diff --git a/core/modules/hal/tests/src/Functional/EntityResource/NodeType/NodeTypeHalJsonAnonTest.php b/core/modules/hal/tests/src/Functional/EntityResource/NodeType/NodeTypeHalJsonAnonTest.php new file mode 100644 index 00000000000..5a46564de44 --- /dev/null +++ b/core/modules/hal/tests/src/Functional/EntityResource/NodeType/NodeTypeHalJsonAnonTest.php @@ -0,0 +1,30 @@ +grantPermissionsToTestedRole(['administer content types', 'access content']); + } + + /** + * {@inheritdoc} + */ + protected function createEntity() { + // Create a "Camelids" node type. + $camelids = NodeType::create([ + 'name' => 'Camelids', + 'type' => 'camelids', + 'description' => 'Camelids are large, strictly herbivorous animals with slender necks and long legs.', + ]); + + $camelids->save(); + + return $camelids; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedNormalizedEntity() { + return [ + 'dependencies' => [], + 'description' => 'Camelids are large, strictly herbivorous animals with slender necks and long legs.', + 'display_submitted' => TRUE, + 'help' => NULL, + 'langcode' => 'en', + 'name' => 'Camelids', + 'new_revision' => TRUE, + 'preview_mode' => 1, + 'status' => TRUE, + 'type' => 'camelids', + 'uuid' => $this->entity->uuid(), + ]; + } + + /** + * {@inheritdoc} + */ + protected function getNormalizedPostEntity() { + // @todo Update in https://www.drupal.org/node/2300677. + } + + /** + * {@inheritdoc} + */ + protected function getExpectedUnauthorizedAccessMessage($method) { + if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) { + return parent::getExpectedUnauthorizedAccessMessage($method); + } + + return "The 'access content' permission is required."; + } + +}