From 2879f07476bb8a81f5316c8ea95d0b536fdf97ea Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Fri, 4 Apr 2014 17:32:57 +0200 Subject: depend on oc6, bind correct types, fix #457 --- tests/unit/db/FeedMapperTest.php | 21 ++----------------- tests/unit/db/FolderMapperTest.php | 35 +++---------------------------- tests/unit/db/ItemMapperTest.php | 35 ++----------------------------- tests/unit/db/postgres/ItemMapperTest.php | 34 ++---------------------------- 4 files changed, 9 insertions(+), 116 deletions(-) (limited to 'tests/unit/db') diff --git a/tests/unit/db/FeedMapperTest.php b/tests/unit/db/FeedMapperTest.php index b7d095861..f347e9732 100644 --- a/tests/unit/db/FeedMapperTest.php +++ b/tests/unit/db/FeedMapperTest.php @@ -284,25 +284,8 @@ class FeedMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility { $pdoResult->expects($this->any()) ->method('fetchRow'); - $query = $this->getMock('Query', - array('execute')); - $query->expects($this->at(0)) - ->method('execute') - ->with($this->equalTo($arguments)) - ->will($this->returnValue($pdoResult)); - $this->api->expects($this->at(0)) - ->method('prepareQuery') - ->with($this->equalTo($sql)) - ->will(($this->returnValue($query))); - - $query->expects($this->at(1)) - ->method('execute') - ->with($this->equalTo($arguments2)) - ->will($this->returnValue($pdoResult)); - $this->api->expects($this->at(1)) - ->method('prepareQuery') - ->with($this->equalTo($sql2)) - ->will(($this->returnValue($query))); + $this->setMapperResult($sql, $arguments); + $this->setMapperResult($sql2, $arguments2); $this->mapper->delete($feed); diff --git a/tests/unit/db/FolderMapperTest.php b/tests/unit/db/FolderMapperTest.php index 989f7a339..0ca53ad81 100644 --- a/tests/unit/db/FolderMapperTest.php +++ b/tests/unit/db/FolderMapperTest.php @@ -151,38 +151,9 @@ class FolderMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility { '`items`.`feed_id` = `feeds`.`id` WHERE `feeds`.`id` IS NULL'; $arguments2 = array($folder->getId()); - $pdoResult = $this->getMock('Result', - array('fetchRow')); - $pdoResult->expects($this->any()) - ->method('fetchRow'); - - $query = $this->getMock('Query', - array('execute')); - $query->expects($this->at(0)) - ->method('execute') - ->with($this->equalTo($arguments)) - ->will($this->returnValue($pdoResult)); - $this->api->expects($this->at(0)) - ->method('prepareQuery') - ->with($this->equalTo($sql)) - ->will(($this->returnValue($query))); - - $query->expects($this->at(1)) - ->method('execute') - ->with($this->equalTo($arguments2)) - ->will($this->returnValue($pdoResult)); - $this->api->expects($this->at(1)) - ->method('prepareQuery') - ->with($this->equalTo($sql2)) - ->will(($this->returnValue($query))); - - $query->expects($this->at(2)) - ->method('execute') - ->will($this->returnValue($pdoResult)); - $this->api->expects($this->at(2)) - ->method('prepareQuery') - ->with($this->equalTo($sql3)) - ->will(($this->returnValue($query))); + $this->setMapperResult($sql, $arguments); + $this->setMapperResult($sql2, $arguments2); + $this->setMapperResult($sql3); $this->folderMapper->delete($folder); } diff --git a/tests/unit/db/ItemMapperTest.php b/tests/unit/db/ItemMapperTest.php index a2df2178a..a13f7d58d 100644 --- a/tests/unit/db/ItemMapperTest.php +++ b/tests/unit/db/ItemMapperTest.php @@ -368,39 +368,8 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility { 'ORDER BY `id` ASC'; $params2 = array($status, 30); - - $pdoResult = $this->getMock('Result', - array('fetchRow')); - - $pdoResult->expects($this->at(0)) - ->method('fetchRow') - ->will($this->returnValue($row)); - $pdoResult->expects($this->at(1)) - ->method('fetchRow') - ->will($this->returnValue(false)); - - $query = $this->getMock('Query', - array('execute')); - $query->expects($this->at(0)) - ->method('execute') - ->with($this->equalTo($params1)) - ->will($this->returnValue($pdoResult)); - - $this->api->expects($this->at(0)) - ->method('prepareQuery') - ->with($this->equalTo($sql1)) - ->will(($this->returnValue($query))); - - $query2 = $this->getMock('Query', - array('execute')); - $query2->expects($this->at(0)) - ->method('execute') - ->with($this->equalTo($params2)); - - $this->api->expects($this->at(1)) - ->method('prepareQuery') - ->with($this->equalTo($sql2), $this->equalTo(1)) - ->will($this->returnValue($query2)); + $this->setMapperResult($sql1, $params1, array($row)); + $this->setMapperResult($sql2, $params2); $result = $this->mapper->deleteReadOlderThanThreshold($threshold); } diff --git a/tests/unit/db/postgres/ItemMapperTest.php b/tests/unit/db/postgres/ItemMapperTest.php index 0dad0471a..1e3207387 100644 --- a/tests/unit/db/postgres/ItemMapperTest.php +++ b/tests/unit/db/postgres/ItemMapperTest.php @@ -157,38 +157,8 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility { $params2 = array($status, 30, 1); - $pdoResult = $this->getMock('Result', - array('fetchRow')); - - $pdoResult->expects($this->at(0)) - ->method('fetchRow') - ->will($this->returnValue($row)); - $pdoResult->expects($this->at(1)) - ->method('fetchRow') - ->will($this->returnValue(false)); - - $query = $this->getMock('Query', - array('execute')); - $query->expects($this->at(0)) - ->method('execute') - ->with($this->equalTo($params1)) - ->will($this->returnValue($pdoResult)); - - $this->api->expects($this->at(0)) - ->method('prepareQuery') - ->with($this->equalTo($sql1)) - ->will(($this->returnValue($query))); - - $query2 = $this->getMock('Query', - array('execute')); - $query2->expects($this->at(0)) - ->method('execute') - ->with($this->equalTo($params2)); - - $this->api->expects($this->at(1)) - ->method('prepareQuery') - ->with($this->equalTo($sql2)) - ->will($this->returnValue($query2)); + $this->setMapperResult($sql1, $params1, array($row)); + $this->setMapperResult($sql2, $params2); $result = $this->mapper->deleteReadOlderThanThreshold($threshold); } -- cgit v1.2.3