public function NodeLinksTest::testHideLinks in Drupal 9
Same name and namespace in other branches
- 8 core/modules/node/tests/src/Functional/NodeLinksTest.php \Drupal\Tests\node\Functional\NodeLinksTest::testHideLinks()
- 10 core/modules/node/tests/src/Functional/NodeLinksTest.php \Drupal\Tests\node\Functional\NodeLinksTest::testHideLinks()
Tests that the links can be hidden in the view display settings.
File
- core/
modules/ node/ tests/ src/ Functional/ NodeLinksTest.php, line 29
Class
- NodeLinksTest
- Tests the output of node links (read more, add new comment, etc).
Namespace
Drupal\Tests\node\FunctionalCode
public function testHideLinks() {
$node = $this
->drupalCreateNode([
'type' => 'article',
'promote' => NodeInterface::PROMOTED,
]);
// Links are displayed by default.
$this
->drupalGet('node');
$this
->assertSession()
->pageTextContains($node
->getTitle());
$this
->assertSession()
->linkExists('Read more');
// Hide links.
\Drupal::service('entity_display.repository')
->getViewDisplay('node', 'article', 'teaser')
->removeComponent('links')
->save();
$this
->drupalGet('node');
$this
->assertSession()
->pageTextContains($node
->getTitle());
$this
->assertSession()
->linkNotExists('Read more');
}