Phalcon\Test\Mvc\CollectionsTest::testCollectionsAggregate PHP Method

testCollectionsAggregate() public method

    public function testCollectionsAggregate()
    {
        $this->loadData();
        $data = Cars::aggregate([['$match' => ['manufacturer' => 'Ferrari']], ['$group' => ['_id' => '$manufacturer', 'total' => ['$sum' => '$value']]]]);
        $this->assertInstanceOf('MongoDB\\Driver\\Cursor', $data);
        $results = $data->toArray();
        $this->assertEquals('Ferrari', $results[0]['_id']);
        $this->assertEquals(700000, $results[0]['total']);
        $this->clearData();
    }