Skip to content

Commit 044f8ca

Browse files
authored
Merge pull request #61 from lode/fix-nesting-include-paths
2 parents e802d27 + 4f31448 commit 044f8ca

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

src/helpers/RequestParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public function getIncludePaths(array $options=[]) {
144144
$wrapped = [$lastStep => $wrapped];
145145
}
146146

147-
$restructured = array_merge($restructured, $wrapped);
147+
$restructured = array_merge_recursive($restructured, $wrapped);
148148
}
149149

150150
return $restructured;

tests/helpers/RequestParserTest.php

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,36 @@ public function testHasIncludePaths() {
214214
}
215215

216216
public function testGetIncludePaths_Reformatted() {
217-
$queryParameters = ['include' => 'foo,bar,baz.baf'];
217+
$paths = [
218+
'foo',
219+
'bar',
220+
'baz.baf',
221+
'baz.bat',
222+
'user.ship.wing',
223+
'user.ship.nose.window',
224+
'user.friends',
225+
];
226+
$expected = [
227+
'foo' => [],
228+
'bar' => [],
229+
'baz' => [
230+
'baf' => [],
231+
'bat' => [],
232+
],
233+
'user' => [
234+
'ship' => [
235+
'wing' => [],
236+
'nose' => [
237+
'window' => [],
238+
],
239+
],
240+
'friends' => [],
241+
],
242+
];
243+
244+
$queryParameters = ['include' => implode(',', $paths)];
218245
$requestParser = new RequestParser($selfLink='', $queryParameters);
219-
$this->assertSame(['foo' => [], 'bar' => [], 'baz' => ['baf' => []]], $requestParser->getIncludePaths());
246+
$this->assertSame($expected, $requestParser->getIncludePaths());
220247
}
221248

222249
public function testGetIncludePaths_Raw() {

0 commit comments

Comments
 (0)