Example #1
0
 /**
  * @link https://docs.mongodb.com/manual/reference/operator/query/and/#and-queries-with-multiple-expressions-specifying-the-same-operator
  */
 public function testTwoWhereOr()
 {
     $firstExpression = $this->collection->expression()->where('field', 1);
     $secondExpression = $this->collection->expression()->where('field', 2);
     $thirdExpression = $this->collection->expression()->where('field2', 3);
     $fourthExpression = $this->collection->expression()->where('field2', 4);
     $expression = $this->collection->expression()->whereAnd($this->collection->expression()->whereOr($firstExpression, $secondExpression), $this->collection->expression()->whereOr($thirdExpression, $fourthExpression));
     $this->assertEquals(array('$and' => array(array('$or' => array(array('field' => 1), array('field' => 2))), array('$or' => array(array('field2' => 3), array('field2' => 4))))), $expression->toArray());
 }