diff --git a/core/modules/rest/src/Plugin/views/style/Serializer.php b/core/modules/rest/src/Plugin/views/style/Serializer.php index 00286e6..db9b05c 100644 --- a/core/modules/rest/src/Plugin/views/style/Serializer.php +++ b/core/modules/rest/src/Plugin/views/style/Serializer.php @@ -135,7 +135,7 @@ public function render() { else { $content_type = !empty($this->options['formats']) ? reset($this->options['formats']) : 'json'; } - return $this->serializer->serialize($rows, $content_type, array('views_style_plugin' => $this)); + return $this->serializer->serialize($rows, $content_type, ['views_style_plugin' => $this]); } /** diff --git a/core/modules/rest/tests/src/Unit/Plugin/views/style/SerializerTest.php b/core/modules/rest/tests/src/Unit/Plugin/views/style/SerializerTest.php index 9be1cdc..efa708e 100644 --- a/core/modules/rest/tests/src/Unit/Plugin/views/style/SerializerTest.php +++ b/core/modules/rest/tests/src/Unit/Plugin/views/style/SerializerTest.php @@ -11,6 +11,7 @@ use Drupal\rest\Plugin\views\style\Serializer; use Drupal\Tests\UnitTestCase; use Drupal\views\ViewExecutable; +use Prophecy\Argument; use Symfony\Component\Serializer\SerializerInterface; /** @@ -66,8 +67,10 @@ public function testSerializerReceivesOptions() { // This is the main expectation of the test. We want to make sure the // serializer options are passed to the SerializerInterface object. - $mock_serializer->serialize([], 'json', ['views_style_plugin' => $mock_serializer]) - ->willReturn('') + $mock_serializer->serialize([], 'json', Argument::that(function ($argument) { + return isset($argument['views_style_plugin']) && $argument['views_style_plugin'] instanceof Serializer; + })) + ->willReturn() ->shouldBeCalled(); $view_serializer_style = new Serializer([], 'dummy_serializer', [], $mock_serializer->reveal(), ['json', 'xml']);