You are here

public function NodeViewTest::testHtmlHeadLinks in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/node/tests/src/Functional/NodeViewTest.php \Drupal\Tests\node\Functional\NodeViewTest::testHtmlHeadLinks()
  2. 9 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 21

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'));
}