If sorting by multiple fields, the first argument should be an array of
field name (key) and order (value) pairs.
This is useful in conjunction with {@link Expr::each()} for a
{@link Expr::push()} operation. {@link Builder::sort()} should be used to
sort the results of a query.
public function testPushWithExpressionShouldEnsureEachOperatorAppearsFirst() { $expr = new Expr(); $innerExpr = new Expr(); $innerExpr->sort('x', 1)->slice(-2)->each(array(array('x' => 1), array('x' => 2))); $expectedNewObj = array('$push' => array('a' => array('$each' => array(array('x' => 1), array('x' => 2)), '$sort' => array('x' => 1), '$slice' => -2))); $this->assertSame($expr, $expr->field('a')->push($innerExpr)); $this->assertSame($expectedNewObj, $expr->getNewObj()); }