Пример #1
0
 public function testAggregate()
 {
     $pipeline = [['$match' => ['status' => 'A']], ['$group' => ['_id' => '$cust_id', 'total' => ['$sum' => 'amount']]]];
     $result = [['_id' => 'a1', 'total' => 321], ['_id' => 'a2', 'total' => 87]];
     $collection = $this->getMockBuilder('\\MongoDB\\Collection')->disableOriginalConstructor()->getMock();
     $collection->expects($this->once())->method('aggregate')->with($pipeline)->will($this->returnValue($result));
     $repository = new RepositoryMock($this->mandango);
     $repository->setCollection($collection);
     $repository->aggregate($pipeline);
 }