3 namespace Drupal\Tests\hal\Functional\EntityResource\EntityTest;
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;
13 class EntityTestHalJsonAnonTest extends EntityTestResourceTestBase {
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 $author = User::load(0);
42 return $normalization + [
45 'href' => $this->baseUrl . '/entity_test/1?_format=hal_json',
48 'href' => $this->baseUrl . '/rest/type/entity_test/entity_test',
50 $this->baseUrl . '/rest/relation/entity_test/entity_test/user_id' => [
52 'href' => $this->baseUrl . '/user/0?_format=hal_json',
58 $this->baseUrl . '/rest/relation/entity_test/entity_test/user_id' => [
62 'href' => $this->baseUrl . '/user/0?_format=hal_json',
65 'href' => $this->baseUrl . '/rest/type/user/user',
69 ['value' => $author->uuid()]
81 protected function getNormalizedPostEntity() {
82 return parent::getNormalizedPostEntity() + [
85 'href' => $this->baseUrl . '/rest/type/entity_test/entity_test',