diff --git a/src/Storyblok/Client.php b/src/Storyblok/Client.php index 323f7e5..2ff70da 100644 --- a/src/Storyblok/Client.php +++ b/src/Storyblok/Client.php @@ -721,7 +721,7 @@ function getResolvedLinks($data, array $queryString) /** * Enrich the Stories with resolved links and stories. * - * @param array|string $data + * @param array|\stdClass|string $data * * @return array|string */ @@ -735,7 +735,7 @@ public function enrichContent($data) foreach ($data as $fieldName => $fieldValue) { $enrichedContent[$fieldName] = $this->insertRelations($data['component'], $fieldName, $fieldValue); $enrichedContent[$fieldName] = $this->insertLinks($enrichedContent[$fieldName]); - $enrichedContent[$fieldName] = $this->enrichContent((array) $enrichedContent[$fieldName]); + $enrichedContent[$fieldName] = $this->enrichContent($enrichedContent[$fieldName]); } } } elseif (\is_array($data)) { diff --git a/tests/Storyblok/Integration/ClientTest.php b/tests/Storyblok/Integration/ClientTest.php index f9530bf..86215fc 100644 --- a/tests/Storyblok/Integration/ClientTest.php +++ b/tests/Storyblok/Integration/ClientTest.php @@ -60,6 +60,32 @@ $this->assertCount(1, $responses); })->group('integration'); +test('Integration: check casting after enriching content', function () { + $client = new Client('Iw3XKcJb6MwkdZEwoQ9BCQtt'); + $client->editMode(); + $options = $client->getApiParameters(); + $response = $client->getStoryBySlug('home'); + $body = $response->getBody(); + expect($body)->toBeArray() + ->toHaveKey('story') + ->toHaveCount(4) + ; + $story = $body['story']; + expect($story)->toBeArray() + ->toHaveKey('content') + ->toHaveCount(22) + ; + $content = $story['content']; + expect($content)->toBeArray() + ->toHaveKey('_uid') + ->toHaveKey('body') + ->toHaveKey('component') + ->toHaveCount(4) + ; + expect($content['_uid'])->toBeString(); + expect($content['component'])->toBeString(); +})->group('integration'); + test('Integration: get one story with option with cache', function () { unset($_GET['_storyblok_published']); $client = new Client('Iw3XKcJb6MwkdZEwoQ9BCQtt');