Skip to content

Commit 189c6b4

Browse files
committed
Merge pull request #19 from countless-integers/patch-1
fixes behaviour for passing empty values to parseIncludes
2 parents 5bde517 + 8d91785 commit 189c6b4

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/Fractal.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public function parseIncludes($includes)
160160
}, explode(',', $includes));
161161
}
162162

163-
$this->includes = array_merge($this->includes, $includes);
163+
$this->includes = array_merge($this->includes, (array)$includes);
164164

165165
return $this;
166166
}

tests/Integration/IncludesTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,28 @@ public function it_can_handle_multiple_includes_at_once()
8282

8383
$this->assertEquals($expectedArray, $array);
8484
}
85+
86+
/**
87+
* @test
88+
*/
89+
public function it_knows_to_ignore_invalid_includes_param()
90+
{
91+
$array = $this->fractal
92+
->collection($this->testBooks, new TestTransformer())
93+
->parseIncludes(null)
94+
->toArray();
95+
96+
$expectedArray = ['data' => [
97+
['id' => 1, 'author' => 'Philip K Dick', ],
98+
['id' => 2, 'author' => 'George R. R. Satan', ],
99+
]];
100+
101+
$this->assertEquals($expectedArray, $array);
102+
103+
$array = $this->fractal
104+
->collection($this->testBooks, new TestTransformer())
105+
->parseIncludes([])
106+
->toArray();
107+
$this->assertEquals($expectedArray, $array);
108+
}
85109
}

0 commit comments

Comments
 (0)