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 = [
48 protected function getExpectedNormalizedEntity() {
49 $default_normalization = parent::getExpectedNormalizedEntity();
51 $normalization = $this->applyHalFieldNormalization($default_normalization);
53 $author = User::load($this->entity->getOwnerId());
54 return $normalization + [
57 'href' => $this->baseUrl . '/node/1?_format=hal_json',
60 'href' => $this->baseUrl . '/rest/type/node/camelids',
62 $this->baseUrl . '/rest/relation/node/camelids/uid' => [
64 'href' => $this->baseUrl . '/user/' . $author->id() . '?_format=hal_json',
68 $this->baseUrl . '/rest/relation/node/camelids/revision_uid' => [
70 'href' => $this->baseUrl . '/user/' . $author->id() . '?_format=hal_json',
75 $this->baseUrl . '/rest/relation/node/camelids/uid' => [
79 'href' => $this->baseUrl . '/user/' . $author->id() . '?_format=hal_json',
82 'href' => $this->baseUrl . '/rest/type/user/user',
86 ['value' => $author->uuid()]
91 $this->baseUrl . '/rest/relation/node/camelids/revision_uid' => [
95 'href' => $this->baseUrl . '/user/' . $author->id() . '?_format=hal_json',
98 'href' => $this->baseUrl . '/rest/type/user/user',
102 ['value' => $author->uuid()]
113 protected function getNormalizedPostEntity() {
114 return parent::getNormalizedPostEntity() + [
117 'href' => $this->baseUrl . '/rest/type/node/camelids',