Skip to content

Commit

Permalink
Merge pull request #30 from bedita/fix/1.x/mask-relationships
Browse files Browse the repository at this point in the history
1.x - fix mask relationships
  • Loading branch information
batopa authored Jun 5, 2020
2 parents 9118e6b + 2f20c53 commit d171d69
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Controller/ApiProxyTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ protected function maskResponseLinks(array $response): array
}
$response['data'] = $data;
} else {
$response['data']['relationships'] = $this->maskMultiLinks($data);
$response['data'] = $this->maskMultiLinks($data);
}

return (array)$response;
Expand Down
10 changes: 8 additions & 2 deletions tests/TestCase/Controller/ApiProxyTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ public function testGet(): void
static::assertStringStartsWith($baseUrl, $link);
}

foreach (Hash::extract($response, 'data.relationships.{s}.links') as $link) {
$relationshipsLinks = (array)Hash::extract($response, 'data.relationships.{s}.links.{s}');
static::assertNotEmpty($relationshipsLinks);

foreach ($relationshipsLinks as $link) {
static::assertStringStartsWith($baseUrl, $link);
}
}
Expand Down Expand Up @@ -174,7 +177,10 @@ public function testMaskRelationshipsLinksGettingList(): void
$this->assertContentType('application/json');
$response = json_decode((string)$this->_response, true);

foreach (Hash::extract($response, 'data.{n}.relationships.{s}.links.{s}') as $link) {
$relationshipsLinks = (array)Hash::extract($response, 'data.{n}.relationships.{s}.links.{s}');
static::assertNotEmpty($relationshipsLinks);

foreach ($relationshipsLinks as $link) {
static::assertStringStartsWith($this->getBaseUrl(), $link);
}
}
Expand Down

0 comments on commit d171d69

Please sign in to comment.