NodeTeaserAndPage.php in Manage display 8
File
tests/src/Functional/NodeTeaserAndPage.php
View source
<?php
namespace Drupal\Tests\manage_display\Functional;
use Drupal\Tests\BrowserTestBase;
use Drupal\Core\Entity\Entity\EntityViewDisplay;
class NodeTeaserAndPage extends BrowserTestBase {
protected static $modules = [
'node',
'manage_display',
'manage_display_fix_title',
'views',
];
protected $defaultTheme = 'classy';
protected function setUp() : void {
parent::setUp();
$this
->drupalCreateContentType([
'type' => 'page',
'name' => 'Basic page',
]);
}
public function testNodeTeaserAndPage() {
$display = EntityViewDisplay::load('node.page.default');
$display
->setComponent('uid', [
'type' => 'entity_reference_label',
'label' => 'above',
'settings' => [
'link' => FALSE,
],
])
->save();
$user = $this
->drupalCreateUser([
'administer nodes',
]);
$this
->drupalLogin($user);
$node = $this
->drupalCreateNode([
'uid' => $user
->id(),
]);
$assert = $this
->assertSession();
$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());
$this
->drupalGet('node');
$assert
->elementTextContains('css', 'div.field--name-title h2 a[href="' . $node
->toUrl()
->toString() . '"]', $node
->getTitle());
}
}