Alcaeus\MongoDbAdapter\Tests\Mongo\MongoCollectionTest::testAggregate PHP Method

testAggregate() public method

public testAggregate ( )
    public function testAggregate()
    {
        $collection = $this->getCollection();
        $this->prepareData();
        $pipeline = [['$group' => ['_id' => '$foo', 'count' => ['$sum' => 1]]], ['$sort' => ['_id' => 1]]];
        $result = $collection->aggregate($pipeline);
        $this->assertInternalType('array', $result);
        $this->assertArrayHasKey('result', $result);
        $this->assertEquals([['_id' => 'bar', 'count' => 2], ['_id' => 'foo', 'count' => 1]], $result['result']);
    }
MongoCollectionTest