3 namespace Drupal\Tests\rest\Functional\EntityResource\BaseFieldOverride;
5 use Drupal\Core\Field\Entity\BaseFieldOverride;
6 use Drupal\node\Entity\NodeType;
7 use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
9 abstract class BaseFieldOverrideResourceTestBase extends EntityResourceTestBase {
14 public static $modules = ['field', 'node'];
19 protected static $entityTypeId = 'base_field_override';
22 * @var \Drupal\Core\Field\Entity\BaseFieldOverride
29 protected function setUpAuthorization($method) {
30 $this->grantPermissionsToTestedRole(['administer node fields']);
36 protected function createEntity() {
37 $camelids = NodeType::create([
43 $entity = BaseFieldOverride::create([
44 'field_name' => 'promote',
45 'entity_type' => 'node',
46 'bundle' => 'camelids',
56 protected function getExpectedNormalizedEntity() {
58 'bundle' => 'camelids',
59 'default_value' => [],
60 'default_value_callback' => '',
67 'entity_type' => 'node',
68 'field_name' => 'promote',
69 'field_type' => 'boolean',
70 'id' => 'node.camelids.promote',
79 'translatable' => TRUE,
80 'uuid' => $this->entity->uuid(),
87 protected function getNormalizedPostEntity() {
88 // @todo Update in https://www.drupal.org/node/2300677.
94 protected function getExpectedCacheContexts() {
103 protected function getExpectedUnauthorizedAccessMessage($method) {
104 if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
105 return parent::getExpectedUnauthorizedAccessMessage($method);
108 return "The 'administer node fields' permission is required.";