3 namespace Drupal\Tests\rest\Functional\EntityResource\ContactForm;
5 use Drupal\contact\Entity\ContactForm;
6 use Drupal\Tests\rest\Functional\BcTimestampNormalizerUnixTestTrait;
7 use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
9 abstract class ContactFormResourceTestBase extends EntityResourceTestBase {
11 use BcTimestampNormalizerUnixTestTrait;
16 public static $modules = ['contact'];
21 protected static $entityTypeId = 'contact_form';
26 protected static $patchProtectedFieldNames = [];
29 * @var \Drupal\contact\Entity\ContactForm
36 protected function setUpAuthorization($method) {
39 $this->grantPermissionsToTestedRole(['access site-wide contact form']);
41 $this->grantPermissionsToTestedRole(['administer contact forms']);
48 protected function createEntity() {
49 $contact_form = ContactForm::create([
52 'message' => 'Let us know what you think about llamas',
53 'reply' => 'Llamas are indeed awesome!',
56 'contact@example.com',
59 $contact_form->save();
67 protected function getExpectedNormalizedEntity() {
73 'message' => 'Let us know what you think about llamas',
76 'contact@example.com',
79 'reply' => 'Llamas are indeed awesome!',
81 'uuid' => $this->entity->uuid(),
89 protected function getNormalizedPostEntity() {
90 // @todo Update in https://www.drupal.org/node/2300677.
96 protected function getExpectedUnauthorizedAccessMessage($method) {
97 if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
98 return parent::getExpectedUnauthorizedAccessMessage($method);
101 return "The 'access site-wide contact form' permission is required.";