Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / shortcut / tests / src / Functional / Hal / ShortcutHalJsonAnonTest.php
1 <?php
2
3 namespace Drupal\Tests\shortcut\Functional\Hal;
4
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\shortcut\Functional\Rest\ShortcutResourceTestBase;
9
10 /**
11  * @group hal
12  */
13 class ShortcutHalJsonAnonTest extends ShortcutResourceTestBase {
14
15   use HalEntityNormalizationTrait;
16   use AnonResourceTestTrait;
17
18   /**
19    * {@inheritdoc}
20    */
21   public static $modules = ['hal'];
22
23   /**
24    * {@inheritdoc}
25    */
26   protected static $format = 'hal_json';
27
28   /**
29    * {@inheritdoc}
30    */
31   protected static $mimeType = 'application/hal+json';
32
33   /**
34    * {@inheritdoc}
35    */
36   protected function getExpectedNormalizedEntity() {
37     $default_normalization = parent::getExpectedNormalizedEntity();
38
39     $normalization = $this->applyHalFieldNormalization($default_normalization);
40
41     return $normalization + [
42       '_links' => [
43         'self' => [
44           'href' => $this->baseUrl . '/admin/config/user-interface/shortcut/link/1?_format=hal_json',
45         ],
46         'type' => [
47           'href' => $this->baseUrl . '/rest/type/shortcut/default',
48         ],
49       ],
50     ];
51   }
52
53   /**
54    * {@inheritdoc}
55    */
56   protected function getNormalizedPostEntity() {
57     return parent::getNormalizedPostEntity() + [
58       '_links' => [
59         'type' => [
60           'href' => $this->baseUrl . '/rest/type/shortcut/default',
61         ],
62       ],
63     ];
64   }
65
66   /**
67    * {@inheritdoc}
68    */
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']);
72   }
73
74 }