Commit b1147b9a authored by git's avatar git Committed by Damien McKenna
Browse files

Issue #3136470 by novchuk.v: Replace assertEqual()/assertSame() with count() with assertCount().

parent bb8ed206
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -29,6 +29,8 @@ Metatag 8.x-1.x-dev, xxxx-xx-xx
#3154416 by novchuk.v: Replace assert* involving an instanceof operator with
  assertInstanceOf()/assertNotInstanceOf().
#3170298 by thejimbirch: Provide link to Facebook Open Graph debugger.
#3136470 by novchuk.v: Replace assertEqual()/assertSame() with count() with
  assertCount().


Metatag 8.x-1.14, 2020-08-11
+1 −1
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ class MetatagCustomRouteTest extends BrowserTestBase {
    $this->drupalGet('metatag_test_custom_route/' . $entity_test->id());
    $this->assertSession()->statusCodeEquals(200);
    $xpath = $this->xpath("//meta[@name='keywords']");
    $this->assertEqual(count($xpath), 1);
    $this->assertCount(1, $xpath);
    $this->assertEqual($xpath[0]->getAttribute('content'), 'test');
  }

+5 −5
Original line number Diff line number Diff line
@@ -354,7 +354,7 @@ abstract class MetatagFieldTestBase extends BrowserTestBase {
    $entities = \Drupal::entityTypeManager()
      ->getStorage($this->entityType)
      ->loadByProperties([$this->entityTitleField => $title]);
    $this->assertEqual(1, count($entities), 'Entity was saved');
    $this->assertCount(1, $entities, 'Entity was saved');
    $entity = reset($entities);

    // @todo Confirm the values output correctly.
@@ -436,7 +436,7 @@ abstract class MetatagFieldTestBase extends BrowserTestBase {
    $entities = \Drupal::entityTypeManager()
      ->getStorage($this->entityType)
      ->loadByProperties([$this->entityTitleField => $title]);
    $this->assertEqual(1, count($entities), 'Entity was saved');
    $this->assertCount(1, $entities, 'Entity was saved');
    $entity = reset($entities);

    // @todo Confirm the values output correctly.
@@ -477,7 +477,7 @@ abstract class MetatagFieldTestBase extends BrowserTestBase {
    $entities = \Drupal::entityTypeManager()
      ->getStorage('entity_test')
      ->loadByProperties([$this->entityTitleField => 'Barfoo']);
    $this->assertEqual(1, count($entities), 'Entity was saved');
    $this->assertCount(1, $entities, 'Entity was saved');
    $entity = reset($entities);

    // Make sure tags that have a field value but no default value still show
@@ -485,7 +485,7 @@ abstract class MetatagFieldTestBase extends BrowserTestBase {
    $this->drupalGet($entity->toUrl());
    $this->assertSession()->statusCodeEquals(200);
    $elements = $this->cssSelect('meta[name=metatag_test_tag]');
    $this->assertTrue(count($elements) === 1, 'Found keywords metatag_test_tag from defaults');
    $this->assertCount(1, $elements, 'Found keywords metatag_test_tag from defaults');
    $this->assertEqual((string) $elements[0]['content'], 'Kilimanjaro', 'Field value for metatag_test_tag found when no default set.');

    // @todo This should not be required, but meta tags does not invalidate
@@ -503,7 +503,7 @@ abstract class MetatagFieldTestBase extends BrowserTestBase {
    $this->drupalGet($entity->toUrl());
    $this->assertSession()->statusCodeEquals(200);
    $elements = $this->cssSelect('meta[name=metatag_test_tag]');
    $this->assertTrue(count($elements) === 1, 'Found test metatag from defaults');
    $this->assertCount(1, $elements, 'Found test metatag from defaults');
    $this->verbose('<pre>' . print_r($elements, TRUE) . '</pre>');
    $this->assertEqual((string) $elements[0]['content'], $values['metatag_test_tag']);
  }
+13 −13
Original line number Diff line number Diff line
@@ -79,13 +79,13 @@ class MetatagFrontpageTest extends BrowserTestBase {
    foreach ($edit as $metatag => $metatag_value) {
      $xpath = $this->xpath("//meta[@name='" . $metatag . "']");
      if ($metatag == 'title') {
        $this->assertEqual(count($xpath), 0, 'Title meta tag not found.');
        $this->assertCount(0, $xpath, 'Title meta tag not found.');
        $xpath = $this->xpath("//title");
        $this->assertEqual(count($xpath), 1, 'Head title tag found.');
        $this->assertCount(1, $xpath, 'Head title tag found.');
        $value = $xpath[0]->getText();
      }
      else {
        $this->assertEqual(count($xpath), 1, 'Exactly one ' . $metatag . ' meta tag found.');
        $this->assertCount(1, $xpath, 'Exactly one ' . $metatag . ' meta tag found.');
        $value = $xpath[0]->getAttribute('content');
      }
      $this->assertEqual($value, $metatag_value);
@@ -97,13 +97,13 @@ class MetatagFrontpageTest extends BrowserTestBase {
    foreach ($edit as $metatag => $metatag_value) {
      $xpath = $this->xpath("//meta[@name='" . $metatag . "']");
      if ($metatag == 'title') {
        $this->assertEqual(count($xpath), 0, 'Title meta tag not found.');
        $this->assertCount(0, $xpath, 'Title meta tag not found.');
        $xpath = $this->xpath("//title");
        $this->assertEqual(count($xpath), 1, 'Head title tag found.');
        $this->assertCount(1, $xpath, 'Head title tag found.');
        $value = $xpath[0]->getText();
      }
      else {
        $this->assertEqual(count($xpath), 1, 'Exactly one ' . $metatag . ' meta tag found.');
        $this->assertCount(1, $xpath, 'Exactly one ' . $metatag . ' meta tag found.');
        $value = $xpath[0]->getAttribute('content');
      }
      $this->assertEqual($value, $metatag_value);
@@ -124,7 +124,7 @@ class MetatagFrontpageTest extends BrowserTestBase {
    $this->assertSession()->statusCodeEquals(200);
    foreach ($edit as $metatag => $metatag_value) {
      $xpath = $this->xpath("//meta[@name='" . $metatag . "']");
      $this->assertEqual(count($xpath), 1, 'Exactly one ' . $metatag . ' meta tag found.');
      $this->assertCount(1, $xpath, 'Exactly one ' . $metatag . ' meta tag found.');
      $value = $xpath[0]->getAttribute('content');
      $this->assertEqual($value, $metatag_value);
    }
@@ -154,13 +154,13 @@ class MetatagFrontpageTest extends BrowserTestBase {
    foreach ($edit as $metatag => $metatag_value) {
      $xpath = $this->xpath("//meta[@name='" . $metatag . "']");
      if ($metatag == 'title') {
        $this->assertEqual(count($xpath), 0, 'Title meta tag not found.');
        $this->assertCount(0, $xpath, 'Title meta tag not found.');
        $xpath = $this->xpath("//title");
        $this->assertEqual(count($xpath), 1, 'Head title tag found.');
        $this->assertCount(1, $xpath, 'Head title tag found.');
        $value = $xpath[0]->getText();
      }
      else {
        $this->assertEqual(count($xpath), 1, 'Exactly one ' . $metatag . ' meta tag found.');
        $this->assertCount(1, $xpath, 'Exactly one ' . $metatag . ' meta tag found.');
        $value = $xpath[0]->getAttribute('content');
      }
      $this->assertEqual($value, $metatag_value);
@@ -192,13 +192,13 @@ class MetatagFrontpageTest extends BrowserTestBase {
    foreach ($edit as $metatag => $metatag_value) {
      $xpath = $this->xpath("//meta[@name='" . $metatag . "']");
      if ($metatag == 'title') {
        $this->assertEqual(count($xpath), 0, 'Title meta tag not found.');
        $this->assertCount(0, $xpath, 'Title meta tag not found.');
        $xpath = $this->xpath("//title");
        $this->assertEqual(count($xpath), 1, 'Head title tag found.');
        $this->assertCount(1, $xpath, 'Head title tag found.');
        $value = $xpath[0]->getText();
      }
      else {
        $this->assertEqual(count($xpath), 1, 'Exactly one ' . $metatag . ' meta tag found.');
        $this->assertCount(1, $xpath, 'Exactly one ' . $metatag . ' meta tag found.');
        $value = $xpath[0]->getAttribute('content');
      }
      $this->assertEqual($value, $metatag_value);
+4 −4
Original line number Diff line number Diff line
@@ -150,7 +150,7 @@ class MetatagNodeTranslationTest extends BrowserTestBase {
    $this->assertSession()->statusCodeEquals(200);

    $xpath = $this->xpath("//meta[@name='description']");
    $this->assertEqual(count($xpath), 1, 'Exactly one description meta tag found.');
    $this->assertCount(1, $xpath, 'Exactly one description meta tag found.');
    $value = $xpath[0]->getAttribute('content');
    $this->assertEqual($value, 'French summary.');

@@ -170,7 +170,7 @@ class MetatagNodeTranslationTest extends BrowserTestBase {
    $this->drupalGet('es/node/1');
    $this->assertSession()->statusCodeEquals(200);
    $xpath = $this->xpath("//meta[@name='description']");
    $this->assertEqual(count($xpath), 1, 'Exactly one description meta tag found.');
    $this->assertCount(1, $xpath, 'Exactly one description meta tag found.');
    $value = $xpath[0]->getAttribute('content');
    $this->assertEqual($value, 'Spanish summary.');
    $this->assertNotEqual($value, 'French summary.');
@@ -192,7 +192,7 @@ class MetatagNodeTranslationTest extends BrowserTestBase {
    $this->assertSession()->statusCodeEquals(200);

    $xpath = $this->xpath("//meta[@name='description']");
    $this->assertEqual(count($xpath), 1, 'Exactly one description meta tag found.');
    $this->assertCount(1, $xpath, 'Exactly one description meta tag found.');
    $value = $xpath[0]->getAttribute('content');
    $this->assertEqual($value, 'Overridden French description.');
    $this->assertNotEqual($value, 'Spanish summary.');
@@ -207,7 +207,7 @@ class MetatagNodeTranslationTest extends BrowserTestBase {
    $this->assertSession()->statusCodeEquals(200);

    $xpath = $this->xpath("//meta[@name='description']");
    $this->assertEqual(count($xpath), 1, 'Exactly one description meta tag found.');
    $this->assertCount(1, $xpath, 'Exactly one description meta tag found.');
    $value = $xpath[0]->getAttribute('content');
    $this->assertEqual($value, 'Overridden Spanish description.');
    $this->assertNotEqual($value, 'Spanish summary.');
Loading