NodeViewTest.php in Drupal 10
File
core/modules/node/tests/src/Functional/NodeViewTest.php
View source
<?php
namespace Drupal\Tests\node\Functional;
class NodeViewTest extends NodeTestBase {
protected $defaultTheme = 'stark';
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'));
}
public function testLinkHeader() {
$node = $this
->drupalCreateNode();
$this
->drupalGet($node
->toUrl());
$this
->assertArrayNotHasKey('Link', $this
->getSession()
->getResponseHeaders());
}
public function testMultiByteUtf8() {
$title = '🐝';
$this
->assertLessThan(strlen($title), mb_strlen($title, 'utf-8'));
$node = $this
->drupalCreateNode([
'title' => $title,
]);
$this
->drupalGet($node
->toUrl());
$this
->assertSession()
->elementTextEquals('xpath', '//h1/span', $title);
}
}