class BaseFieldOverrideTest in Drupal 10
Same name in this branch
- 10 core/modules/jsonapi/tests/src/Functional/BaseFieldOverrideTest.php \Drupal\Tests\jsonapi\Functional\BaseFieldOverrideTest
- 10 core/tests/Drupal/KernelTests/Core/Field/Entity/BaseFieldOverrideTest.php \Drupal\KernelTests\Core\Field\Entity\BaseFieldOverrideTest
Same name and namespace in other branches
- 8 core/modules/jsonapi/tests/src/Functional/BaseFieldOverrideTest.php \Drupal\Tests\jsonapi\Functional\BaseFieldOverrideTest
- 9 core/modules/jsonapi/tests/src/Functional/BaseFieldOverrideTest.php \Drupal\Tests\jsonapi\Functional\BaseFieldOverrideTest
JSON:API integration test for the "BaseFieldOverride" 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\BaseFieldOverrideTest
- class \Drupal\Tests\jsonapi\Functional\ConfigEntityResourceTestBase
- class \Drupal\Tests\jsonapi\Functional\ResourceTestBase uses ContentModerationTestTrait, JsonApiRequestTestTrait, ResourceResponseTestTrait
Expanded class hierarchy of BaseFieldOverrideTest
File
- core/
modules/ jsonapi/ tests/ src/ Functional/ BaseFieldOverrideTest.php, line 14
Namespace
Drupal\Tests\jsonapi\FunctionalView source
class BaseFieldOverrideTest extends ConfigEntityResourceTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'field',
'node',
'field_ui',
];
/**
* {@inheritdoc}
*/
protected static $entityTypeId = 'base_field_override';
/**
* {@inheritdoc}
*/
protected static $resourceTypeName = 'base_field_override--base_field_override';
/**
* {@inheritdoc}
*
* @var \Drupal\Core\Field\Entity\BaseFieldOverride
*/
protected $entity;
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setUpAuthorization($method) {
$this
->grantPermissionsToTestedRole([
'administer node fields',
]);
}
/**
* {@inheritdoc}
*/
protected function createEntity() {
$camelids = NodeType::create([
'name' => 'Camelids',
'type' => 'camelids',
]);
$camelids
->save();
$entity = BaseFieldOverride::create([
'field_name' => 'promote',
'entity_type' => 'node',
'bundle' => 'camelids',
]);
$entity
->save();
return $entity;
}
/**
* {@inheritdoc}
*/
protected function getExpectedDocument() {
$self_url = Url::fromUri('base:/jsonapi/base_field_override/base_field_override/' . $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' => 'base_field_override--base_field_override',
'links' => [
'self' => [
'href' => $self_url,
],
],
'attributes' => [
'bundle' => 'camelids',
'default_value' => [],
'default_value_callback' => '',
'dependencies' => [
'config' => [
'node.type.camelids',
],
],
'description' => '',
'entity_type' => 'node',
'field_name' => 'promote',
'field_type' => 'boolean',
'label' => NULL,
'langcode' => 'en',
'required' => FALSE,
'settings' => [
'on_label' => 'On',
'off_label' => 'Off',
],
'status' => TRUE,
'translatable' => TRUE,
'drupal_internal__id' => 'node.camelids.promote',
],
],
];
}
/**
* {@inheritdoc}
*/
protected function getPostDocument() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessMessage($method) {
return "The 'administer node fields' permission is required.";
}
/**
* {@inheritdoc}
*/
protected function createAnotherEntity($key) {
$entity = BaseFieldOverride::create([
'field_name' => 'status',
'entity_type' => 'node',
'bundle' => 'camelids',
]);
$entity
->save();
return $entity;
}
}