X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Ffield%2Ftests%2Fsrc%2FFunctional%2FRest%2FFieldConfigResourceTestBase.php;fp=web%2Fcore%2Fmodules%2Ffield%2Ftests%2Fsrc%2FFunctional%2FRest%2FFieldConfigResourceTestBase.php;h=40ce43f5788bd5a872504d0dd269094a3b4d2d01;hp=0000000000000000000000000000000000000000;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/modules/field/tests/src/Functional/Rest/FieldConfigResourceTestBase.php b/web/core/modules/field/tests/src/Functional/Rest/FieldConfigResourceTestBase.php new file mode 100644 index 000000000..40ce43f57 --- /dev/null +++ b/web/core/modules/field/tests/src/Functional/Rest/FieldConfigResourceTestBase.php @@ -0,0 +1,119 @@ +grantPermissionsToTestedRole(['administer node fields']); + } + + /** + * {@inheritdoc} + */ + protected function createEntity() { + $camelids = NodeType::create([ + 'name' => 'Camelids', + 'type' => 'camelids', + ]); + $camelids->save(); + + $field_storage = FieldStorageConfig::create([ + 'field_name' => 'field_llama', + 'entity_type' => 'node', + 'type' => 'text', + ]); + $field_storage->save(); + + $entity = FieldConfig::create([ + 'field_storage' => $field_storage, + 'bundle' => 'camelids', + ]); + $entity->save(); + + return $entity; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedNormalizedEntity() { + return [ + 'bundle' => 'camelids', + 'default_value' => [], + 'default_value_callback' => '', + 'dependencies' => [ + 'config' => [ + 'field.storage.node.field_llama', + 'node.type.camelids', + ], + 'module' => [ + 'text', + ], + ], + 'description' => '', + 'entity_type' => 'node', + 'field_name' => 'field_llama', + 'field_type' => 'text', + 'id' => 'node.camelids.field_llama', + 'label' => 'field_llama', + 'langcode' => 'en', + 'required' => FALSE, + 'settings' => [], + 'status' => TRUE, + 'translatable' => TRUE, + 'uuid' => $this->entity->uuid(), + ]; + } + + /** + * {@inheritdoc} + */ + protected function getNormalizedPostEntity() { + // @todo Update in https://www.drupal.org/node/2300677. + } + + /** + * {@inheritdoc} + */ + protected function getExpectedCacheContexts() { + 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 node fields' permission is required."; + } + +}