123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- <?php
- namespace Drupal\FunctionalTests\Rest;
- use Drupal\Core\Field\Entity\BaseFieldOverride;
- use Drupal\node\Entity\NodeType;
- use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
- abstract class BaseFieldOverrideResourceTestBase extends EntityResourceTestBase {
- /**
- * {@inheritdoc}
- */
- public static $modules = ['field', 'node'];
- /**
- * {@inheritdoc}
- */
- protected static $entityTypeId = 'base_field_override';
- /**
- * @var \Drupal\Core\Field\Entity\BaseFieldOverride
- */
- protected $entity;
- /**
- * {@inheritdoc}
- */
- protected function setUpAuthorization($method) {
- $this->grantPermissionsToTestedRole(['administer node fields']);
- }
- /**
- * {@inheritdoc}
- */
- protected function createEntity() {
- $camelids = NodeType::create([
- 'name' => 'Camelids',
- 'type' => 'camelids',
- ]);
- $camelids->save();
- $entity = BaseFieldOverride::create([
- 'field_name' => 'promote',
- 'entity_type' => 'node',
- 'bundle' => 'camelids',
- ]);
- $entity->save();
- return $entity;
- }
- /**
- * {@inheritdoc}
- */
- protected function getExpectedNormalizedEntity() {
- return [
- 'bundle' => 'camelids',
- 'default_value' => [],
- 'default_value_callback' => '',
- 'dependencies' => [
- 'config' => [
- 'node.type.camelids',
- ],
- ],
- 'description' => '',
- 'entity_type' => 'node',
- 'field_name' => 'promote',
- 'field_type' => 'boolean',
- 'id' => 'node.camelids.promote',
- 'label' => NULL,
- 'langcode' => 'en',
- 'required' => FALSE,
- 'settings' => [
- 'on_label' => 'On',
- 'off_label' => 'Off',
- ],
- '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.";
- }
- }
|