public function testPushWithPosition() { $expr = new Expr(); $innerExpr = new Expr(); $innerExpr->each(array(20, 30))->position(0); $expectedNewObj = array('$push' => array('a' => array('$each' => array(20, 30), '$position' => 0))); $this->assertSame($expr, $expr->field('a')->push($innerExpr)); $this->assertEquals($expectedNewObj, $expr->getNewObj()); }
public function testPushWithExpression() { $expr = new Expr(); $innerExpr = new Expr(); $innerExpr->each(array(array('x' => 1), array('x' => 2)))->slice(-2)->sort('x', 1); $expectedNewObj = array('$push' => array('a' => array('$each' => array(array('x' => 1), array('x' => 2)), '$slice' => -2, '$sort' => array('x' => 1)))); $this->assertSame($expr, $expr->field('a')->push($innerExpr)); $this->assertEquals($expectedNewObj, $expr->getNewObj()); }
public function testPushWithPosition() { $expr = new Expr(); $innerExpr = new Expr(); $innerExpr->each([20, 30])->position(0); $expectedNewObj = ['$push' => ['a' => ['$each' => [20, 30], '$position' => 0]]]; $this->assertSame($expr, $expr->field('a')->push($innerExpr)); $this->assertEquals($expectedNewObj, $expr->getNewObj()); }