View source
<?php
namespace Drupal\Tests\field\Functional\Rest;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\Tests\rest\Functional\EntityResource\ConfigEntityResourceTestBase;
abstract class FieldStorageConfigResourceTestBase extends ConfigEntityResourceTestBase {
protected static $modules = [
'field_ui',
'node',
];
protected static $entityTypeId = 'field_storage_config';
protected $entity;
protected function setUpAuthorization($method) {
$this
->grantPermissionsToTestedRole([
'administer node fields',
]);
}
protected function createEntity() {
$field_storage = FieldStorageConfig::create([
'field_name' => 'true_llama',
'entity_type' => 'node',
'type' => 'boolean',
]);
$field_storage
->save();
return $field_storage;
}
protected function getExpectedNormalizedEntity() {
return [
'cardinality' => 1,
'custom_storage' => FALSE,
'dependencies' => [
'module' => [
'node',
],
],
'entity_type' => 'node',
'field_name' => 'true_llama',
'id' => 'node.true_llama',
'indexes' => [],
'langcode' => 'en',
'locked' => FALSE,
'module' => 'core',
'persist_with_no_fields' => FALSE,
'settings' => [],
'status' => TRUE,
'translatable' => TRUE,
'type' => 'boolean',
'uuid' => $this->entity
->uuid(),
];
}
protected function getNormalizedPostEntity() {
return [];
}
protected function getExpectedUnauthorizedAccessMessage($method) {
switch ($method) {
case 'GET':
return "The 'administer node fields' permission is required.";
default:
return parent::getExpectedUnauthorizedAccessMessage($method);
}
}
}