3 namespace Drupal\Tests\rest\Functional\EntityResource\EntityViewDisplay;
5 use Drupal\Core\Entity\Entity\EntityViewDisplay;
6 use Drupal\node\Entity\NodeType;
7 use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
9 abstract class EntityViewDisplayResourceTestBase extends EntityResourceTestBase {
14 public static $modules = ['node'];
19 protected static $entityTypeId = 'entity_view_display';
24 protected static $patchProtectedFieldNames = [];
27 * @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface
34 protected function setUpAuthorization($method) {
35 $this->grantPermissionsToTestedRole(['administer node display']);
41 protected function createEntity() {
42 // Create a "Camelids" node type.
43 $camelids = NodeType::create([
49 // Create a view display.
50 $view_display = EntityViewDisplay::create([
51 'targetEntityType' => 'node',
52 'bundle' => 'camelids',
56 $view_display->save();
64 protected function getExpectedNormalizedEntity() {
66 'bundle' => 'camelids',
69 'region' => 'content',
82 'id' => 'node.camelids.default',
86 'targetEntityType' => 'node',
87 'uuid' => $this->entity->uuid(),
94 protected function getNormalizedPostEntity() {
95 // @todo Update in https://www.drupal.org/node/2300677.
101 protected function getExpectedCacheContexts() {
110 protected function getExpectedUnauthorizedAccessMessage($method) {
111 if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
112 return parent::getExpectedUnauthorizedAccessMessage($method);
115 return "The 'administer node display' permission is required.";