You are here

protected function EditorIntegrationTest::getSelectedEditor in Drupal 9

Returns the in-place editor that quickedit selects.

Parameters

int $entity_id: An entity ID.

string $field_name: A field name.

string $view_mode: A view mode.

Return value

string Returns the selected in-place editor.

1 call to EditorIntegrationTest::getSelectedEditor()
EditorIntegrationTest::testEditorSelection in core/modules/quickedit/tests/src/Kernel/EditorIntegrationTest.php
Tests editor selection when the Editor module is present.

File

core/modules/quickedit/tests/src/Kernel/EditorIntegrationTest.php, line 122

Class

EditorIntegrationTest
Tests Edit module integration (Editor module's inline editing support).

Namespace

Drupal\Tests\quickedit\Kernel

Code

protected function getSelectedEditor($entity_id, $field_name, $view_mode = 'default') {
  $storage = $this->container
    ->get('entity_type.manager')
    ->getStorage('entity_test');
  $storage
    ->resetCache([
    $entity_id,
  ]);
  $entity = $storage
    ->load($entity_id);
  $items = $entity
    ->get($field_name);
  $options = \Drupal::service('entity_display.repository')
    ->getViewDisplay('entity_test', 'entity_test', $view_mode)
    ->getComponent($field_name);
  return $this->editorSelector
    ->getEditor($options['type'], $items);
}