function 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\FunctionalCode
public function testHtmlHeadLinks() : void {
  $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'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.