class NodeLinksTest
Same name and namespace in other branches
- 11.x core/modules/node/tests/src/Functional/NodeLinksTest.php \Drupal\Tests\node\Functional\NodeLinksTest
- 10 core/modules/node/tests/src/Functional/NodeLinksTest.php \Drupal\Tests\node\Functional\NodeLinksTest
- 8.9.x core/modules/node/tests/src/Functional/NodeLinksTest.php \Drupal\Tests\node\Functional\NodeLinksTest
Tests the output of node links (read more, add new comment, etc).
@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 extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\node\Functional\NodeTestBase extends \Drupal\Tests\BrowserTestBase
- class \Drupal\Tests\node\Functional\NodeLinksTest extends \Drupal\Tests\node\Functional\NodeTestBase
- class \Drupal\Tests\node\Functional\NodeTestBase extends \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of NodeLinksTest
File
-
core/
modules/ node/ tests/ src/ Functional/ NodeLinksTest.php, line 12
Namespace
Drupal\Tests\node\FunctionalView source
class NodeLinksTest extends NodeTestBase {
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'views',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Tests that the links can be hidden in the view display settings.
*/
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');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.