You are here

public function DefaultMetatagsTest::testMetaTag in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/system/tests/src/Functional/Page/DefaultMetatagsTest.php \Drupal\Tests\system\Functional\Page\DefaultMetatagsTest::testMetaTag()

Tests meta tags.

File

core/modules/system/tests/src/Functional/Page/DefaultMetatagsTest.php, line 22

Class

DefaultMetatagsTest
Tests default HTML metatags on a page.

Namespace

Drupal\Tests\system\Functional\Page

Code

public function testMetaTag() {
  $this
    ->drupalGet('');

  // Ensures that the charset metatag is on the page.
  $result = $this
    ->xpath('//meta[@charset="utf-8"]');
  $this
    ->assertCount(1, $result);

  // Ensure that the charset one is the first metatag.
  $result = $this
    ->xpath('//meta');
  $this
    ->assertEqual((string) $result[0]
    ->getAttribute('charset'), 'utf-8');

  // Ensure that the shortcut icon is on the page.
  $result = $this
    ->xpath('//link[@rel = "shortcut icon"]');
  $this
    ->assertCount(1, $result, 'The shortcut icon is present.');
}