public function testReferencesWithFindAndReferences() { try { $c = new Model1(); $c->where('int <= ', 1000); $c->where('processing exists', FALSE); $c->limit(50); $c->sort('int DESC'); $c->findAndModify(array("processing" => TRUE)); $invalid_ref = $c->getReference(TRUE); $this->assertTrue(FALSE); } catch (ActiveMongo_Exception $e) { $this->assertTrue(TRUE); } }
function testQuery() { $c = new Model1(); /* rand values */ $val1 = rand(1, 50); $val2 = rand(1, 50); $val3 = rand(1, 50); $val4 = rand(1, 50); $val5 = rand(1, 50); /* prepare the query */ $c->properties('a,b')->where('a >', $val1)->where('b <', $val2)->where('c !=', $val3); $c->where('h regexp', '/[a-f0-9]+/'); $c->where('x in', array(1, 2)); $c->where('x nin', array(4)); $c->where('y ==', array(4)); $c->where('f exists'); $c->where('f !=', array(5, 6)); $c->where(array("bar exists", "a exists")); $c->where('xxx ==', 5); $c->where('bar >=', 5); $c->sort('c DESC, a ASC')->limit($val4, $val5); /* perform it */ $c->doQuery(); /* Get cursor info */ $sQuery = $c->getReference(TRUE); /* expected cursor info */ $eQuery = array('ns' => DB . '.model1', 'limit' => $val4, 'skip' => $val5, 'query' => array('$query' => array('a' => array('$gt' => $val1, '$exists' => 1), 'b' => array('$lt' => $val2), 'c' => array('$ne' => $val3), 'h' => new MongoRegex('/[a-f0-9]+/'), 'x' => array('$in' => array(1, 2), '$nin' => array(4)), 'y' => array('$all' => array(4)), 'f' => array('$exists' => 1, '$nin' => array(5, 6)), 'xxx' => 5, 'bar' => array('$exists' => 1, '$gte' => 5)), '$orderby' => array('c' => -1, 'a' => 1)), 'fields' => array('a' => 1, 'b' => 1, '_id' => 1)); $this->assertEquals($sQuery['dynamic'], $eQuery); }