Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #174

  • Loading branch information...
commit e9dc1ea9b97c7986746bfe41af3ea60e2728d7bd 2 parents f57b098 + 2a5d5c4
@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));
}
/**
@@ -638,7 +638,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
@@ -395,4 +395,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.