Permalink
Browse files

Merge branch '1.1.x'

  • Loading branch information...
2 parents f0574f7 + e9dc1ea commit f8deed92fe4519c07a57c6d49779d4d05a980286 @jmikola jmikola committed Apr 18, 2014
Showing with 34 additions and 2 deletions.
  1. +2 −2 lib/Doctrine/MongoDB/Query/Expr.php
  2. +32 −0 tests/Doctrine/MongoDB/Tests/Query/ExprTest.php
View
4 lib/Doctrine/MongoDB/Query/Expr.php
@@ -453,7 +453,7 @@ public function gte($value)
*/
public function in(array $values)
{
- return $this->operator('$in', $values);
+ return $this->operator('$in', array_values($values));
}
/**
@@ -675,7 +675,7 @@ public function notEqual($value)
*/
public function notIn(array $values)
{
- return $this->operator('$nin', $values);
+ return $this->operator('$nin', array_values($values));
}
/**
View
32 tests/Doctrine/MongoDB/Tests/Query/ExprTest.php
@@ -445,4 +445,36 @@ private function getMockPolygon($json)
return $point;
}
+
+ public function testIn()
+ {
+ $expr = new Expr();
+
+ $this->assertSame($expr, $expr->in(array('value1', 'value2')));
+ $this->assertEquals(array('$in' => array('value1', 'value2')), $expr->getQuery());
+ }
+
+ public function testInWillStripKeysToYieldBsonArray()
+ {
+ $expr = new Expr();
+
+ $this->assertSame($expr, $expr->in(array(1 => 'value1', 'some' => 'value2')));
+ $this->assertEquals(array('$in' => array('value1', 'value2')), $expr->getQuery());
+ }
+
+ public function testNotIn()
+ {
+ $expr = new Expr();
+
+ $this->assertSame($expr, $expr->notIn(array('value1', 'value2')));
+ $this->assertEquals(array('$nin' => array('value1', 'value2')), $expr->getQuery());
+ }
+
+ public function testNotInWillStripKeysToYieldBsonArray()
+ {
+ $expr = new Expr();
+
+ $this->assertSame($expr, $expr->notIn(array(1 => 'value1', 'some' => 'value2')));
+ $this->assertEquals(array('$nin' => array('value1', 'value2')), $expr->getQuery());
+ }
}

0 comments on commit f8deed9

Please sign in to comment.