NodeTypeTest.php
Same filename in this branch
Same filename in other branches
- 9 core/modules/jsonapi/tests/src/Functional/NodeTypeTest.php
- 9 core/modules/node/tests/src/Kernel/Plugin/migrate/source/d6/NodeTypeTest.php
- 9 core/modules/node/tests/src/Kernel/Plugin/migrate/source/d7/NodeTypeTest.php
- 9 core/modules/node/tests/src/Functional/NodeTypeTest.php
- 8.9.x core/modules/jsonapi/tests/src/Functional/NodeTypeTest.php
- 8.9.x core/modules/node/tests/src/Kernel/Plugin/migrate/source/d6/NodeTypeTest.php
- 8.9.x core/modules/node/tests/src/Kernel/Plugin/migrate/source/d7/NodeTypeTest.php
- 8.9.x core/modules/node/tests/src/Functional/NodeTypeTest.php
- 10 core/modules/jsonapi/tests/src/Functional/NodeTypeTest.php
- 10 core/modules/node/tests/src/Kernel/Plugin/migrate/source/d6/NodeTypeTest.php
- 10 core/modules/node/tests/src/Kernel/Plugin/migrate/source/d7/NodeTypeTest.php
- 10 core/modules/node/tests/src/Functional/NodeTypeTest.php
Namespace
Drupal\Tests\jsonapi\FunctionalFile
-
core/
modules/ jsonapi/ tests/ src/ Functional/ NodeTypeTest.php
View source
<?php
declare (strict_types=1);
namespace Drupal\Tests\jsonapi\Functional;
use Drupal\Core\Url;
use Drupal\node\Entity\NodeType;
/**
* JSON:API integration test for the "NodeType" config entity type.
*
* @group jsonapi
*/
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() : array {
$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() : array {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessMessage($method) : string {
return "The 'access content' permission is required.";
}
}
Classes
Title | Deprecated | Summary |
---|---|---|
NodeTypeTest | JSON:API integration test for the "NodeType" config entity type. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.