3 namespace Drupal\Tests\rest\Functional\EntityResource\Shortcut;
5 use Drupal\shortcut\Entity\Shortcut;
6 use Drupal\shortcut\Entity\ShortcutSet;
7 use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
10 * ResourceTestBase for Shortcut entity.
12 abstract class ShortcutResourceTestBase extends EntityResourceTestBase {
17 public static $modules = ['comment', 'shortcut'];
22 protected static $entityTypeId = 'shortcut';
27 protected static $patchProtectedFieldNames = [];
30 * The Shortcut entity.
32 * @var \Drupal\shortcut\ShortcutInterface
39 protected function setUpAuthorization($method) {
45 $this->grantPermissionsToTestedRole(['access shortcuts', 'customize shortcut links']);
53 protected function createEntity() {
55 $shortcut = Shortcut::create([
56 'shortcut_set' => 'default',
57 'title' => t('Comments'),
60 'uri' => 'internal:/admin/content/comment',
71 protected function getExpectedNormalizedEntity() {
75 'value' => $this->entity->uuid(),
80 'value' => (int) $this->entity->id(),
85 'value' => 'Comments',
90 'target_id' => 'default',
91 'target_type' => 'shortcut_set',
92 'target_uuid' => ShortcutSet::load('default')->uuid(),
97 'uri' => 'internal:/admin/content/comment',
112 'default_langcode' => [
123 protected function getNormalizedPostEntity() {
127 'value' => 'Comments',
132 'uri' => 'internal:/',
137 'target_id' => 'default',
146 protected function getExpectedUnauthorizedAccessMessage($method) {
147 if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
148 return parent::getExpectedUnauthorizedAccessMessage($method);
156 return "The shortcut set must be the currently displayed set for the user and the user must have 'access shortcuts' AND 'customize shortcut links' permissions.";
159 return parent::getExpectedUnauthorizedAccessMessage($method);