Skip to content

Commit

Permalink
adjusted tests and syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
joaokamun committed Apr 13, 2023
1 parent 9e383fe commit 33d17fa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/Storyblok/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ public function enrichContent($data, $level = 0)
if (isset($fieldValue['_stopResolving']) && $fieldValue['_stopResolving']) {
continue;
}

$enrichedContent[$fieldName] = $this->insertRelations($data['component'], $fieldName, $fieldValue);
$enrichedContent[$fieldName] = $this->insertLinks($enrichedContent[$fieldName]);
$enrichedContent[$fieldName] = $this->enrichContent($enrichedContent[$fieldName], $level + 1);
Expand Down
27 changes: 15 additions & 12 deletions tests/Storyblok/Integration/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,13 @@
$body = $responses->getBody();
expect($body)->toHaveKeys(['rels', 'story', 'cv', 'links']);
expect($body['story']['content']['Products'])->toBeArray();
expect($body['story']['content']['Products']['content']['productname'])->toEqual('Shoe 001');
expect($body['story']['content']['Products']['content']['ProductVariants'])->toBeArray()->toHaveLength(3);
expect($body['story']['content']['Products']['content']['ProductVariants']['0'])->toBeArray();
expect($body['story']['content']['Products']['content']['ProductVariants']['0']['name'])->toEqual('Shoe 001 Blue');
expect($body['story']['content']['Products']['content']['ProductVariants']['0']['content'])->toBeArray();
expect($body['story']['content']['Products']['content']['ProductVariants']['0']['content']['VariantName'])->toEqual('Shoe 001 Blue');
expect($body['story']['content']['Products'])->toHaveLength(1);
expect($body['story']['content']['Products'][0]['content']['productname'])->toEqual('Shoe 001');
expect($body['story']['content']['Products'][0]['content']['ProductVariants'])->toBeArray()->toHaveLength(3);
expect($body['story']['content']['Products'][0]['content']['ProductVariants']['0'])->toBeArray();
expect($body['story']['content']['Products'][0]['content']['ProductVariants']['0']['name'])->toEqual('Shoe 001 Blue');
expect($body['story']['content']['Products'][0]['content']['ProductVariants']['0']['content'])->toBeArray();
expect($body['story']['content']['Products'][0]['content']['ProductVariants']['0']['content']['VariantName'])->toEqual('Shoe 001 Blue');
expect($body['rels'])->toHaveLength(4);
})->group('integration');

Expand Down Expand Up @@ -243,9 +244,10 @@
expect($body['stories'][0]['name'])->toEqual('Category Shoe 001');

expect($body['stories'][0]['content']['Products'])->toBeArray();
expect($body['stories'][0]['content']['Products']['name'])->toEqual('Shoe 001');
expect($body['stories'][0]['content']['Products']['content']['ProductVariants'])->toBeArray()->toHaveLength(3);
expect($body['stories'][0]['content']['Products']['content']['ProductVariants']['0']['content']['VariantName'])->toEqual('Shoe 001 Blue');
expect($body['stories'][0]['content']['Products'])->toHaveLength(1);
expect($body['stories'][0]['content']['Products'][0]['name'])->toEqual('Shoe 001');
expect($body['stories'][0]['content']['Products'][0]['content']['ProductVariants'])->toBeArray()->toHaveLength(3);
expect($body['stories'][0]['content']['Products'][0]['content']['ProductVariants']['0']['content']['VariantName'])->toEqual('Shoe 001 Blue');
})->group('integration');

test('Integration: get list of stories -translations- story with Resolved relations 2', function () {
Expand All @@ -269,9 +271,10 @@
expect($body['stories'][0]['name'])->toEqual('Category Shoe 001');

expect($body['stories'][0]['content']['Products'])->toBeArray();
expect($body['stories'][0]['content']['Products']['name'])->toEqual('Shoe 001');
expect($body['stories'][0]['content']['Products']['content']['ProductVariants'])->toBeArray()->toHaveLength(3);
expect($body['stories'][0]['content']['Products']['content']['ProductVariants']['0']['content']['VariantName'])->toEqual('Scarpa 001 Blu');
expect($body['stories'][0]['content']['Products'])->toHaveLength(1);
expect($body['stories'][0]['content']['Products'][0]['name'])->toEqual('Shoe 001');
expect($body['stories'][0]['content']['Products'][0]['content']['ProductVariants'])->toBeArray()->toHaveLength(3);
expect($body['stories'][0]['content']['Products'][0]['content']['ProductVariants']['0']['content']['VariantName'])->toEqual('Scarpa 001 Blu');
})->group('integration');

test('Integration: get one story with Resolved relations 3', function () {
Expand Down

0 comments on commit 33d17fa

Please sign in to comment.