You are here

public function MetatagTestBase::checkByPathConfig in Metatag 7

Checks if meta tags have been added correctly from a test_object.

Parameters

object $test_object: Metatag mapping object.

3 calls to MetatagTestBase::checkByPathConfig()
MetatagContextTest::testFrontPage in metatag_context/tests/MetatagContextTest.test
Test handling the front page.
MetatagContextTest::testNode in metatag_context/tests/MetatagContextTest.test
Test handling a node.
MetatagContextWithI18nTest::testContextI18n in metatag_context/tests/MetatagContextWithI18nTest.test
Verify that strings are added to the translation system.

File

tests/MetatagTestBase.test, line 634
A base class for the Metatag tests, provides shared methods.

Class

MetatagTestBase
A base class for the Metatag tests, provides shared methods.

Code

public function checkByPathConfig($test_object) {
  $this
    ->drupalGet($test_object->path);
  $this
    ->assertResponse(200);

  // Manually test the page title.
  if (!empty($test_object->title)) {
    $this
      ->assertTitle($test_object->title, 'Title found in ' . $test_object->path);
  }

  // Test the other meta tags.
  $tags = array(
    'description',
    'abstract',
    'keywords',
  );
  foreach ($tags as $tag) {
    if (!empty($test_object->{$tag})) {
      $this
        ->assertRaw($test_object->{$tag}, $tag . ' found in ' . $test_object->path);
    }
    else {
      $this
        ->assertNoRaw('<meta name="' . $tag, $tag . ' not found in ' . $test_object->path);
    }
  }
}