class RoleTest in Drupal 10
Same name in this branch
- 10 core/modules/jsonapi/tests/src/Functional/RoleTest.php \Drupal\Tests\jsonapi\Functional\RoleTest
- 10 core/modules/user/tests/src/Kernel/Plugin/migrate/source/d6/RoleTest.php \Drupal\Tests\user\Kernel\Plugin\migrate\source\d6\RoleTest
- 10 core/modules/user/tests/src/Kernel/Plugin/migrate/source/d7/RoleTest.php \Drupal\Tests\user\Kernel\Plugin\migrate\source\d7\RoleTest
Same name and namespace in other branches
- 8 core/modules/jsonapi/tests/src/Functional/RoleTest.php \Drupal\Tests\jsonapi\Functional\RoleTest
- 9 core/modules/jsonapi/tests/src/Functional/RoleTest.php \Drupal\Tests\jsonapi\Functional\RoleTest
JSON:API integration test for the "Role" config entity type.
@group jsonapi
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\jsonapi\Functional\ResourceTestBase uses ContentModerationTestTrait, JsonApiRequestTestTrait, ResourceResponseTestTrait
- class \Drupal\Tests\jsonapi\Functional\ConfigEntityResourceTestBase
- class \Drupal\Tests\jsonapi\Functional\RoleTest
- class \Drupal\Tests\jsonapi\Functional\ConfigEntityResourceTestBase
- class \Drupal\Tests\jsonapi\Functional\ResourceTestBase uses ContentModerationTestTrait, JsonApiRequestTestTrait, ResourceResponseTestTrait
Expanded class hierarchy of RoleTest
File
- core/
modules/ jsonapi/ tests/ src/ Functional/ RoleTest.php, line 13
Namespace
Drupal\Tests\jsonapi\FunctionalView source
class RoleTest extends ConfigEntityResourceTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'user',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected static $entityTypeId = 'user_role';
/**
* {@inheritdoc}
*/
protected static $resourceTypeName = 'user_role--user_role';
/**
* {@inheritdoc}
*
* @var \Drupal\user\RoleInterface
*/
protected $entity;
/**
* {@inheritdoc}
*/
protected function setUpAuthorization($method) {
$this
->grantPermissionsToTestedRole([
'administer permissions',
]);
}
/**
* {@inheritdoc}
*/
protected function createEntity() {
$role = Role::create([
'id' => 'llama',
'label' => 'Llama',
]);
$role
->save();
return $role;
}
/**
* {@inheritdoc}
*/
protected function getExpectedDocument() {
$self_url = Url::fromUri('base:/jsonapi/user_role/user_role/' . $this->entity
->uuid())
->setAbsolute()
->toString(TRUE)
->getGeneratedUrl();
return [
'jsonapi' => [
'meta' => [
'links' => [
'self' => [
'href' => 'http://jsonapi.org/format/1.0/',
],
],
],
'version' => '1.0',
],
'links' => [
'self' => [
'href' => $self_url,
],
],
'data' => [
'id' => $this->entity
->uuid(),
'type' => 'user_role--user_role',
'links' => [
'self' => [
'href' => $self_url,
],
],
'attributes' => [
'weight' => 2,
'langcode' => 'en',
'status' => TRUE,
'dependencies' => [],
'label' => 'Llama',
'is_admin' => NULL,
'permissions' => [],
'drupal_internal__id' => 'llama',
],
],
];
}
/**
* {@inheritdoc}
*/
protected function getPostDocument() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
}