public function testAggregationBuilder()
{
$this->insertTestData();
$builder = $this->dm->createAggregationBuilder(\Documents\BlogPost::class);
$aggregationResult = $builder->hydrate(\Documents\BlogTagAggregation::class)->unwind('$tags')->group()->field('id')->expression('$tags')->field('numPosts')->sum(1)->sort('numPosts', 'desc')->execute();
$this->assertInstanceOf('Doctrine\\ODM\\MongoDB\\CommandCursor', $aggregationResult);
$this->assertCount(2, $aggregationResult);
$results = $aggregationResult->toArray();
$this->assertInstanceOf('Documents\\BlogTagAggregation', $results[0]);
$this->assertSame('baseball', $results[0]->tag->name);
$this->assertSame(3, $results[0]->numPosts);
}