class NodeViewTest
Same name and namespace in other branches
- 11.x core/modules/node/tests/src/Functional/NodeViewTest.php \Drupal\Tests\node\Functional\NodeViewTest
Tests the node/{node} page.
@group node
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\node\Functional\NodeTestBase implements \Drupal\Tests\BrowserTestBase
- class \Drupal\Tests\node\Functional\NodeViewTest implements \Drupal\Tests\node\Functional\NodeTestBase
- class \Drupal\Tests\node\Functional\NodeTestBase implements \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of NodeViewTest
See also
\Drupal\node\Controller\NodeController
File
-
core/
modules/ node/ tests/ src/ Functional/ NodeViewTest.php, line 11
Namespace
Drupal\Tests\node\FunctionalView source
class NodeViewTest extends NodeTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Tests the html head links.
*/
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'));
}
/**
* Tests the Link header.
*/
public function testLinkHeader() {
$node = $this->drupalCreateNode();
$this->drupalGet($node->toUrl());
$this->assertArrayNotHasKey('Link', $this->getSession()
->getResponseHeaders());
}
/**
* Tests that we store and retrieve multi-byte UTF-8 characters correctly.
*/
public function testMultiByteUtf8() {
$title = '🐝';
// To ensure that the title has multi-byte characters, we compare the byte
// length to the character length.
$this->assertLessThan(strlen($title), mb_strlen($title, 'utf-8'));
$node = $this->drupalCreateNode([
'title' => $title,
]);
$this->drupalGet($node->toUrl());
// Verify that the passed title was returned.
$this->assertSession()
->elementTextEquals('xpath', '//h1/span', $title);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.