Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
IonBazan committed Aug 4, 2021
1 parent e18e9f4 commit 5fac0cb
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/Doctrine/ODM/MongoDB/Tests/Aggregation/BuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,32 @@ public function testAggregationBuilder()
$this->assertSame(3, $results[0]->numPosts);
}

public function testAggregationBuilderResetHydration(): void
{
$this->insertTestData();

$builder = $this->dm->createAggregationBuilder(BlogPost::class)->hydrate(BlogTagAggregation::class);

$resultCursor = $builder
->hydrate(null)
->unwind('$tags')
->group()
->field('id')
->expression('$tags')
->field('numPosts')
->sum(1)
->sort('numPosts', 'desc')
->getAggregation()
->getIterator();

$this->assertInstanceOf(Iterator::class, $resultCursor);

$results = $resultCursor->toArray();
$this->assertCount(2, $results);
$this->assertIsArray($results[0]);
$this->assertSame(3, $results[0]['numPosts']);
}

public function testGetAggregation()
{
$this->insertTestData();
Expand Down

0 comments on commit 5fac0cb

Please sign in to comment.