You are here

protected function EditorResourceTestBase::createEntity in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/editor/tests/src/Functional/Rest/EditorResourceTestBase.php \Drupal\Tests\editor\Functional\Rest\EditorResourceTestBase::createEntity()
  2. 10 core/modules/editor/tests/src/Functional/Rest/EditorResourceTestBase.php \Drupal\Tests\editor\Functional\Rest\EditorResourceTestBase::createEntity()

Creates the entity to be tested.

Return value

\Drupal\Core\Entity\EntityInterface The entity to be tested.

Overrides EntityResourceTestBase::createEntity

File

core/modules/editor/tests/src/Functional/Rest/EditorResourceTestBase.php, line 41

Class

EditorResourceTestBase
ResourceTestBase for Editor entity.

Namespace

Drupal\Tests\editor\Functional\Rest

Code

protected function createEntity() {

  // Create a "Llama" filter format.
  $llama_format = FilterFormat::create([
    'name' => 'Llama',
    'format' => 'llama',
    'langcode' => 'es',
    'filters' => [
      'filter_html' => [
        'status' => TRUE,
        'settings' => [
          'allowed_html' => '<p> <a> <b> <lo>',
        ],
      ],
    ],
  ]);
  $llama_format
    ->save();

  // Create a "Camelids" editor.
  $camelids = Editor::create([
    'format' => 'llama',
    'editor' => 'ckeditor',
  ]);
  $camelids
    ->setImageUploadSettings([
    'status' => FALSE,
    'scheme' => 'public',
    'directory' => 'inline-images',
    'max_size' => '',
    'max_dimensions' => [
      'width' => '',
      'height' => '',
    ],
  ])
    ->save();
  return $camelids;
}