3 namespace Drupal\Tests\hal\Functional\EntityResource\Node;
5 use Drupal\Tests\hal\Functional\EntityResource\HalEntityNormalizationTrait;
6 use Drupal\Tests\rest\Functional\AnonResourceTestTrait;
7 use Drupal\Tests\rest\Functional\EntityResource\Node\NodeResourceTestBase;
8 use Drupal\user\Entity\User;
13 class NodeHalJsonAnonTest extends NodeResourceTestBase {
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 static $patchProtectedFieldNames = [
49 protected function getExpectedNormalizedEntity() {
50 $default_normalization = parent::getExpectedNormalizedEntity();
52 $normalization = $this->applyHalFieldNormalization($default_normalization);
54 $author = User::load($this->entity->getOwnerId());
55 return $normalization + [
58 'href' => $this->baseUrl . '/llama?_format=hal_json',
61 'href' => $this->baseUrl . '/rest/type/node/camelids',
63 $this->baseUrl . '/rest/relation/node/camelids/revision_uid' => [
65 'href' => $this->baseUrl . '/user/' . $author->id() . '?_format=hal_json',
68 $this->baseUrl . '/rest/relation/node/camelids/uid' => [
70 'href' => $this->baseUrl . '/user/' . $author->id() . '?_format=hal_json',
76 $this->baseUrl . '/rest/relation/node/camelids/revision_uid' => [
80 'href' => $this->baseUrl . '/user/' . $author->id() . '?_format=hal_json',
83 'href' => $this->baseUrl . '/rest/type/user/user',
87 ['value' => $author->uuid()]
91 $this->baseUrl . '/rest/relation/node/camelids/uid' => [
95 'href' => $this->baseUrl . '/user/' . $author->id() . '?_format=hal_json',
98 'href' => $this->baseUrl . '/rest/type/user/user',
102 ['value' => $author->uuid()]
114 protected function getNormalizedPostEntity() {
115 return parent::getNormalizedPostEntity() + [
118 'href' => $this->baseUrl . '/rest/type/node/camelids',