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

Commit 9b96cc9

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

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

tests/Builder/PipelineTest.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,28 @@ 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+
],
32+
);
33+
34+
$expected = [
35+
['$match' => ['tag' => 'foo']],
36+
['$sort' => ['_id' => 1]],
37+
];
38+
39+
$this->assertSame($expected, iterator_to_array($pipeline));
40+
}
41+
2542
public function testMergingPipeline(): void
2643
{
2744
$stages = array_map(

0 commit comments

Comments
 (0)