VocabularyResourceTestBase.php in Drupal 10
File
core/modules/taxonomy/tests/src/Functional/Rest/VocabularyResourceTestBase.php
View source
<?php
namespace Drupal\Tests\taxonomy\Functional\Rest;
use Drupal\taxonomy\Entity\Vocabulary;
use Drupal\Tests\rest\Functional\EntityResource\ConfigEntityResourceTestBase;
abstract class VocabularyResourceTestBase extends ConfigEntityResourceTestBase {
protected static $modules = [
'taxonomy',
];
protected static $entityTypeId = 'taxonomy_vocabulary';
protected $entity;
protected function setUpAuthorization($method) {
$this
->grantPermissionsToTestedRole([
'administer taxonomy',
]);
}
protected function createEntity() {
$vocabulary = Vocabulary::create([
'name' => 'Llama',
'vid' => 'llama',
]);
$vocabulary
->save();
return $vocabulary;
}
protected function getExpectedNormalizedEntity() {
return [
'uuid' => $this->entity
->uuid(),
'vid' => 'llama',
'langcode' => 'en',
'status' => TRUE,
'dependencies' => [],
'name' => 'Llama',
'description' => NULL,
'weight' => 0,
];
}
protected function getNormalizedPostEntity() {
return [];
}
protected function getExpectedUnauthorizedAccessMessage($method) {
if ($method === 'GET') {
return "The following permissions are required: 'access taxonomy overview' OR 'administer taxonomy'.";
}
return parent::getExpectedUnauthorizedAccessMessage($method);
}
}