3 namespace Drupal\Tests\hal\Functional\EntityResource\Shortcut;
5 use Drupal\Core\Cache\Cache;
6 use Drupal\Tests\hal\Functional\EntityResource\HalEntityNormalizationTrait;
7 use Drupal\Tests\rest\Functional\AnonResourceTestTrait;
8 use Drupal\Tests\rest\Functional\EntityResource\Shortcut\ShortcutResourceTestBase;
13 class ShortcutHalJsonAnonTest extends ShortcutResourceTestBase {
15 use HalEntityNormalizationTrait;
16 use AnonResourceTestTrait;
21 public static $modules = ['hal'];
26 protected static $format = 'hal_json';
31 protected static $mimeType = 'application/hal+json';
36 protected function getExpectedNormalizedEntity() {
37 $default_normalization = parent::getExpectedNormalizedEntity();
39 $normalization = $this->applyHalFieldNormalization($default_normalization);
41 return $normalization + [
44 'href' => $this->baseUrl . '/admin/config/user-interface/shortcut/link/1?_format=hal_json',
47 'href' => $this->baseUrl . '/rest/type/shortcut/default',
56 protected function getNormalizedPostEntity() {
57 return parent::getNormalizedPostEntity() + [
60 'href' => $this->baseUrl . '/rest/type/shortcut/default',
69 protected function getExpectedCacheContexts() {
70 // The 'url.site' cache context is added for '_links' in the response.
71 return Cache::mergeContexts(parent::getExpectedCacheContexts(), ['url.site']);