3 namespace Drupal\Tests\rest\Functional\EntityResource\Editor;
5 use Drupal\editor\Entity\Editor;
6 use Drupal\filter\Entity\FilterFormat;
7 use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
10 * ResourceTestBase for Editor entity.
12 abstract class EditorResourceTestBase extends EntityResourceTestBase {
17 public static $modules = ['ckeditor', 'editor'];
22 protected static $entityTypeId = 'editor';
27 * @var \Drupal\editor\EditorInterface
34 protected function setUpAuthorization($method) {
35 $this->grantPermissionsToTestedRole(['administer filters']);
41 protected function createEntity() {
42 // Create a "Llama" filter format.
43 $llama_format = FilterFormat::create([
51 'allowed_html' => '<p> <a> <b> <lo>',
57 $llama_format->save();
59 // Create a "Camelids" editor.
60 $camelids = Editor::create([
62 'editor' => 'ckeditor',
65 ->setImageUploadSettings([
67 'scheme' => file_default_scheme(),
68 'directory' => 'inline-images',
83 protected function getExpectedNormalizedEntity() {
87 'filter.format.llama',
93 'editor' => 'ckeditor',
98 'directory' => 'inline-images',
100 'max_dimensions' => [
111 'name' => 'Formatting',
149 'language_list' => 'un',
154 'uuid' => $this->entity->uuid(),
161 protected function getNormalizedPostEntity() {
162 // @todo Update in https://www.drupal.org/node/2300677.
168 protected function getExpectedCacheContexts() {
169 // @see ::createEntity()
170 return ['user.permissions'];
176 protected function getExpectedUnauthorizedAccessMessage($method) {
177 if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
178 return parent::getExpectedUnauthorizedAccessMessage($method);
181 return "The 'administer filters' permission is required.";