Skip to content

Commit 947ee9a

Browse files
Nathaniel Catchpolealexpott
authored andcommitted
Issue #3021406 by ApacheEx, Lendude: Convert \Drupal\Tests\quickedit\FunctionalJavascript\QuickEditLoadingTest::testDisplayOptions to a kernel test
(cherry picked from commit d7618cb)
1 parent 22c7e60 commit 947ee9a

File tree

2 files changed

+88
-14
lines changed

2 files changed

+88
-14
lines changed

modules/quickedit/src/Tests/QuickEditLoadingTest.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -437,20 +437,6 @@ public function testTitleBaseField() {
437437
}
438438
}
439439

440-
/**
441-
* Tests that Quick Edit doesn't make fields rendered with display options
442-
* editable.
443-
*/
444-
public function testDisplayOptions() {
445-
$node = Node::load('1');
446-
$display_settings = [
447-
'label' => 'inline',
448-
];
449-
$build = $node->body->view($display_settings);
450-
$output = \Drupal::service('renderer')->renderRoot($build);
451-
$this->assertFalse(strpos($output, 'data-quickedit-field-id'), 'data-quickedit-field-id attribute not added when rendering field using dynamic display options.');
452-
}
453-
454440
/**
455441
* Tests that Quick Edit works with custom render pipelines.
456442
*/
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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+
}

0 commit comments

Comments
 (0)