class NodeLinksTest
Same name in this branch
- 11.x core/modules/node/tests/src/Functional/NodeLinksTest.php \Drupal\Tests\node\Functional\NodeLinksTest
Same name and namespace in other branches
- 10 core/modules/node/tests/src/Functional/NodeLinksTest.php \Drupal\Tests\node\Functional\NodeLinksTest
- 9 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
- main core/modules/node/tests/src/Functional/NodeLinksTest.php \Drupal\Tests\node\Functional\NodeLinksTest
- main core/modules/node/tests/src/Kernel/NodeLinksTest.php \Drupal\Tests\node\Kernel\NodeLinksTest
Tests the output of node links (read more, add new comment, etc).
Attributes
#[Group('node')]
#[RunTestsInSeparateProcesses]
Hierarchy
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\Tests\DrupalTestCaseTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\PhpUnitCompatibilityTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait, \Drupal\Tests\BrowserHtmlDebugTrait, \Drupal\Tests\HttpKernelUiHelperTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\node\Kernel\NodeLinksTest uses \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\node\Traits\NodeCreationTrait extends \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of NodeLinksTest
File
-
core/
modules/ node/ tests/ src/ Kernel/ NodeLinksTest.php, line 19
Namespace
Drupal\Tests\node\KernelView source
class NodeLinksTest extends KernelTestBase {
use UserCreationTrait;
use NodeCreationTrait;
/**
* {@inheritdoc}
*/
protected static $modules = [
'system',
'user',
'field',
'datetime',
'filter',
'text',
'node',
'views',
];
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->installEntitySchema('user');
$this->installEntitySchema('node');
$this->installConfig([
'filter',
]);
$this->installConfig([
'node',
]);
$this->setUpCurrentUser(permissions: [
'access content',
]);
DateFormat::create([
'id' => 'fallback',
'label' => 'Fallback',
'pattern' => 'Y-m-d',
])->save();
$node_type = NodeType::create([
'type' => 'article',
'name' => 'Article',
]);
$node_type->save();
}
/**
* Tests that the links can be hidden in the view display settings.
*/
public function testHideLinks() : void {
$node = $this->createNode([
'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.