Skip to content
This repository was archived by the owner on Feb 28, 2025. It is now read-only.

Commit 0850040

Browse files
committed
Add test to create pipeline from array
1 parent c7ce07c commit 0850040

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

tests/Builder/PipelineTest.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,32 @@ class PipelineTest extends TestCase
1717
{
1818
public function testEmptyPipeline(): void
1919
{
20-
$pipeline = new Pipeline();
20+
$pipeline = new Pipeline([]);
2121

2222
$this->assertSame([], iterator_to_array($pipeline));
2323
}
2424

25+
public function testFromArray(): void
26+
{
27+
$pipeline = new Pipeline(
28+
['$match' => ['tag' => 'foo']],
29+
[
30+
['$sort' => ['_id' => 1]],
31+
['$skip' => 10],
32+
],
33+
['$limit' => 5],
34+
);
35+
36+
$expected = [
37+
['$match' => ['tag' => 'foo']],
38+
['$sort' => ['_id' => 1]],
39+
['$skip' => 10],
40+
['$limit' => 5],
41+
];
42+
43+
$this->assertSame($expected, iterator_to_array($pipeline));
44+
}
45+
2546
public function testMergingPipeline(): void
2647
{
2748
$stages = array_map(

0 commit comments

Comments
 (0)