X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2Fcore%2Fmodules%2Fcontact%2Ftests%2Fsrc%2FFunctional%2FRest%2FContactFormResourceTestBase.php;fp=web%2Fcore%2Fmodules%2Fcontact%2Ftests%2Fsrc%2FFunctional%2FRest%2FContactFormResourceTestBase.php;h=98edc5ae91f1373339b717e587e33f4456fc04de;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hp=0000000000000000000000000000000000000000;hpb=74df008bdbb3a11eeea356744f39b802369bda3c;p=yaffs-website diff --git a/web/core/modules/contact/tests/src/Functional/Rest/ContactFormResourceTestBase.php b/web/core/modules/contact/tests/src/Functional/Rest/ContactFormResourceTestBase.php new file mode 100644 index 000000000..98edc5ae9 --- /dev/null +++ b/web/core/modules/contact/tests/src/Functional/Rest/ContactFormResourceTestBase.php @@ -0,0 +1,104 @@ +grantPermissionsToTestedRole(['access site-wide contact form']); + default: + $this->grantPermissionsToTestedRole(['administer contact forms']); + } + } + + /** + * {@inheritdoc} + */ + protected function createEntity() { + $contact_form = ContactForm::create([ + 'id' => 'llama', + 'label' => 'Llama', + 'message' => 'Let us know what you think about llamas', + 'reply' => 'Llamas are indeed awesome!', + 'recipients' => [ + 'llama@example.com', + 'contact@example.com', + ], + ]); + $contact_form->save(); + + return $contact_form; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedNormalizedEntity() { + return [ + 'dependencies' => [], + 'id' => 'llama', + 'label' => 'Llama', + 'langcode' => 'en', + 'message' => 'Let us know what you think about llamas', + 'recipients' => [ + 'llama@example.com', + 'contact@example.com', + ], + 'redirect' => NULL, + 'reply' => 'Llamas are indeed awesome!', + 'status' => TRUE, + 'uuid' => $this->entity->uuid(), + 'weight' => 0, + ]; + } + + /** + * {@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 site-wide contact form' permission is required."; + } + +}