added Order, Limit, Skip methods to MongoStatement
This commit is contained in:
@ -271,7 +271,84 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase
|
||||
->will($this->returnValue(array('some' => 'val')));
|
||||
|
||||
$this->stmt->execute();
|
||||
$result = $this->stmt->fetch(222);
|
||||
$this->stmt->fetch(222);
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
public function testSkipOrderLimit()
|
||||
{
|
||||
if (!defined('DEBUG')) {
|
||||
define('DEBUG', true);
|
||||
}
|
||||
$this->setDriverGetConnectionMethod()->setRequestForFetch();
|
||||
|
||||
$this->stmt->execute();
|
||||
$this->assertInstanceOf('MongoStatement', $this->stmt->order(array('id' => 1)));
|
||||
|
||||
$this->stmt->fetch();
|
||||
$this->stmt->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage MongoStatement error. Impossible order results of opened cursor
|
||||
*/
|
||||
public function testOrderException()
|
||||
{
|
||||
if (!defined('DEBUG')) {
|
||||
define('DEBUG', true);
|
||||
}
|
||||
$this->setDriverGetConnectionMethod();
|
||||
$this->request
|
||||
->expects($this->once())
|
||||
->method('execute')
|
||||
->will($this->returnValue(array('some' => 'val')));
|
||||
|
||||
$this->stmt->execute();
|
||||
$this->stmt->order(array('id' => 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage MongoStatement error. Impossible skip results of opened cursor
|
||||
*/
|
||||
public function testSkipException()
|
||||
{
|
||||
if (!defined('DEBUG')) {
|
||||
define('DEBUG', true);
|
||||
}
|
||||
$this->setDriverGetConnectionMethod();
|
||||
$this->request
|
||||
->expects($this->once())
|
||||
->method('execute')
|
||||
->will($this->returnValue(array('some' => 'val')));
|
||||
|
||||
$this->stmt->execute();
|
||||
$this->stmt->skip(array('id' => 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage MongoStatement error. Impossible limit results of opened cursor
|
||||
*/
|
||||
public function testLimitException()
|
||||
{
|
||||
if (!defined('DEBUG')) {
|
||||
define('DEBUG', true);
|
||||
}
|
||||
$this->setDriverGetConnectionMethod();
|
||||
$this->request
|
||||
->expects($this->once())
|
||||
->method('execute')
|
||||
->will($this->returnValue(array('some' => 'val')));
|
||||
|
||||
$this->stmt->execute();
|
||||
$this->stmt->limit(array('id' => 1));
|
||||
}
|
||||
|
||||
private function setDriverGetConnectionMethod()
|
||||
@ -308,12 +385,21 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase
|
||||
public function setRequestForFetch()
|
||||
{
|
||||
$resultMock = $this->getMockBuilder('MongoCursor')
|
||||
->setMethods(array('count', 'getNext'))
|
||||
->setMethods(array('count', 'getNext', 'limit', 'sort', 'skip'))
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$resultMock
|
||||
->expects($this->any())
|
||||
->method('limit');
|
||||
$resultMock
|
||||
->expects($this->any())
|
||||
->method('sort');
|
||||
$resultMock
|
||||
->expects($this->any())
|
||||
->method('skip');
|
||||
$resultMock
|
||||
->expects($this->any())
|
||||
->method('count')
|
||||
->will($this->returnValue(10));
|
||||
$resultMock
|
||||
|
Reference in New Issue
Block a user