|
|
@@ -600,6 +600,40 @@ class MongoCollectionTest extends TestCase
|
|
|
], $result['result']);
|
|
|
}
|
|
|
|
|
|
+ public function testAggregateWithMultiplePilelineOperatorsAsArguments()
|
|
|
+ {
|
|
|
+ $collection = $this->getCollection();
|
|
|
+
|
|
|
+ $this->prepareData();
|
|
|
+
|
|
|
+ try {
|
|
|
+ $result = $collection->aggregate(
|
|
|
+ [
|
|
|
+ '$group' => [
|
|
|
+ '_id' => '$foo',
|
|
|
+ 'count' => [ '$sum' => 1 ],
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ '$sort' => ['_id' => 1]
|
|
|
+ ]
|
|
|
+ );
|
|
|
+ } catch (\MongoResultException $ex) {
|
|
|
+ $msg = 'MongoCollection::aggregate ( array $op [, array $op [, array $... ]] ) should accept variable amount of pipeline operators as argument'
|
|
|
+ . "\n"
|
|
|
+ . $ex;
|
|
|
+ $this->fail($msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->assertInternalType('array', $result);
|
|
|
+ $this->assertArrayHasKey('result', $result);
|
|
|
+
|
|
|
+ $this->assertEquals([
|
|
|
+ ['_id' => 'bar', 'count' => 2],
|
|
|
+ ['_id' => 'foo', 'count' => 1],
|
|
|
+ ], $result['result']);
|
|
|
+ }
|
|
|
+
|
|
|
public function testAggregateInvalidPipeline()
|
|
|
{
|
|
|
$collection = $this->getCollection();
|