core/modules/layout_builder/layout_builder.services.yml | 5 ++--- .../src/Normalizer/LayoutEntityDisplayNormalizer.php | 2 ++ .../tests/src/Functional/Rest/EntityDisplaySections.php | 13 +++---------- .../tests/src/Functional/Rest/LayoutRestTestBase.php | 6 ++++-- .../tests/src/Functional/Rest/OverrideSections.php | 12 ++++++------ 5 files changed, 17 insertions(+), 21 deletions(-) diff --git a/core/modules/layout_builder/layout_builder.services.yml b/core/modules/layout_builder/layout_builder.services.yml index 5802ed1142..72baee308b 100644 --- a/core/modules/layout_builder/layout_builder.services.yml +++ b/core/modules/layout_builder/layout_builder.services.yml @@ -44,9 +44,8 @@ services: class: Drupal\layout_builder\InlineBlockUsage arguments: ['@database'] layout_builder.normalizer.layout_entity_display: + parent: serializer.normalizer.config_entity class: Drupal\layout_builder\Normalizer\LayoutEntityDisplayNormalizer tags: - # Set the priority higher than the serializer.normalizer.config_entity normalizer, so that we do not replace it. - # @todo Find a better way for this in https://www.drupal.org/node/2575761. + # Priority must be higher than serializer.normalizer.config_entity. - { name: normalizer, priority: 5 } - arguments: ['@entity_type.manager', '@entity_type.repository', '@entity_field.manager'] diff --git a/core/modules/layout_builder/src/Normalizer/LayoutEntityDisplayNormalizer.php b/core/modules/layout_builder/src/Normalizer/LayoutEntityDisplayNormalizer.php index 7b3f1dbe5b..e7a83d0cbe 100644 --- a/core/modules/layout_builder/src/Normalizer/LayoutEntityDisplayNormalizer.php +++ b/core/modules/layout_builder/src/Normalizer/LayoutEntityDisplayNormalizer.php @@ -7,6 +7,8 @@ /** * Normalizes/denormalizes LayoutEntityDisplay objects into an array structure. + * + * @internal */ class LayoutEntityDisplayNormalizer extends ConfigEntityNormalizer { diff --git a/core/modules/layout_builder/tests/src/Functional/Rest/EntityDisplaySections.php b/core/modules/layout_builder/tests/src/Functional/Rest/EntityDisplaySections.php index e67ba8cf61..cf643bf21d 100644 --- a/core/modules/layout_builder/tests/src/Functional/Rest/EntityDisplaySections.php +++ b/core/modules/layout_builder/tests/src/Functional/Rest/EntityDisplaySections.php @@ -6,9 +6,10 @@ use Drupal\Core\Url; /** - * Tests that default layout sections are not is not exposed via Rest. + * Tests that default layout sections are not exposed via the REST API. * * @group layout_builder + * @group rest */ class EntityDisplaySections extends LayoutRestTestBase { @@ -18,15 +19,7 @@ class EntityDisplaySections extends LayoutRestTestBase { protected static $resourceConfigId = 'entity.entity_view_display'; /** - * {@inheritdoc} - */ - public function setUp() { - parent::setUp(); - $this->provisionResource([static::$format], ['basic_auth'], ['GET']); - } - - /** - * Tests Layout Entity Display does not contain layout sections. + * Tests the normalization does not contain layout sections. */ public function testLayoutEntityDisplay() { $display_id = 'node.bundle_with_section_field.default'; diff --git a/core/modules/layout_builder/tests/src/Functional/Rest/LayoutRestTestBase.php b/core/modules/layout_builder/tests/src/Functional/Rest/LayoutRestTestBase.php index a4d8069fcc..fb0f7c2b4a 100644 --- a/core/modules/layout_builder/tests/src/Functional/Rest/LayoutRestTestBase.php +++ b/core/modules/layout_builder/tests/src/Functional/Rest/LayoutRestTestBase.php @@ -10,7 +10,7 @@ use Psr\Http\Message\ResponseInterface; /** - * Base class for Layout Builder Rest tests. + * Base class for Layout Builder REST tests. */ abstract class LayoutRestTestBase extends ResourceTestBase { @@ -94,6 +94,8 @@ public function setUp() { $this->drupalLogout(); $this->setUpAuthorization('ALL'); + + $this->provisionResource([static::$format], ['basic_auth']); } /** @@ -104,7 +106,7 @@ protected function request($method, Url $url, array $request_options = []) { 'Content-Type' => static::$mimeType, ]; $request_options = NestedArray::mergeDeep($request_options, $this->getAuthenticationRequestOptions($method)); - $request_options['query'] = ['_format' => static::$format]; + $request_options[RequestOptions::QUERY] = ['_format' => static::$format]; return parent::request($method, $url, $request_options); } diff --git a/core/modules/layout_builder/tests/src/Functional/Rest/OverrideSections.php b/core/modules/layout_builder/tests/src/Functional/Rest/OverrideSections.php index 12d1a3fdce..37b7dfef6a 100644 --- a/core/modules/layout_builder/tests/src/Functional/Rest/OverrideSections.php +++ b/core/modules/layout_builder/tests/src/Functional/Rest/OverrideSections.php @@ -8,9 +8,10 @@ use GuzzleHttp\RequestOptions; /** - * Tests that override layout sections are not is not exposed via Rest. + * Tests that override layout sections are not exposed via the REST API. * * @group layout_builder + * @group rest */ class OverrideSections extends LayoutRestTestBase { @@ -24,14 +25,13 @@ class OverrideSections extends LayoutRestTestBase { */ public function setUp() { parent::setUp(); - $this->provisionResource([static::$format], ['basic_auth']); // @todo Figure why field definitions have to cleared in // https://www.drupal.org/project/drupal/issues/2985882. $this->container->get('entity_field.manager')->clearCachedFieldDefinitions(); } /** - * Tests that the override field is not available over Rest. + * Tests that the layout override field is not normalized. */ public function testOverrideField() { $this->assertCount(1, $this->node->get(OverridesSectionStorage::FIELD_NAME)); @@ -61,9 +61,9 @@ public function testOverrideField() { FALSE, 'MISS' ); - $patch_data = $this->getDecodedContents($response); - $this->assertSame('A node at rest will stay at rest.', $patch_data['title'][0]['value']); - $this->assertArrayNotHasKey('layout_builder__layout', $patch_data); + $get_data = $this->getDecodedContents($response); + $this->assertSame('A node at rest will stay at rest.', $get_data['title'][0]['value']); + $this->assertArrayNotHasKey('layout_builder__layout', $get_data); // Make a POST request without the override field. $new_node = [