public function NodeViewTest::testHtmlHeadLinks in Drupal 9
Same name and namespace in other branches
- 8 core/modules/node/tests/src/Functional/NodeViewTest.php \Drupal\Tests\node\Functional\NodeViewTest::testHtmlHeadLinks()
- 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\FunctionalCode
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'));
}