3 namespace Drupal\Tests\rest\Functional\EntityResource\FieldConfig;
5 use Drupal\field\Entity\FieldConfig;
6 use Drupal\field\Entity\FieldStorageConfig;
7 use Drupal\node\Entity\NodeType;
8 use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
10 abstract class FieldConfigResourceTestBase extends EntityResourceTestBase {
15 public static $modules = ['field', 'node'];
20 protected static $entityTypeId = 'field_config';
23 * @var \Drupal\field\FieldConfigInterface
30 protected function setUpAuthorization($method) {
31 $this->grantPermissionsToTestedRole(['administer node fields']);
37 protected function createEntity() {
38 $camelids = NodeType::create([
44 $field_storage = FieldStorageConfig::create([
45 'field_name' => 'field_llama',
46 'entity_type' => 'node',
49 $field_storage->save();
51 $entity = FieldConfig::create([
52 'field_storage' => $field_storage,
53 'bundle' => 'camelids',
63 protected function getExpectedNormalizedEntity() {
65 'bundle' => 'camelids',
66 'default_value' => [],
67 'default_value_callback' => '',
70 'field.storage.node.field_llama',
78 'entity_type' => 'node',
79 'field_name' => 'field_llama',
80 'field_type' => 'text',
81 'id' => 'node.camelids.field_llama',
82 'label' => 'field_llama',
87 'translatable' => TRUE,
88 'uuid' => $this->entity->uuid(),
95 protected function getNormalizedPostEntity() {
96 // @todo Update in https://www.drupal.org/node/2300677.
102 protected function getExpectedCacheContexts() {
111 protected function getExpectedUnauthorizedAccessMessage($method) {
112 if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
113 return parent::getExpectedUnauthorizedAccessMessage($method);
116 return "The 'administer node fields' permission is required.";