abstract class ShortcutSetResourceTestBase in Drupal 10
Same name and namespace in other branches
- 8 core/modules/shortcut/tests/src/Functional/Rest/ShortcutSetResourceTestBase.php \Drupal\Tests\shortcut\Functional\Rest\ShortcutSetResourceTestBase
- 9 core/modules/shortcut/tests/src/Functional/Rest/ShortcutSetResourceTestBase.php \Drupal\Tests\shortcut\Functional\Rest\ShortcutSetResourceTestBase
ResourceTestBase for ShortcutSet entity.
Hierarchy
- class \Drupal\Tests\BrowserTestBase extends \PHPUnit\Framework\TestCase uses \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, FunctionalTestSetupTrait, TestSetupTrait, BlockCreationTrait, ConfigTestTrait, ExtensionListTestTrait, ContentTypeCreationTrait, NodeCreationTrait, RandomGeneratorTrait, TestRequirementsTrait, PhpUnitWarnings, UiHelperTrait, UserCreationTrait, XdebugRequestTrait
- class \Drupal\Tests\rest\Functional\ResourceTestBase
- class \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase
- class \Drupal\Tests\rest\Functional\EntityResource\ConfigEntityResourceTestBase
- class \Drupal\Tests\shortcut\Functional\Rest\ShortcutSetResourceTestBase
- class \Drupal\Tests\rest\Functional\EntityResource\ConfigEntityResourceTestBase
- class \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase
- class \Drupal\Tests\rest\Functional\ResourceTestBase
Expanded class hierarchy of ShortcutSetResourceTestBase
File
- core/
modules/ shortcut/ tests/ src/ Functional/ Rest/ ShortcutSetResourceTestBase.php, line 11
Namespace
Drupal\Tests\shortcut\Functional\RestView source
abstract class ShortcutSetResourceTestBase extends ConfigEntityResourceTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'shortcut',
];
/**
* {@inheritdoc}
*/
protected static $entityTypeId = 'shortcut_set';
/**
* {@inheritdoc}
*/
protected static $patchProtectedFieldNames = [];
/**
* The ShortcutSet entity.
*
* @var \Drupal\shortcut\ShortcutSetInterface
*/
protected $entity;
/**
* {@inheritdoc}
*/
protected function setUpAuthorization($method) {
switch ($method) {
case 'GET':
$this
->grantPermissionsToTestedRole([
'access shortcuts',
]);
break;
case 'POST':
case 'PATCH':
$this
->grantPermissionsToTestedRole([
'access shortcuts',
'customize shortcut links',
]);
break;
case 'DELETE':
$this
->grantPermissionsToTestedRole([
'administer shortcuts',
]);
break;
}
}
/**
* {@inheritdoc}
*/
protected function createEntity() {
$set = ShortcutSet::create([
'id' => 'llama_set',
'label' => 'Llama Set',
]);
$set
->save();
return $set;
}
/**
* {@inheritdoc}
*/
protected function getExpectedNormalizedEntity() {
return [
'id' => 'llama_set',
'uuid' => $this->entity
->uuid(),
'label' => 'Llama Set',
'status' => TRUE,
'langcode' => 'en',
'dependencies' => [],
];
}
/**
* {@inheritdoc}
*/
protected function getNormalizedPostEntity() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessMessage($method) {
switch ($method) {
case 'GET':
return "The 'access shortcuts' permission is required.";
default:
return parent::getExpectedUnauthorizedAccessMessage($method);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ShortcutSetResourceTestBase:: |
protected | property | The ShortcutSet entity. | |
ShortcutSetResourceTestBase:: |
protected static | property | ||
ShortcutSetResourceTestBase:: |
protected static | property | 2 | |
ShortcutSetResourceTestBase:: |
protected static | property | ||
ShortcutSetResourceTestBase:: |
protected | function | ||
ShortcutSetResourceTestBase:: |
protected | function | ||
ShortcutSetResourceTestBase:: |
protected | function | ||
ShortcutSetResourceTestBase:: |
protected | function | ||
ShortcutSetResourceTestBase:: |
protected | function |