Skip to content
This repository has been archived by the owner on Nov 11, 2020. It is now read-only.

Commit

Permalink
Merge pull request #174
Browse files Browse the repository at this point in the history
  • Loading branch information
jmikola committed Apr 18, 2014
2 parents f57b098 + 2a5d5c4 commit e9dc1ea
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Doctrine/MongoDB/Query/Expr.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/**
Expand Down Expand Up @@ -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));
}

/**
Expand Down
32 changes: 32 additions & 0 deletions tests/Doctrine/MongoDB/Tests/Query/ExprTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

0 comments on commit e9dc1ea

Please sign in to comment.