Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch '1.1.x'

  • Loading branch information...
commit f8deed92fe4519c07a57c6d49779d4d05a980286 2 parents f0574f7 + e9dc1ea
@jmikola jmikola authored
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());
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.