View source
<?php
namespace Drupal\Tests\tour\Functional\Rest;
use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
use Drupal\tour\Entity\Tour;
abstract class TourResourceTestBase extends EntityResourceTestBase {
protected static $modules = [
'tour',
];
protected static $entityTypeId = 'tour';
protected $entity;
protected function setUpAuthorization($method) {
$this
->grantPermissionsToTestedRole([
'access tour',
]);
}
protected function createEntity() {
$tour = Tour::create([
'id' => 'tour-llama',
'label' => 'Llama tour',
'langcode' => 'en',
'module' => 'tour',
'routes' => [
[
'route_name' => '<front>',
],
],
'tips' => [
'tour-llama-1' => [
'id' => 'tour-llama-1',
'plugin' => 'text',
'label' => 'Llama',
'body' => 'Who handle the awesomeness of llamas?',
'weight' => 100,
'selector' => '#tour-llama-1',
],
],
]);
$tour
->save();
return $tour;
}
protected function getExpectedNormalizedEntity() {
return [
'dependencies' => [],
'id' => 'tour-llama',
'label' => 'Llama tour',
'langcode' => 'en',
'module' => 'tour',
'routes' => [
[
'route_name' => '<front>',
],
],
'status' => TRUE,
'tips' => [
'tour-llama-1' => [
'id' => 'tour-llama-1',
'plugin' => 'text',
'label' => 'Llama',
'body' => 'Who handle the awesomeness of llamas?',
'weight' => 100,
'selector' => '#tour-llama-1',
],
],
'uuid' => $this->entity
->uuid(),
];
}
protected function getNormalizedPostEntity() {
}
protected function getExpectedCacheContexts() {
return [
'user.permissions',
];
}
protected function getExpectedUnauthorizedAccessMessage($method) {
return "The following permissions are required: 'access tour' OR 'administer site configuration'.";
}
}