|
|
@ -114,9 +114,7 @@ class MongoDriverTest extends PHPUnit_Framework_TestCase |
|
|
|
*/ |
|
|
|
public function testFind() |
|
|
|
{ |
|
|
|
if (!defined('DEBUG')) { |
|
|
|
define('DEBUG', false); |
|
|
|
} |
|
|
|
Config::set('DEBUG', 0); |
|
|
|
|
|
|
|
$mongo = new MongoDriver($this->conf); |
|
|
|
$this->assertEquals(1, $mongo->find('items', array('name' => 'bread'))->numRows()); |
|
|
@ -145,9 +143,7 @@ class MongoDriverTest extends PHPUnit_Framework_TestCase |
|
|
|
*/ |
|
|
|
public function testOrderSkipLimit() |
|
|
|
{ |
|
|
|
if (!defined('DEBUG')) { |
|
|
|
define('DEBUG', false); |
|
|
|
} |
|
|
|
Config::set('DEBUG', 0); |
|
|
|
|
|
|
|
$mongo = new MongoDriver($this->conf); |
|
|
|
|
|
|
@ -184,9 +180,7 @@ class MongoDriverTest extends PHPUnit_Framework_TestCase |
|
|
|
*/ |
|
|
|
public function testCount() |
|
|
|
{ |
|
|
|
if (!defined('DEBUG')) { |
|
|
|
define('DEBUG', false); |
|
|
|
} |
|
|
|
Config::set('DEBUG', 0); |
|
|
|
$mongo = new MongoDriver($this->conf); |
|
|
|
$this->assertEquals(5, $mongo->count('items')); |
|
|
|
$this->assertEquals(2, $mongo->count('items', array('name' => 'eggs'))); |
|
|
@ -199,9 +193,7 @@ class MongoDriverTest extends PHPUnit_Framework_TestCase |
|
|
|
*/ |
|
|
|
public function testCursorCount() |
|
|
|
{ |
|
|
|
if (!defined('DEBUG')) { |
|
|
|
define('DEBUG', false); |
|
|
|
} |
|
|
|
Config::set('DEBUG', 0); |
|
|
|
$mongo = new MongoDriver($this->conf); |
|
|
|
$this->assertEquals(5, $mongo->find('items')->count(5)); |
|
|
|
$this->assertCount(3, $mongo->find('items')->limit(3)->fetchAll()); |
|
|
@ -214,9 +206,7 @@ class MongoDriverTest extends PHPUnit_Framework_TestCase |
|
|
|
*/ |
|
|
|
public function testGet() |
|
|
|
{ |
|
|
|
if (!defined('DEBUG')) { |
|
|
|
define('DEBUG', false); |
|
|
|
} |
|
|
|
Config::set('DEBUG', 0); |
|
|
|
|
|
|
|
$mongo = new MongoDriver($this->conf); |
|
|
|
$eggs = $mongo->get('items', array('name' => 'eggs'))->fetchObject(); |
|
|
@ -232,9 +222,7 @@ class MongoDriverTest extends PHPUnit_Framework_TestCase |
|
|
|
*/ |
|
|
|
public function testRemove() |
|
|
|
{ |
|
|
|
if (!defined('DEBUG')) { |
|
|
|
define('DEBUG', false); |
|
|
|
} |
|
|
|
Config::set('DEBUG', 0); |
|
|
|
|
|
|
|
$mongo = new MongoDriver($this->conf); |
|
|
|
$this->assertEquals(1, $mongo->find('items', array('name' => 'bread'))->numRows()); |
|
|
@ -250,9 +238,7 @@ class MongoDriverTest extends PHPUnit_Framework_TestCase |
|
|
|
*/ |
|
|
|
public function testInsert() |
|
|
|
{ |
|
|
|
if (!defined('DEBUG')) { |
|
|
|
define('DEBUG', false); |
|
|
|
} |
|
|
|
Config::set('DEBUG', 0); |
|
|
|
|
|
|
|
$mongo = new MongoDriver($this->conf); |
|
|
|
$this->assertEquals(1, $mongo->find('items', array('name' => 'bread'))->numRows()); |
|
|
@ -269,9 +255,7 @@ class MongoDriverTest extends PHPUnit_Framework_TestCase |
|
|
|
*/ |
|
|
|
public function testBatchInsert() |
|
|
|
{ |
|
|
|
if (!defined('DEBUG')) { |
|
|
|
define('DEBUG', false); |
|
|
|
} |
|
|
|
Config::set('DEBUG', 0); |
|
|
|
|
|
|
|
$data = array( |
|
|
|
array('name' => 'first object'), |
|
|
@ -292,9 +276,7 @@ class MongoDriverTest extends PHPUnit_Framework_TestCase |
|
|
|
*/ |
|
|
|
public function testGetInsertId() |
|
|
|
{ |
|
|
|
if (!defined('DEBUG')) { |
|
|
|
define('DEBUG', false); |
|
|
|
} |
|
|
|
Config::set('DEBUG', 0); |
|
|
|
|
|
|
|
$mongo = new MongoDriver($this->conf); |
|
|
|
$this->assertEquals(0, $mongo->getInsertId()); |
|
|
@ -316,9 +298,7 @@ class MongoDriverTest extends PHPUnit_Framework_TestCase |
|
|
|
*/ |
|
|
|
public function testUpdate() |
|
|
|
{ |
|
|
|
if (!defined('DEBUG')) { |
|
|
|
define('DEBUG', false); |
|
|
|
} |
|
|
|
Config::set('DEBUG', 0); |
|
|
|
|
|
|
|
$mongo = new MongoDriver($this->conf); |
|
|
|
$this->assertEquals(1, $mongo->find('items', array('name' => 'bread'))->numRows()); |
|
|
@ -336,9 +316,7 @@ class MongoDriverTest extends PHPUnit_Framework_TestCase |
|
|
|
*/ |
|
|
|
public function testUpsert() |
|
|
|
{ |
|
|
|
if (!defined('DEBUG')) { |
|
|
|
define('DEBUG', false); |
|
|
|
} |
|
|
|
Config::set('DEBUG', 0); |
|
|
|
|
|
|
|
$mongo = new MongoDriver($this->conf); |
|
|
|
|
|
|
@ -353,9 +331,7 @@ class MongoDriverTest extends PHPUnit_Framework_TestCase |
|
|
|
*/ |
|
|
|
public function testFindAndModify() |
|
|
|
{ |
|
|
|
if (!defined('DEBUG')) { |
|
|
|
define('DEBUG', false); |
|
|
|
} |
|
|
|
Config::set('DEBUG', 0); |
|
|
|
|
|
|
|
$mongo = new MongoDriver($this->conf); |
|
|
|
|
|
|
@ -371,9 +347,7 @@ class MongoDriverTest extends PHPUnit_Framework_TestCase |
|
|
|
*/ |
|
|
|
public function testFindAndModifyNoItem() |
|
|
|
{ |
|
|
|
if (!defined('DEBUG')) { |
|
|
|
define('DEBUG', false); |
|
|
|
} |
|
|
|
Config::set('DEBUG', 0); |
|
|
|
|
|
|
|
$mongo = new MongoDriver($this->conf); |
|
|
|
|
|
|
@ -389,9 +363,7 @@ class MongoDriverTest extends PHPUnit_Framework_TestCase |
|
|
|
*/ |
|
|
|
public function testEvalCommand() |
|
|
|
{ |
|
|
|
if (!defined('DEBUG')) { |
|
|
|
define('DEBUG', false); |
|
|
|
} |
|
|
|
Config::set('DEBUG', 0); |
|
|
|
$mongo = new MongoDriver($this->conf); |
|
|
|
$result = $mongo->command('items', array('$eval' => 'function() { return db.items.count();}')); |
|
|
|
$this->assertEquals(5, $result->fetch()); |
|
|
@ -406,9 +378,7 @@ class MongoDriverTest extends PHPUnit_Framework_TestCase |
|
|
|
*/ |
|
|
|
public function testEval() |
|
|
|
{ |
|
|
|
if (!defined('DEBUG')) { |
|
|
|
define('DEBUG', false); |
|
|
|
} |
|
|
|
Config::set('DEBUG', 0); |
|
|
|
$mongo = new MongoDriver($this->conf); |
|
|
|
$result = $mongo->command('items', array('$eval' => 'function() {return true; }')); |
|
|
|
$this->assertTrue($result->fetch()); |
|
|
@ -424,9 +394,7 @@ class MongoDriverTest extends PHPUnit_Framework_TestCase |
|
|
|
*/ |
|
|
|
public function testCommand() |
|
|
|
{ |
|
|
|
if (!defined('DEBUG')) { |
|
|
|
define('DEBUG', false); |
|
|
|
} |
|
|
|
Config::set('DEBUG', 0); |
|
|
|
$mongo = new MongoDriver($this->conf); |
|
|
|
$result = $mongo->command('items', array('distinct' => 'items', 'key' => 'name')); |
|
|
|
$this->assertEquals(4, count($result->fetch(DB::FETCH_ASSOC))); |
|
|
|