You are here

protected function EditorSelectionTest::getSelectedEditor in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/quickedit/tests/src/Kernel/EditorSelectionTest.php \Drupal\Tests\quickedit\Kernel\EditorSelectionTest::getSelectedEditor()
  2. 9 core/modules/quickedit/tests/src/Kernel/EditorSelectionTest.php \Drupal\Tests\quickedit\Kernel\EditorSelectionTest::getSelectedEditor()

Returns the in-place editor that Quick Edit selects.

File

core/modules/quickedit/tests/src/Kernel/EditorSelectionTest.php, line 39

Class

EditorSelectionTest
Tests in-place field editor selection.

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);
}