You are here

public function NodeViewTest::testHtmlHeadLinks in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/node/tests/src/Functional/NodeViewTest.php \Drupal\Tests\node\Functional\NodeViewTest::testHtmlHeadLinks()
  2. 10 core/modules/node/tests/src/Functional/NodeViewTest.php \Drupal\Tests\node\Functional\NodeViewTest::testHtmlHeadLinks()

Tests the html head links.

File

core/modules/node/tests/src/Functional/NodeViewTest.php, line 23

Class

NodeViewTest
Tests the node/{node} page.

Namespace

Drupal\Tests\node\Functional

Code

public function testHtmlHeadLinks() {
  $node = $this
    ->drupalCreateNode();
  $this
    ->drupalGet($node
    ->toUrl());
  $element = $this
    ->assertSession()
    ->elementExists('css', 'link[rel="canonical"]');
  $this
    ->assertEquals($node
    ->toUrl()
    ->setAbsolute()
    ->toString(), $element
    ->getAttribute('href'));
  $element = $this
    ->assertSession()
    ->elementExists('css', 'link[rel="shortlink"]');
  $this
    ->assertEquals($node
    ->toUrl('canonical', [
    'alias' => TRUE,
  ])
    ->setAbsolute()
    ->toString(), $element
    ->getAttribute('href'));
}