Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/node/tests/src/Functional/NodeDisplayConfigurableTest.php @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
4:a9cd425dd02b | 5:12f9dff5fda9 |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\Tests\node\Functional; | |
4 | |
5 use Drupal\Core\Entity\Entity\EntityViewDisplay; | |
6 | |
7 /** | |
8 * Tests making node base fields' displays configurable. | |
9 * | |
10 * @group node | |
11 */ | |
12 class NodeDisplayConfigurableTest extends NodeTestBase { | |
13 | |
14 /** | |
15 * Modules to enable. | |
16 * | |
17 * @var array | |
18 */ | |
19 public static $modules = ['quickedit', 'rdf']; | |
20 | |
21 /** | |
22 * Sets base fields to configurable display and check settings are respected. | |
23 */ | |
24 public function testDisplayConfigurable() { | |
25 // Change the node type setting to show submitted by information. | |
26 $node_type = \Drupal::entityTypeManager()->getStorage('node_type')->load('page'); | |
27 $node_type->setDisplaySubmitted(TRUE); | |
28 $node_type->save(); | |
29 | |
30 $user = $this->drupalCreateUser(['access in-place editing', 'administer nodes']); | |
31 $this->drupalLogin($user); | |
32 $node = $this->drupalCreateNode(['uid' => $user->id()]); | |
33 $assert = $this->assertSession(); | |
34 | |
35 // Check the node with Drupal default non-configurable display. | |
36 $this->drupalGet($node->toUrl()); | |
37 $assert->elementTextContains('css', 'span.field--name-created', \Drupal::service('date.formatter')->format($node->getCreatedTime())); | |
38 $assert->elementTextContains('css', 'span.field--name-uid[data-quickedit-field-id="node/1/uid/en/full"]', $user->getAccountName()); | |
39 $assert->elementTextContains('css', 'div.node__submitted', 'Submitted by'); | |
40 $assert->elementTextContains('css', 'span.field--name-title', $node->getTitle()); | |
41 | |
42 // Enable module to make base fields' displays configurable. | |
43 \Drupal::service('module_installer')->install(['node_display_configurable_test']); | |
44 | |
45 // Configure display. | |
46 $display = EntityViewDisplay::load('node.page.default'); | |
47 $display->setComponent('uid', | |
48 [ | |
49 'type' => 'entity_reference_label', | |
50 'label' => 'above', | |
51 'settings' => ['link' => FALSE], | |
52 ]) | |
53 ->save(); | |
54 | |
55 // Recheck the node with configurable display. | |
56 $this->drupalGet($node->toUrl()); | |
57 $assert->elementTextContains('css', 'span.field--name-created', \Drupal::service('date.formatter')->format($node->getCreatedTime())); | |
58 $assert->elementTextContains('css', 'span.field--name-uid[data-quickedit-field-id="node/1/uid/en/full"]', $user->getAccountName()); | |
59 $assert->elementNotExists('css', 'span.field--name-uid a'); | |
60 $assert->elementTextContains('css', 'span.field--name-title', $node->getTitle()); | |
61 $assert->elementExists('css', 'span[property="schema:dateCreated"]'); | |
62 | |
63 // Remove from display. | |
64 $display->removeComponent('uid') | |
65 ->removeComponent('created') | |
66 ->save(); | |
67 | |
68 $this->drupalGet($node->toUrl()); | |
69 $assert->elementNotExists('css', '.field--name-created'); | |
70 $assert->elementNotExists('css', '.field--name-uid'); | |
71 } | |
72 | |
73 } |