You are here

public function DefaultTags::testTerm in Metatag 8

Test the default values for a Term entity.

File

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

Class

DefaultTags
Verify that the configured defaults load as intended.

Namespace

Drupal\Tests\metatag\Functional

Code

public function testTerm() {
  $vocab = $this
    ->createVocabulary();
  $term = $this
    ->createTerm([
    'vid' => $vocab
      ->id(),
  ]);
  $this_page_url = $term
    ->toUrl('canonical', [
    'absolute' => TRUE,
  ])
    ->toString();
  $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);
}