You are here

public function DefaultTags::testNode in Metatag 8

Test the default values for a Node entity.

File

tests/src/Functional/DefaultTags.php, line 86

Class

DefaultTags
Verify that the configured defaults load as intended.

Namespace

Drupal\Tests\metatag\Functional

Code

public function testNode() {
  $node = $this
    ->createContentTypeNode();
  $this_page_url = $node
    ->toUrl('canonical', [
    'absolute' => TRUE,
  ])
    ->toString();

  // Load the node's entity page.
  $this
    ->drupalGet($this_page_url);
  $this
    ->assertSession()
    ->statusCodeEquals(200);

  // Check the meta tags.
  $xpath = $this
    ->xpath("//link[@rel='canonical']");
  self::assertEquals((string) $xpath[0]
    ->getAttribute('href'), $this_page_url);
}