X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2Fcore%2Fmodules%2Feditor%2Ftests%2Fsrc%2FFunctional%2FRest%2FEditorResourceTestBase.php;fp=web%2Fcore%2Fmodules%2Feditor%2Ftests%2Fsrc%2FFunctional%2FRest%2FEditorResourceTestBase.php;h=2dc43dc6a3c3813216d89f70a6b1ca0640cd5a6c;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hp=0000000000000000000000000000000000000000;hpb=74df008bdbb3a11eeea356744f39b802369bda3c;p=yaffs-website
diff --git a/web/core/modules/editor/tests/src/Functional/Rest/EditorResourceTestBase.php b/web/core/modules/editor/tests/src/Functional/Rest/EditorResourceTestBase.php
new file mode 100644
index 000000000..2dc43dc6a
--- /dev/null
+++ b/web/core/modules/editor/tests/src/Functional/Rest/EditorResourceTestBase.php
@@ -0,0 +1,184 @@
+grantPermissionsToTestedRole(['administer filters']);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ 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' => '
',
+ ],
+ ],
+ ],
+ ]);
+
+ $llama_format->save();
+
+ // Create a "Camelids" editor.
+ $camelids = Editor::create([
+ 'format' => 'llama',
+ 'editor' => 'ckeditor',
+ ]);
+ $camelids
+ ->setImageUploadSettings([
+ 'status' => FALSE,
+ 'scheme' => file_default_scheme(),
+ 'directory' => 'inline-images',
+ 'max_size' => '',
+ 'max_dimensions' => [
+ 'width' => '',
+ 'height' => '',
+ ],
+ ])
+ ->save();
+
+ return $camelids;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getExpectedNormalizedEntity() {
+ return [
+ 'dependencies' => [
+ 'config' => [
+ 'filter.format.llama',
+ ],
+ 'module' => [
+ 'ckeditor',
+ ],
+ ],
+ 'editor' => 'ckeditor',
+ 'format' => 'llama',
+ 'image_upload' => [
+ 'status' => FALSE,
+ 'scheme' => 'public',
+ 'directory' => 'inline-images',
+ 'max_size' => '',
+ 'max_dimensions' => [
+ 'width' => NULL,
+ 'height' => NULL,
+ ],
+ ],
+ 'langcode' => 'en',
+ 'settings' => [
+ 'toolbar' => [
+ 'rows' => [
+ [
+ [
+ 'name' => 'Formatting',
+ 'items' => [
+ 'Bold',
+ 'Italic',
+ ],
+ ],
+ [
+ 'name' => 'Links',
+ 'items' => [
+ 'DrupalLink',
+ 'DrupalUnlink',
+ ],
+ ],
+ [
+ 'name' => 'Lists',
+ 'items' => [
+ 'BulletedList',
+ 'NumberedList',
+ ],
+ ],
+ [
+ 'name' => 'Media',
+ 'items' => [
+ 'Blockquote',
+ 'DrupalImage',
+ ],
+ ],
+ [
+ 'name' => 'Tools',
+ 'items' => [
+ 'Source',
+ ],
+ ],
+ ],
+ ],
+ ],
+ 'plugins' => [
+ 'language' => [
+ 'language_list' => 'un',
+ ],
+ ],
+ ],
+ 'status' => TRUE,
+ 'uuid' => $this->entity->uuid(),
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getNormalizedPostEntity() {
+ // @todo Update in https://www.drupal.org/node/2300677.
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getExpectedCacheContexts() {
+ // @see ::createEntity()
+ return ['user.permissions'];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getExpectedUnauthorizedAccessMessage($method) {
+ if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
+ return parent::getExpectedUnauthorizedAccessMessage($method);
+ }
+
+ return "The 'administer filters' permission is required.";
+ }
+
+}