class EntityTestLabelResourceTestBase
Same name and namespace in other branches
- 11.x core/modules/system/tests/modules/entity_test/tests/src/Functional/Rest/EntityTestLabelResourceTestBase.php \Drupal\Tests\entity_test\Functional\Rest\EntityTestLabelResourceTestBase
- 10 core/modules/system/tests/modules/entity_test/tests/src/Functional/Rest/EntityTestLabelResourceTestBase.php \Drupal\Tests\entity_test\Functional\Rest\EntityTestLabelResourceTestBase
- 8.9.x core/modules/rest/tests/src/Functional/EntityResource/EntityTestLabel/EntityTestLabelResourceTestBase.php \Drupal\Tests\rest\Functional\EntityResource\EntityTestLabel\EntityTestLabelResourceTestBase
- 8.9.x core/modules/system/tests/modules/entity_test/tests/src/Functional/Rest/EntityTestLabelResourceTestBase.php \Drupal\Tests\entity_test\Functional\Rest\EntityTestLabelResourceTestBase
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\rest\Functional\ResourceTestBase extends \Drupal\Tests\BrowserTestBase
- class \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase extends \Drupal\Tests\rest\Functional\ResourceTestBase
- class \Drupal\Tests\rest\Functional\EntityResource\ConfigEntityResourceTestBase extends \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase
- class \Drupal\Tests\entity_test\Functional\Rest\EntityTestLabelResourceTestBase extends \Drupal\Tests\rest\Functional\EntityResource\ConfigEntityResourceTestBase
- class \Drupal\Tests\rest\Functional\EntityResource\ConfigEntityResourceTestBase extends \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase
- class \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase extends \Drupal\Tests\rest\Functional\ResourceTestBase
- class \Drupal\Tests\rest\Functional\ResourceTestBase extends \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of EntityTestLabelResourceTestBase
1 file declares its use of EntityTestLabelResourceTestBase
- EntityTestLabelHalJsonAnonTest.php in core/
modules/ hal/ tests/ src/ Functional/ entity_test/ EntityTestLabelHalJsonAnonTest.php
File
-
core/
modules/ system/ tests/ modules/ entity_test/ tests/ src/ Functional/ Rest/ EntityTestLabelResourceTestBase.php, line 9
Namespace
Drupal\Tests\entity_test\Functional\RestView source
abstract class EntityTestLabelResourceTestBase extends ConfigEntityResourceTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'entity_test',
];
/**
* {@inheritdoc}
*/
protected static $entityTypeId = 'entity_test_label';
/**
* {@inheritdoc}
*/
protected static $patchProtectedFieldNames = [];
/**
* @var \Drupal\entity_test\Entity\EntityTestLabel
*/
protected $entity;
/**
* {@inheritdoc}
*/
protected function setUpAuthorization($method) {
switch ($method) {
case 'GET':
$this->grantPermissionsToTestedRole([
'view test entity',
]);
break;
case 'POST':
$this->grantPermissionsToTestedRole([
'administer entity_test content',
'administer entity_test_with_bundle content',
'create entity_test entity_test_with_bundle entities',
]);
break;
case 'PATCH':
case 'DELETE':
$this->grantPermissionsToTestedRole([
'administer entity_test content',
]);
break;
}
}
/**
* {@inheritdoc}
*/
protected function createEntity() {
$entity_test_label = EntityTestLabel::create([
'name' => 'label_llama',
]);
$entity_test_label->setOwnerId(0);
$entity_test_label->save();
return $entity_test_label;
}
/**
* {@inheritdoc}
*/
protected function getExpectedNormalizedEntity() {
$author = User::load(0);
$normalization = [
'uuid' => [
[
'value' => $this->entity
->uuid(),
],
],
'id' => [
[
'value' => (int) $this->entity
->id(),
],
],
'langcode' => [
[
'value' => 'en',
],
],
'type' => [
[
'value' => 'entity_test_label',
],
],
'name' => [
[
'value' => 'label_llama',
],
],
'created' => [
[
'value' => (new \DateTime())->setTimestamp((int) $this->entity
->get('created')->value)
->setTimezone(new \DateTimeZone('UTC'))
->format(\DateTime::RFC3339),
'format' => \DateTime::RFC3339,
],
],
'user_id' => [
[
'target_id' => (int) $author->id(),
'target_type' => 'user',
'target_uuid' => $author->uuid(),
'url' => $author->toUrl()
->toString(),
],
],
];
return $normalization;
}
/**
* {@inheritdoc}
*/
protected function getNormalizedPostEntity() {
return [
'type' => [
[
'value' => 'entity_test_label',
],
],
'name' => [
[
'value' => 'label_llama',
],
],
];
}
/**
* {@inheritdoc}
*/
protected function getExpectedCacheContexts() {
return [
'user.permissions',
];
}
/**
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessMessage($method) {
switch ($method) {
case 'GET':
return "The 'view test entity' permission is required.";
case 'POST':
return "The following permissions are required: 'administer entity_test content' OR 'administer entity_test_with_bundle content' OR 'create entity_test_label entity_test_with_bundle entities'.";
case 'PATCH':
case 'DELETE':
return "The 'administer entity_test content' permission is required.";
default:
return parent::getExpectedUnauthorizedAccessMessage($method);
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.