diff --git a/tests/Collection/BuilderCollectionFunctionalTest.php b/tests/Collection/BuilderCollectionFunctionalTest.php index c974ac40d..1075c7aa8 100644 --- a/tests/Collection/BuilderCollectionFunctionalTest.php +++ b/tests/Collection/BuilderCollectionFunctionalTest.php @@ -8,8 +8,6 @@ use MongoDB\Builder\Stage; use PHPUnit\Framework\Attributes\TestWith; -use function iterator_to_array; - class BuilderCollectionFunctionalTest extends FunctionalTestCase { public function setUp(): void @@ -24,15 +22,15 @@ public function setUp(): void public function testAggregate(bool $pipelineAsArray): void { $this->collection->insertMany([['x' => 10], ['x' => 10], ['x' => 10]]); - $pipeline = new Pipeline( + $pipeline = [ Stage::bucketAuto( groupBy: Expression::intFieldPath('x'), buckets: 2, ), - ); + ]; - if ($pipelineAsArray) { - $pipeline = iterator_to_array($pipeline); + if (! $pipelineAsArray) { + $pipeline = new Pipeline(...$pipeline); } $results = $this->collection->aggregate($pipeline)->toArray(); @@ -272,12 +270,12 @@ public function testWatch(bool $pipelineAsArray): void $this->markTestSkipped('Test does not apply on sharded clusters: need more than a single getMore call on the change stream.'); } - $pipeline = new Pipeline( + $pipeline = [ Stage::match(operationType: Query::eq('insert')), - ); + ]; - if ($pipelineAsArray) { - $pipeline = iterator_to_array($pipeline); + if (! $pipelineAsArray) { + $pipeline = new Pipeline(...$pipeline); } $changeStream = $this->collection->watch($pipeline); diff --git a/tests/Database/BuilderDatabaseFunctionalTest.php b/tests/Database/BuilderDatabaseFunctionalTest.php index 1df18dbb1..491d2ccc1 100644 --- a/tests/Database/BuilderDatabaseFunctionalTest.php +++ b/tests/Database/BuilderDatabaseFunctionalTest.php @@ -8,8 +8,6 @@ use MongoDB\Builder\Stage; use PHPUnit\Framework\Attributes\TestWith; -use function iterator_to_array; - class BuilderDatabaseFunctionalTest extends FunctionalTestCase { public function tearDown(): void @@ -25,7 +23,7 @@ public function testAggregate(bool $pipelineAsArray): void { $this->skipIfServerVersion('<', '6.0.0', '$documents stage is not supported'); - $pipeline = new Pipeline( + $pipeline = [ Stage::documents([ ['x' => 1], ['x' => 2], @@ -35,10 +33,10 @@ public function testAggregate(bool $pipelineAsArray): void groupBy: Expression::intFieldPath('x'), buckets: 2, ), - ); + ]; - if ($pipelineAsArray) { - $pipeline = iterator_to_array($pipeline); + if (! $pipelineAsArray) { + $pipeline = new Pipeline(...$pipeline); } $results = $this->database->aggregate($pipeline)->toArray(); @@ -55,12 +53,12 @@ public function testWatch(bool $pipelineAsArray): void $this->markTestSkipped('Test does not apply on sharded clusters: need more than a single getMore call on the change stream.'); } - $pipeline = new Pipeline( + $pipeline = [ Stage::match(operationType: Query::eq('insert')), - ); + ]; - if ($pipelineAsArray) { - $pipeline = iterator_to_array($pipeline); + if (! $pipelineAsArray) { + $pipeline = new Pipeline(...$pipeline); } $changeStream = $this->database->watch($pipeline);