Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/quickedit/tests/src/Kernel/QuickEditLoadingTest.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\quickedit\Kernel; | |
4 | |
5 use Drupal\KernelTests\KernelTestBase; | |
6 use Drupal\node\Entity\Node; | |
7 use Drupal\Tests\node\Traits\ContentTypeCreationTrait; | |
8 use Drupal\Tests\node\Traits\NodeCreationTrait; | |
9 use Drupal\Tests\user\Traits\UserCreationTrait; | |
10 | |
11 /** | |
12 * Tests loading of in-place editing functionality and lazy loading of its | |
13 * in-place editors. | |
14 * | |
15 * @group quickedit | |
16 */ | |
17 class QuickEditLoadingTest extends KernelTestBase { | |
18 | |
19 use NodeCreationTrait; | |
20 use UserCreationTrait; | |
21 use ContentTypeCreationTrait; | |
22 | |
23 /** | |
24 * {@inheritdoc} | |
25 */ | |
26 protected static $modules = [ | |
27 'user', | |
28 'system', | |
29 'field', | |
30 'node', | |
31 'text', | |
32 'filter', | |
33 'contextual', | |
34 'quickedit', | |
35 ]; | |
36 | |
37 /** | |
38 * A user with permissions to access in-place editor. | |
39 * | |
40 * @var \Drupal\user\UserInterface | |
41 */ | |
42 protected $editorUser; | |
43 | |
44 /** | |
45 * {@inheritdoc} | |
46 */ | |
47 protected function setUp() { | |
48 parent::setUp(); | |
49 | |
50 $this->installSchema('system', 'sequences'); | |
51 $this->installEntitySchema('user'); | |
52 $this->installEntitySchema('node'); | |
53 $this->installConfig(['field', 'filter', 'node']); | |
54 | |
55 // Create a Content type and one test node. | |
56 $this->createContentType(['type' => 'page']); | |
57 $this->createNode(); | |
58 | |
59 $this->editorUser = $this->createUser([ | |
60 'access content', | |
61 'create page content', | |
62 'edit any page content', | |
63 'access contextual links', | |
64 'access in-place editing', | |
65 ]); | |
66 } | |
67 | |
68 /** | |
69 * Tests that Quick Edit doesn't make fields rendered with display options | |
70 * editable. | |
71 */ | |
72 public function testDisplayOptions() { | |
73 $node = Node::load(1); | |
74 $renderer = $this->container->get('renderer'); | |
75 $this->container->get('current_user')->setAccount($this->editorUser); | |
76 | |
77 $build = $node->body->view(['label' => 'inline']); | |
78 $this->setRawContent($renderer->renderRoot($build)); | |
79 $elements = $this->xpath('//div[@data-quickedit-field-id]'); | |
80 $this->assertFalse(!empty($elements), 'data-quickedit-field-id attribute not added when rendering field using dynamic display options.'); | |
81 | |
82 $build = $node->body->view('default'); | |
83 $this->setRawContent($renderer->renderRoot($build)); | |
84 $elements = $this->xpath('//div[@data-quickedit-field-id="node/1/body/en/default"]'); | |
85 $this->assertTrue(!empty($elements), 'Body with data-quickedit-field-id attribute found.'); | |
86 } | |
87 | |
88 } |