|
|
@@ -1553,4 +1553,17 @@ class CollectionTest extends TestCase
|
|
|
$expected = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11]];
|
|
|
$this->assertEquals($expected, $chunked);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Tests the chunk method with non-scalar items
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testChunkNested()
|
|
|
+ {
|
|
|
+ $collection = new Collection([1, 2, 3, [4, 5], 6, [7, [8, 9], 10], 11]);
|
|
|
+ $chunked = $collection->chunk(2)->toList();
|
|
|
+ $expected = [[1, 2], [3, [4, 5]], [6, [7, [8, 9,], 10]], [11]];
|
|
|
+ $this->assertEquals($expected, $chunked);
|
|
|
+ }
|
|
|
}
|