ConfigTestResourceTestBase.php in Drupal 10
File
core/modules/config/tests/config_test/tests/src/Functional/Rest/ConfigTestResourceTestBase.php
View source
<?php
namespace Drupal\Tests\config_test\Functional\Rest;
use Drupal\config_test\Entity\ConfigTest;
use Drupal\Tests\rest\Functional\EntityResource\ConfigEntityResourceTestBase;
abstract class ConfigTestResourceTestBase extends ConfigEntityResourceTestBase {
protected static $modules = [
'config_test',
'config_test_rest',
];
protected static $entityTypeId = 'config_test';
protected $entity;
protected function setUpAuthorization($method) {
$this
->grantPermissionsToTestedRole([
'view config_test',
]);
}
protected function createEntity() {
$config_test = ConfigTest::create([
'id' => 'llama',
'label' => 'Llama',
]);
$config_test
->save();
return $config_test;
}
protected function getExpectedNormalizedEntity() {
$normalization = [
'uuid' => $this->entity
->uuid(),
'id' => 'llama',
'weight' => 0,
'langcode' => 'en',
'status' => TRUE,
'dependencies' => [],
'label' => 'Llama',
'style' => NULL,
'size' => NULL,
'size_value' => NULL,
'protected_property' => NULL,
];
return $normalization;
}
protected function getNormalizedPostEntity() {
return [];
}
protected function getExpectedUnauthorizedAccessMessage($method) {
switch ($method) {
case 'GET':
return "The 'view config_test' permission is required.";
default:
return parent::getExpectedUnauthorizedAccessMessage($method);
}
}
}