You are here

public function QuickEditLoadingTest::testDisplayOptions in Drupal 9

Same name in this branch
  1. 9 core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditLoadingTest.php \Drupal\Tests\quickedit\FunctionalJavascript\QuickEditLoadingTest::testDisplayOptions()
  2. 9 core/modules/quickedit/tests/src/Kernel/QuickEditLoadingTest.php \Drupal\Tests\quickedit\Kernel\QuickEditLoadingTest::testDisplayOptions()
Same name and namespace in other branches
  1. 8 core/modules/quickedit/tests/src/Kernel/QuickEditLoadingTest.php \Drupal\Tests\quickedit\Kernel\QuickEditLoadingTest::testDisplayOptions()

Tests that Quick Edit doesn't make fields rendered with display options editable.

File

core/modules/quickedit/tests/src/Kernel/QuickEditLoadingTest.php, line 72

Class

QuickEditLoadingTest
Tests loading of in-place editing functionality and lazy loading of its in-place editors.

Namespace

Drupal\Tests\quickedit\Kernel

Code

public function testDisplayOptions() {
  $node = Node::load(1);
  $renderer = $this->container
    ->get('renderer');
  $this->container
    ->get('current_user')
    ->setAccount($this->editorUser);
  $build = $node->body
    ->view([
    'label' => 'inline',
  ]);
  $this
    ->setRawContent($renderer
    ->renderRoot($build));
  $elements = $this
    ->xpath('//div[@data-quickedit-field-id]');
  $this
    ->assertFalse(!empty($elements), 'data-quickedit-field-id attribute not added when rendering field using dynamic display options.');
  $build = $node->body
    ->view('default');
  $this
    ->setRawContent($renderer
    ->renderRoot($build));
  $elements = $this
    ->xpath('//div[@data-quickedit-field-id="node/1/body/en/default"]');
  $this
    ->assertTrue(!empty($elements), 'Body with data-quickedit-field-id attribute found.');
}