fixed ret value on eval
This commit is contained in:
@ -60,11 +60,10 @@ class MongoStatement extends DbStatement
|
|||||||
if (!$this->result) {
|
if (!$this->result) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (isset($this->result['retval'])) {
|
if (is_array($this->result) && isset($this->result['retval'])) {
|
||||||
return $this->result['retval'];
|
return $this->result['retval'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$row = false;
|
|
||||||
switch ($style) {
|
switch ($style) {
|
||||||
case Db::FETCH_OBJ:
|
case Db::FETCH_OBJ:
|
||||||
$row = $this->fetchObject();
|
$row = $this->fetchObject();
|
||||||
|
@ -329,23 +329,23 @@ class MongoDbCommandTest extends PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::COUNT, new CollectionMock());
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::COUNT, new CollectionMock());
|
||||||
$cmd->bindParam('condition', array());
|
$cmd->bindParam('condition', array());
|
||||||
$this->assertStringStartsWith('Collection: CollectionMock', $cmd->__toString());
|
$this->assertStringStartsWith("\n" . 'Collection: CollectionMock', $cmd->__toString());
|
||||||
|
|
||||||
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::FIND, new CollectionMock());
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::FIND, new CollectionMock());
|
||||||
$cmd->bindParam('condition', array());
|
$cmd->bindParam('condition', array());
|
||||||
$this->assertStringStartsWith('Collection: CollectionMock', $cmd->__toString());
|
$this->assertStringStartsWith("\n" . 'Collection: CollectionMock', $cmd->__toString());
|
||||||
|
|
||||||
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::COMMAND, new CollectionMock());
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::COMMAND, new CollectionMock());
|
||||||
$this->assertSame('Command properties not set', $cmd->__toString());
|
$this->assertSame('Command properties not set', $cmd->__toString());
|
||||||
$cmd->bindParam('command', array());
|
$cmd->bindParam('command', array());
|
||||||
$this->assertStringStartsWith('Collection: CollectionMock', $cmd->__toString());
|
$this->assertStringStartsWith("\n" . 'Collection: CollectionMock', $cmd->__toString());
|
||||||
|
|
||||||
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::INSERT, $this->collection);
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::INSERT, $this->collection);
|
||||||
$this->assertSame('Command properties not set', $cmd->__toString());
|
$this->assertSame('Command properties not set', $cmd->__toString());
|
||||||
$cmd
|
$cmd
|
||||||
->bindParam('data', array('name' => 'insert'))
|
->bindParam('data', array('name' => 'insert'))
|
||||||
->bindParam('safe', true);
|
->bindParam('safe', true);
|
||||||
$this->assertStringStartsWith('Collection: ', $cmd->__toString());
|
$this->assertStringStartsWith("\n" . 'Collection: ', $cmd->__toString());
|
||||||
$this->assertContains('Bulk insert: FALSE', $cmd->__toString());
|
$this->assertContains('Bulk insert: FALSE', $cmd->__toString());
|
||||||
|
|
||||||
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::INSERT, $this->collection);
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::INSERT, $this->collection);
|
||||||
@ -357,14 +357,14 @@ class MongoDbCommandTest extends PHPUnit_Framework_TestCase
|
|||||||
$this->assertContains('Bulk insert: TRUE', $cmd->__toString());
|
$this->assertContains('Bulk insert: TRUE', $cmd->__toString());
|
||||||
|
|
||||||
$cmd->bindParam('condition', array('name' => 'insert'))->bindParam('fields', array());
|
$cmd->bindParam('condition', array('name' => 'insert'))->bindParam('fields', array());
|
||||||
$this->assertStringStartsWith('Collection: ', $cmd->__toString());
|
$this->assertStringStartsWith("\n" . 'Collection: ', $cmd->__toString());
|
||||||
|
|
||||||
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::REMOVE, $this->collection);
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::REMOVE, $this->collection);
|
||||||
$this->assertSame('Command properties not set', $cmd->__toString());
|
$this->assertSame('Command properties not set', $cmd->__toString());
|
||||||
$cmd
|
$cmd
|
||||||
->bindParam('condition', array('name' => 'insert'))
|
->bindParam('condition', array('name' => 'insert'))
|
||||||
->bindParam('safe', true);
|
->bindParam('safe', true);
|
||||||
$this->assertStringStartsWith('Collection: ', $cmd->__toString());
|
$this->assertStringStartsWith("\n" . 'Collection: ', $cmd->__toString());
|
||||||
|
|
||||||
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::UPDATE, $this->collection);
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::UPDATE, $this->collection);
|
||||||
$this->assertSame('Command properties not set', $cmd->__toString());
|
$this->assertSame('Command properties not set', $cmd->__toString());
|
||||||
@ -373,7 +373,7 @@ class MongoDbCommandTest extends PHPUnit_Framework_TestCase
|
|||||||
->bindParam('data', array('$set' => array('name' => 'update')))
|
->bindParam('data', array('$set' => array('name' => 'update')))
|
||||||
->bindParam('upsert', false)
|
->bindParam('upsert', false)
|
||||||
->bindParam('safe', true);
|
->bindParam('safe', true);
|
||||||
$this->assertStringStartsWith('Collection: ', $cmd->__toString());
|
$this->assertStringStartsWith("\n" . 'Collection: ', $cmd->__toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -369,6 +369,24 @@ class MongoDriverTest extends PHPUnit_Framework_TestCase
|
|||||||
* @runInSeparateProcess
|
* @runInSeparateProcess
|
||||||
* @group Mongo
|
* @group Mongo
|
||||||
*/
|
*/
|
||||||
|
public function testEval()
|
||||||
|
{
|
||||||
|
if (!defined('DEBUG')) {
|
||||||
|
define('DEBUG', false);
|
||||||
|
}
|
||||||
|
$mongo = new MongoDriver($this->conf);
|
||||||
|
$result = $mongo->command('items', array('$eval' => 'function() {return true; }'));
|
||||||
|
$this->assertTrue($result->fetch());
|
||||||
|
$result = $mongo->command('items', array('$eval' => 'function() {return "Hello"; }'));
|
||||||
|
$this->assertSame('Hello', $result->fetch());
|
||||||
|
$result = $mongo->command('items', array('$eval' => 'function() {return db.items.count(); }'));
|
||||||
|
$this->assertEquals(5, $result->fetch());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @runInSeparateProcess
|
||||||
|
* @group Mongo
|
||||||
|
*/
|
||||||
public function testCommand()
|
public function testCommand()
|
||||||
{
|
{
|
||||||
if (!defined('DEBUG')) {
|
if (!defined('DEBUG')) {
|
||||||
|
Reference in New Issue
Block a user