3 namespace Drupal\Tests\hal\Functional\EntityResource\BlockContent;
5 use Drupal\Core\Cache\Cache;
6 use Drupal\Tests\hal\Functional\EntityResource\HalEntityNormalizationTrait;
7 use Drupal\Tests\rest\Functional\AnonResourceTestTrait;
8 use Drupal\Tests\rest\Functional\EntityResource\BlockContent\BlockContentResourceTestBase;
13 class BlockContentHalJsonAnonTest extends BlockContentResourceTestBase {
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 return $normalization + [
44 'href' => $this->baseUrl . '/block/1?_format=hal_json',
47 'href' => $this->baseUrl . '/rest/type/block_content/basic',
56 protected function getNormalizedPostEntity() {
57 return parent::getNormalizedPostEntity() + [
60 'href' => $this->baseUrl . '/rest/type/block_content/basic',
69 protected function getExpectedCacheContexts() {
70 // The 'url.site' cache context is added for '_links' in the response.
71 return Cache::mergeTags(parent::getExpectedCacheContexts(), ['url.site']);