public function NodeTeaserAndPage::testNodeTeaserAndPage in Manage display 8
Test the title replacements work as expected.
File
- tests/
src/ Functional/ NodeTeaserAndPage.php, line 43
Class
- NodeTeaserAndPage
- Test the title field is configurable.
Namespace
Drupal\Tests\manage_display\FunctionalCode
public function testNodeTeaserAndPage() {
// Configure display.
$display = EntityViewDisplay::load('node.page.default');
$display
->setComponent('uid', [
'type' => 'entity_reference_label',
'label' => 'above',
'settings' => [
'link' => FALSE,
],
])
->save();
// Create user and node.
$user = $this
->drupalCreateUser([
'administer nodes',
]);
$this
->drupalLogin($user);
$node = $this
->drupalCreateNode([
'uid' => $user
->id(),
]);
$assert = $this
->assertSession();
// Check page display.
$this
->drupalGet($node
->toUrl());
$assert
->elementTextContains('css', 'div.field--name-uid', $user
->getAccountName());
$assert
->elementNotExists('css', 'div.field--name-uid a');
$assert
->elementTextContains('css', 'h1.page-title span', $node
->getTitle());
// Check teaser display.
$this
->drupalGet('node');
$assert
->elementTextContains('css', 'div.field--name-title h2 a[href="' . $node
->toUrl()
->toString() . '"]', $node
->getTitle());
}