Version 1
[yaffs-website] / web / core / modules / hal / tests / src / Functional / EntityResource / Term / TermHalJsonAnonTest.php
1 <?php
2
3 namespace Drupal\Tests\hal\Functional\EntityResource\Term;
4
5 use Drupal\Tests\hal\Functional\EntityResource\HalEntityNormalizationTrait;
6 use Drupal\Tests\rest\Functional\AnonResourceTestTrait;
7 use Drupal\Tests\rest\Functional\EntityResource\Term\TermResourceTestBase;
8
9 /**
10  * @group hal
11  */
12 class TermHalJsonAnonTest extends TermResourceTestBase {
13
14   use HalEntityNormalizationTrait;
15   use AnonResourceTestTrait;
16
17   /**
18    * {@inheritdoc}
19    */
20   public static $modules = ['hal'];
21
22   /**
23    * {@inheritdoc}
24    */
25   protected static $format = 'hal_json';
26
27   /**
28    * {@inheritdoc}
29    */
30   protected static $mimeType = 'application/hal+json';
31
32   /**
33    * {@inheritdoc}
34    */
35   protected function getExpectedNormalizedEntity() {
36     $default_normalization = parent::getExpectedNormalizedEntity();
37
38     $normalization = $this->applyHalFieldNormalization($default_normalization);
39
40     return $normalization + [
41       '_links' => [
42         'self' => [
43           'href' => $this->baseUrl . '/taxonomy/term/1?_format=hal_json',
44         ],
45         'type' => [
46           'href' => $this->baseUrl . '/rest/type/taxonomy_term/camelids',
47         ],
48       ],
49     ];
50   }
51
52   /**
53    * {@inheritdoc}
54    */
55   protected function getNormalizedPostEntity() {
56     return parent::getNormalizedPostEntity() + [
57       '_links' => [
58         'type' => [
59           'href' => $this->baseUrl . '/rest/type/taxonomy_term/camelids',
60         ],
61       ],
62     ];
63   }
64
65 }