|
|
@ -369,6 +369,41 @@ class MongoDriverTest extends PHPUnit_Framework_TestCase |
|
|
|
* @runInSeparateProcess |
|
|
|
* @group Mongo |
|
|
|
*/ |
|
|
|
public function testFindAndModifyNoItem() |
|
|
|
{ |
|
|
|
if (!defined('DEBUG')) { |
|
|
|
define('DEBUG', false); |
|
|
|
} |
|
|
|
|
|
|
|
$mongo = new MongoDriver($this->conf); |
|
|
|
|
|
|
|
$this->assertEquals(10, $mongo->get('items', array('name' => 'bread'))->fetch()->quantity); |
|
|
|
$result = $mongo->findAndModify('items', array('name' => 'breading'), array('$set' => array('quantity' => 20)))->fetch(); |
|
|
|
$this->assertFalse($result); |
|
|
|
$this->assertEquals(10, $mongo->get('items', array('name' => 'bread'))->fetch()->quantity); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @runInSeparateProcess |
|
|
|
* @group Mongo |
|
|
|
*/ |
|
|
|
public function testEvalCommand() |
|
|
|
{ |
|
|
|
if (!defined('DEBUG')) { |
|
|
|
define('DEBUG', false); |
|
|
|
} |
|
|
|
$mongo = new MongoDriver($this->conf); |
|
|
|
$result = $mongo->command('items', array('$eval' => 'function() { return db.items.count();}')); |
|
|
|
$this->assertEquals(5, $result->fetch()); |
|
|
|
$this->assertEquals(5, $mongo->count('items')); |
|
|
|
$result = $mongo->command('items', array('$eval' => 'function() { return "HELLO!";}')); |
|
|
|
$this->assertEquals("HELLO!", $result->fetch()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @runInSeparateProcess |
|
|
|
* @group Mongo |
|
|
|
*/ |
|
|
|
public function testEval() |
|
|
|
{ |
|
|
|
if (!defined('DEBUG')) { |
|
|
|