function ResourceTestBase::setUp
Same name in this branch
- 10 core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::setUp()
Same name in other branches
- 9 core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::setUp()
- 9 core/modules/rest/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\rest\Functional\ResourceTestBase::setUp()
- 8.9.x core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::setUp()
- 8.9.x core/modules/rest/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\rest\Functional\ResourceTestBase::setUp()
- 11.x core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::setUp()
- 11.x core/modules/rest/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\rest\Functional\ResourceTestBase::setUp()
Overrides BrowserTestBase::setUp
1 call to ResourceTestBase::setUp()
- UserRegistrationRestTest::setUp in core/
modules/ user/ tests/ src/ Functional/ UserRegistrationRestTest.php
6 methods override ResourceTestBase::setUp()
- DbLogResourceTest::setUp in core/
modules/ dblog/ tests/ src/ Functional/ DbLogResourceTest.php - EntityResourceTestBase::setUp in core/
modules/ rest/ tests/ src/ Functional/ EntityResource/ EntityResourceTestBase.php - FileUploadResourceTestBase::setUp in core/
modules/ rest/ tests/ src/ Functional/ FileUploadResourceTestBase.php - LayoutRestTestBase::setUp in core/
modules/ layout_builder/ tests/ src/ Functional/ Rest/ LayoutRestTestBase.php - RestJsonApiUnsupported::setUp in core/
modules/ jsonapi/ tests/ src/ Functional/ RestJsonApiUnsupported.php
File
-
core/
modules/ rest/ tests/ src/ Functional/ ResourceTestBase.php, line 101
Class
- ResourceTestBase
- Subclass this for every REST resource, every format and every auth provider.
Namespace
Drupal\Tests\rest\FunctionalCode
protected function setUp() : void {
parent::setUp();
$this->serializer = $this->container
->get('serializer');
// Ensure the anonymous user role has no permissions at all.
$user_role = Role::load(RoleInterface::ANONYMOUS_ID);
foreach ($user_role->getPermissions() as $permission) {
$user_role->revokePermission($permission);
}
$user_role->save();
assert([] === $user_role->getPermissions(), 'The anonymous user role has no permissions at all.');
if (static::$auth !== FALSE) {
// Ensure the authenticated user role has no permissions at all.
$user_role = Role::load(RoleInterface::AUTHENTICATED_ID);
foreach ($user_role->getPermissions() as $permission) {
$user_role->revokePermission($permission);
}
$user_role->save();
assert([] === $user_role->getPermissions(), 'The authenticated user role has no permissions at all.');
// Create an account.
$this->account = $this->createUser();
}
else {
// Otherwise, also create an account, so that any test involving User
// entities will have the same user IDs regardless of authentication.
$this->createUser();
}
$this->resourceConfigStorage = $this->container
->get('entity_type.manager')
->getStorage('rest_resource_config');
// Ensure there's a clean slate: delete all REST resource config entities.
$this->resourceConfigStorage
->delete($this->resourceConfigStorage
->loadMultiple());
$this->refreshTestStateAfterRestConfigChange();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.