Permalink
Browse files

Query preparation tests for simple references

This was originally included in PR #261. It tests the fixes for #250, #283 and #284.
  • Loading branch information...
1 parent d2053a5 commit fc3128c80dac84ca7bfb8e29cae800350d678e53 @rtens rtens committed with jmikola May 17, 2012
Showing with 15 additions and 1 deletion.
  1. +15 −1 tests/Doctrine/ODM/MongoDB/Tests/Functional/SimpleReferencesTest.php
@@ -101,4 +101,18 @@ public function testOneInverseSide()
$test = $user->getSimpleReferenceOneInverse();
$this->assertEquals('test', $test->getName());
}
-}
+
+ public function testQueryForNonIds() {
+ $qb = $this->dm->createQueryBuilder('Documents\SimpleReferenceUser');
+ $qb->field('user')->equals(null);
+ $this->assertEquals(array('userId' => null), $qb->getQueryArray());
+
+ $qb = $this->dm->createQueryBuilder('Documents\SimpleReferenceUser');
+ $qb->field('user')->notEqual(null);
+ $this->assertEquals(array('userId' => array('$ne' => null)), $qb->getQueryArray());
+
+ $qb = $this->dm->createQueryBuilder('Documents\SimpleReferenceUser');
+ $qb->field('user')->exists(true);
+ $this->assertEquals(array('userId' => array('$exists' => true)), $qb->getQueryArray());
+ }
+}

0 comments on commit fc3128c

Please sign in to comment.