class NodeTypeTest in Drupal 10
Same name in this branch
- 10 core/modules/node/tests/src/Functional/NodeTypeTest.php \Drupal\Tests\node\Functional\NodeTypeTest
- 10 core/modules/jsonapi/tests/src/Functional/NodeTypeTest.php \Drupal\Tests\jsonapi\Functional\NodeTypeTest
Same name and namespace in other branches
- 8 core/modules/jsonapi/tests/src/Functional/NodeTypeTest.php \Drupal\Tests\jsonapi\Functional\NodeTypeTest
- 9 core/modules/jsonapi/tests/src/Functional/NodeTypeTest.php \Drupal\Tests\jsonapi\Functional\NodeTypeTest
JSON:API integration test for the "NodeType" 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\NodeTypeTest
- class \Drupal\Tests\jsonapi\Functional\ConfigEntityResourceTestBase
- class \Drupal\Tests\jsonapi\Functional\ResourceTestBase uses ContentModerationTestTrait, JsonApiRequestTestTrait, ResourceResponseTestTrait
Expanded class hierarchy of NodeTypeTest
File
- core/
modules/ jsonapi/ tests/ src/ Functional/ NodeTypeTest.php, line 13
Namespace
Drupal\Tests\jsonapi\FunctionalView source
class NodeTypeTest extends ConfigEntityResourceTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'node',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected static $entityTypeId = 'node_type';
/**
* {@inheritdoc}
*/
protected static $resourceTypeName = 'node_type--node_type';
/**
* {@inheritdoc}
*
* @var \Drupal\node\NodeTypeInterface
*/
protected $entity;
/**
* {@inheritdoc}
*/
protected function setUpAuthorization($method) {
$this
->grantPermissionsToTestedRole([
'administer content types',
'access content',
]);
}
/**
* {@inheritdoc}
*/
protected function createEntity() {
// Create a "Camelids" node type.
$camelids = NodeType::create([
'name' => 'Camelids',
'type' => 'camelids',
'description' => 'Camelids are large, strictly herbivorous animals with slender necks and long legs.',
]);
$camelids
->save();
return $camelids;
}
/**
* {@inheritdoc}
*/
protected function getExpectedDocument() {
$self_url = Url::fromUri('base:/jsonapi/node_type/node_type/' . $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' => 'node_type--node_type',
'links' => [
'self' => [
'href' => $self_url,
],
],
'attributes' => [
'dependencies' => [],
'description' => 'Camelids are large, strictly herbivorous animals with slender necks and long legs.',
'display_submitted' => TRUE,
'help' => NULL,
'langcode' => 'en',
'name' => 'Camelids',
'new_revision' => TRUE,
'preview_mode' => 1,
'status' => TRUE,
'drupal_internal__type' => 'camelids',
],
],
];
}
/**
* {@inheritdoc}
*/
protected function getPostDocument() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessMessage($method) {
return "The 'access content' permission is required.";
}
}