diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-03-19 19:49:25 +0100 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-03-19 19:49:25 +0100 |
commit | 966af078df176fc96d1e37696d4725115ad9639f (patch) | |
tree | 1f98e44ab2a5e991252cf0c82a5973451803ce46 | |
parent | 4e077697a1fd0cf15a6eac22cb6e3d6ec4b10ff2 (diff) |
added mapper spec
-rw-r--r-- | doc/mapper spec.md | 24 | ||||
-rw-r--r-- | tests/db/ItemMapperTest.php | 26 |
2 files changed, 28 insertions, 22 deletions
diff --git a/doc/mapper spec.md b/doc/mapper spec.md new file mode 100644 index 000000000..0b82354e2 --- /dev/null +++ b/doc/mapper spec.md @@ -0,0 +1,24 @@ + +update($item) +delete($item) +findAllFromUser($userId) +find(int $feedId, $userId) +create($item) +findAllFromFeedWithStatus($status, $feedId, $userId); + +foldermapper + +find($feedId, $userId) +update($folder) +delete($folder) +create($folder) + +feedmapper + +find($feedId, $userId) +update($folder) +delete($folder) +create($folder) +findAll() +findAllFromUser($userId) + diff --git a/tests/db/ItemMapperTest.php b/tests/db/ItemMapperTest.php index d5068d1f8..ab7cfa043 100644 --- a/tests/db/ItemMapperTest.php +++ b/tests/db/ItemMapperTest.php @@ -28,16 +28,14 @@ namespace OCA\News\Db; require_once(__DIR__ . "/../classloader.php"); -class Test extends \PHPUnit_Framework_TestCase { +class Test extends \OCA\AppFramework\Utility\MapperTestUtility { private $itemMapper; - private $api; private $items; protected function setUp(){ - $this->api = $this->getMock('\OCA\AppFramework\Core\API', - array('prepareQuery'), - array('a')); + $this->beforeEach(); + $this->itemMapper = new ItemMapper($this->api); // create mock items @@ -65,23 +63,7 @@ class Test extends \PHPUnit_Framework_TestCase { WHERE user_id = ? AND feed_id = ?'; - $pdoResult = $this->getMock('Result', - array('fetchRow')); - $pdoResult->expects($this->once()) - ->method('fetchRow') - ->will($this->returnValue($rows)); - - $query = $this->getMock('Query', - array('execute')); - $query->expects($this->once()) - ->method('execute') - ->with($this->equalTo(array($feedId, $userId))) - ->will($this->returnValue($pdoResult)); - - $this->api->expects($this->once()) - ->method('prepareQuery') - ->with($this->equalTo($sql)) - ->will(($this->returnValue($query))); + $this->setMapperResult($sql, array($feedId, $userId), $rows); $result = $this->itemMapper->findAllFromFeed($feedId, $userId); |