Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / hal / tests / src / Functional / EntityResource / EntityTest / EntityTestHalJsonAnonTest.php
1 <?php
2
3 namespace Drupal\Tests\hal\Functional\EntityResource\EntityTest;
4
5 use Drupal\Tests\hal\Functional\EntityResource\HalEntityNormalizationTrait;
6 use Drupal\Tests\rest\Functional\AnonResourceTestTrait;
7 use Drupal\Tests\rest\Functional\EntityResource\EntityTest\EntityTestResourceTestBase;
8 use Drupal\user\Entity\User;
9
10 /**
11  * @group hal
12  */
13 class EntityTestHalJsonAnonTest extends EntityTestResourceTestBase {
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     $author = User::load(0);
42     return  $normalization + [
43       '_links' => [
44         'self' => [
45           'href' => $this->baseUrl . '/entity_test/1?_format=hal_json',
46         ],
47         'type' => [
48           'href' => $this->baseUrl . '/rest/type/entity_test/entity_test',
49         ],
50         $this->baseUrl . '/rest/relation/entity_test/entity_test/user_id' => [
51           [
52             'href' => $this->baseUrl . '/user/0?_format=hal_json',
53             'lang' => 'en',
54           ],
55         ],
56       ],
57       '_embedded' => [
58         $this->baseUrl . '/rest/relation/entity_test/entity_test/user_id' => [
59           [
60             '_links' => [
61               'self' => [
62                 'href' => $this->baseUrl . '/user/0?_format=hal_json',
63               ],
64               'type' => [
65                 'href' => $this->baseUrl . '/rest/type/user/user',
66               ],
67             ],
68             'uuid' => [
69               ['value' => $author->uuid()]
70             ],
71             'lang' => 'en',
72           ],
73         ],
74       ],
75     ];
76   }
77
78   /**
79    * {@inheritdoc}
80    */
81   protected function getNormalizedPostEntity() {
82     return parent::getNormalizedPostEntity() + [
83       '_links' => [
84         'type' => [
85           'href' => $this->baseUrl . '/rest/type/entity_test/entity_test',
86         ],
87       ],
88     ];
89   }
90
91 }