NodeTypeResourceTestBase.php in Drupal 8
File
core/modules/node/tests/src/Functional/Rest/NodeTypeResourceTestBase.php
View source
<?php
namespace Drupal\Tests\node\Functional\Rest;
use Drupal\node\Entity\NodeType;
use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
abstract class NodeTypeResourceTestBase extends EntityResourceTestBase {
public static $modules = [
'node',
];
protected static $entityTypeId = 'node_type';
protected $entity;
protected function setUpAuthorization($method) {
$this
->grantPermissionsToTestedRole([
'administer content types',
'access content',
]);
}
protected function createEntity() {
$camelids = NodeType::create([
'name' => 'Camelids',
'type' => 'camelids',
'description' => 'Camelids are large, strictly herbivorous animals with slender necks and long legs.',
]);
$camelids
->save();
return $camelids;
}
protected function getExpectedNormalizedEntity() {
return [
'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,
'type' => 'camelids',
'uuid' => $this->entity
->uuid(),
];
}
protected function getNormalizedPostEntity() {
}
protected function getExpectedUnauthorizedAccessMessage($method) {
if ($this
->config('rest.settings')
->get('bc_entity_resource_permissions')) {
return parent::getExpectedUnauthorizedAccessMessage($method);
}
return "The 'access content' permission is required.";
}
}