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

Commit

Permalink
Test Builder::addNor() and fix documentation example
Browse files Browse the repository at this point in the history
  • Loading branch information
jmikola committed May 13, 2013
1 parent cc3652b commit dae5464
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/Doctrine/MongoDB/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,8 @@ public function addAnd($expression)
*
* $qb = $this->createQueryBuilder('User');
* $qb
* ->addNor($qb->expr()->field('first_name')->equals('Kris')->field('first_name')->equals('Chris'));
* ->addNor($qb->expr()->field('first_name')->equals('Kris'))
* ->addNor($qb->expr()->field('first_name')->equals('Chris'));
*
* @param array|QueryBuilder $expression
* @return Query
Expand Down
14 changes: 14 additions & 0 deletions tests/Doctrine/MongoDB/Tests/Query/BuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,20 @@ public function testThatAndAcceptsAnotherQuery()
), $qb->getQueryArray());
}

public function testThatNorAcceptsAnotherQuery()
{
$coll = $this->conn->selectCollection('db', 'users');

$qb = $coll->createQueryBuilder();
$qb->addNor($qb->expr()->field('firstName')->equals('Kris'));
$qb->addNor($qb->expr()->field('firstName')->equals('Chris'));

$this->assertEquals(array('$nor' => array(
array('firstName' => 'Kris'),
array('firstName' => 'Chris')
)), $qb->getQueryArray());
}

public function testAddElemMatch()
{
$qb = $this->getTestQueryBuilder();
Expand Down

0 comments on commit dae5464

Please sign in to comment.