X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fnode%2Ftests%2Fsrc%2FFunctional%2FRest%2FNodeTypeResourceTestBase.php;fp=web%2Fcore%2Fmodules%2Fnode%2Ftests%2Fsrc%2FFunctional%2FRest%2FNodeTypeResourceTestBase.php;h=d74824dd13a2ea0c124cc62739747adf69e8120a;hp=0000000000000000000000000000000000000000;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/modules/node/tests/src/Functional/Rest/NodeTypeResourceTestBase.php b/web/core/modules/node/tests/src/Functional/Rest/NodeTypeResourceTestBase.php new file mode 100644 index 000000000..d74824dd1 --- /dev/null +++ b/web/core/modules/node/tests/src/Functional/Rest/NodeTypeResourceTestBase.php @@ -0,0 +1,90 @@ +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."; + } + +}