summaryrefslogtreecommitdiffstats
path: root/tests/lib/appframework
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2015-01-29 19:23:57 +0100
committerBernhard Posselt <dev@bernhard-posselt.com>2015-01-29 19:23:57 +0100
commit983563d7d94429778a7e43596018ce514b60250c (patch)
treec3554f8d8fe8ef067f11c0c990efd8ed983bb22e /tests/lib/appframework
parent37e8969d347b4a277a0a9c5bb963ff9f2ec1b6ae (diff)
downloadnextcloud-server-983563d7d94429778a7e43596018ce514b60250c.tar.gz
nextcloud-server-983563d7d94429778a7e43596018ce514b60250c.zip
add tests for closing the cursor
Diffstat (limited to 'tests/lib/appframework')
-rw-r--r--tests/lib/appframework/db/mappertest.php14
-rw-r--r--tests/lib/appframework/db/mappertestutility.php12
2 files changed, 16 insertions, 10 deletions
diff --git a/tests/lib/appframework/db/mappertest.php b/tests/lib/appframework/db/mappertest.php
index 6ad8cd86bff..9cbc01883e3 100644
--- a/tests/lib/appframework/db/mappertest.php
+++ b/tests/lib/appframework/db/mappertest.php
@@ -74,7 +74,7 @@ class MapperTest extends MapperTestUtility {
$rows = array(
array('hi')
);
- $this->setMapperResult($sql, $params, $rows);
+ $this->setMapperResult($sql, $params, $rows);
$this->mapper->find($sql, $params);
}
@@ -84,7 +84,7 @@ class MapperTest extends MapperTestUtility {
$rows = array(
array('pre_name' => 'hi')
);
- $this->setMapperResult($sql, $params, $rows);
+ $this->setMapperResult($sql, $params, $rows, null, null, true);
$this->mapper->findOneEntity($sql, $params);
}
@@ -92,7 +92,7 @@ class MapperTest extends MapperTestUtility {
$sql = 'hi';
$params = array('jo');
$rows = array();
- $this->setMapperResult($sql, $params, $rows);
+ $this->setMapperResult($sql, $params, $rows);
$this->setExpectedException(
'\OCP\AppFramework\Db\DoesNotExistException');
$this->mapper->find($sql, $params);
@@ -102,7 +102,7 @@ class MapperTest extends MapperTestUtility {
$sql = 'hi';
$params = array('jo');
$rows = array();
- $this->setMapperResult($sql, $params, $rows);
+ $this->setMapperResult($sql, $params, $rows, null, null, true);
$this->setExpectedException(
'\OCP\AppFramework\Db\DoesNotExistException');
$this->mapper->findOneEntity($sql, $params);
@@ -114,7 +114,7 @@ class MapperTest extends MapperTestUtility {
$rows = array(
array('jo'), array('ho')
);
- $this->setMapperResult($sql, $params, $rows);
+ $this->setMapperResult($sql, $params, $rows, null, null, true);
$this->setExpectedException(
'\OCP\AppFramework\Db\MultipleObjectsReturnedException');
$this->mapper->find($sql, $params);
@@ -126,7 +126,7 @@ class MapperTest extends MapperTestUtility {
$rows = array(
array('jo'), array('ho')
);
- $this->setMapperResult($sql, $params, $rows);
+ $this->setMapperResult($sql, $params, $rows, null, null, true);
$this->setExpectedException(
'\OCP\AppFramework\Db\MultipleObjectsReturnedException');
$this->mapper->findOneEntity($sql, $params);
@@ -249,7 +249,7 @@ class MapperTest extends MapperTestUtility {
$entity = new Example();
$entity->setPreName('hi');
$entity->resetUpdatedFields();
- $this->setMapperResult($sql, array(), $rows);
+ $this->setMapperResult($sql, array(), $rows, null, null, true);
$result = $this->mapper->findAllEntities($sql);
$this->assertEquals(array($entity), $result);
}
diff --git a/tests/lib/appframework/db/mappertestutility.php b/tests/lib/appframework/db/mappertestutility.php
index 3508286137d..2a2bb1ab500 100644
--- a/tests/lib/appframework/db/mappertestutility.php
+++ b/tests/lib/appframework/db/mappertestutility.php
@@ -69,7 +69,7 @@ abstract class MapperTestUtility extends \Test\TestCase {
* will be called on the result
*/
protected function setMapperResult($sql, $arguments=array(), $returnRows=array(),
- $limit=null, $offset=null){
+ $limit=null, $offset=null, $expectClose=false){
$this->iterators[] = new ArgumentIterator($returnRows);
@@ -90,8 +90,14 @@ abstract class MapperTestUtility extends \Test\TestCase {
return $result;
}
));
- $this->pdoResult->expects($this->any())
- ->method('closeCursor');
+ if ($expectClose) {
+ $closing = $this->once();
+ } else {
+ $closing = $this->any();
+ }
+ $this->pdoResult->expects($closing)
+ ->method('closeCursor');
+
$index = 1;
foreach($arguments as $argument) {
switch (gettype($argument)) {