.../entity_test/src/Entity/EntityTestMapField.php | 1 + .../Hal/EnityTestMapFieldHalJsonAnonTest.php | 103 +++++++++++++++++++++ .../Rest/EntityTestMapFieldResourceTestBase.php | 5 + 3 files changed, 109 insertions(+) diff --git a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestMapField.php b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestMapField.php index 82bba32..b21d1a0 100644 --- a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestMapField.php +++ b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestMapField.php @@ -15,6 +15,7 @@ * entity_keys = { * "id" = "id", * "label" = "name", + * "langcode" = "langcode", * }, * admin_permission = "administer entity_test content", * ) diff --git a/core/modules/system/tests/modules/entity_test/tests/src/Functional/Hal/EnityTestMapFieldHalJsonAnonTest.php b/core/modules/system/tests/modules/entity_test/tests/src/Functional/Hal/EnityTestMapFieldHalJsonAnonTest.php new file mode 100644 index 0000000..af1ef4c --- /dev/null +++ b/core/modules/system/tests/modules/entity_test/tests/src/Functional/Hal/EnityTestMapFieldHalJsonAnonTest.php @@ -0,0 +1,103 @@ +applyHalFieldNormalization($default_normalization); + + $author = User::load(0); + return $normalization + [ + '_links' => [ + 'self' => [ + 'href' => '', + ], + 'type' => [ + 'href' => $this->baseUrl . '/rest/type/entity_test_map_field/entity_test_map_field', + ], + $this->baseUrl . '/rest/relation/entity_test_map_field/entity_test_map_field/user_id' => [ + [ + 'href' => $this->baseUrl . '/user/0?_format=hal_json', + 'lang' => 'en', + ], + ], + ], + '_embedded' => [ + $this->baseUrl . '/rest/relation/entity_test_map_field/entity_test_map_field/user_id' => [ + [ + '_links' => [ + 'self' => [ + 'href' => $this->baseUrl . '/user/0?_format=hal_json', + ], + 'type' => [ + 'href' => $this->baseUrl . '/rest/type/user/user', + ], + ], + 'uuid' => [ + [ + 'value' => $author->uuid(), + ], + ], + 'lang' => 'en', + ], + ], + ], + ]; + } + + /** + * {@inheritdoc} + */ + protected function getNormalizedPostEntity() { + return parent::getNormalizedPostEntity() + [ + '_links' => [ + 'type' => [ + 'href' => $this->baseUrl . '/rest/type/entity_test_map_field/entity_test_map_field', + ], + ], + ]; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedCacheContexts() { + return [ + 'url.site', + 'user.permissions', + ]; + } + +} diff --git a/core/modules/system/tests/modules/entity_test/tests/src/Functional/Rest/EntityTestMapFieldResourceTestBase.php b/core/modules/system/tests/modules/entity_test/tests/src/Functional/Rest/EntityTestMapFieldResourceTestBase.php index dcc12b9..183b49d 100644 --- a/core/modules/system/tests/modules/entity_test/tests/src/Functional/Rest/EntityTestMapFieldResourceTestBase.php +++ b/core/modules/system/tests/modules/entity_test/tests/src/Functional/Rest/EntityTestMapFieldResourceTestBase.php @@ -82,6 +82,11 @@ protected function getExpectedNormalizedEntity() { 'value' => 'Llama', ], ], + 'langcode' => [ + [ + 'value' => 'en', + ], + ], 'created' => [ $this->formatExpectedTimestampItemValues((int) $this->entity->get('created')->value), ],