From 2bfa9f22b7d97dcdbda5992ad603d9d10482b49f Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Wed, 14 May 2014 01:04:57 +0200 Subject: fix unittests --- tests/unit/db/FeedMapperTest.php | 12 ++++++------ tests/unit/db/FolderMapperTest.php | 8 ++++---- tests/unit/db/ItemMapperTest.php | 9 ++++----- tests/unit/db/ItemTest.php | 20 +++++++++++++------- tests/unit/db/MapperFactoryTest.php | 2 +- tests/unit/db/postgres/ItemMapperTest.php | 7 +++---- 6 files changed, 31 insertions(+), 27 deletions(-) (limited to 'tests/unit/db') diff --git a/tests/unit/db/FeedMapperTest.php b/tests/unit/db/FeedMapperTest.php index 5c2921063..607255fde 100644 --- a/tests/unit/db/FeedMapperTest.php +++ b/tests/unit/db/FeedMapperTest.php @@ -16,13 +16,13 @@ namespace OCA\News\Db; require_once(__DIR__ . "/../../classloader.php"); -class FeedMapperTest extends \OCA\News\Utility\MapperTestUtility { +class FeedMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { private $mapper; private $feeds; protected function setUp(){ - $this->beforeEach(); + parent::setUp(); $this->mapper = new FeedMapper($this->db); @@ -83,7 +83,7 @@ class FeedMapperTest extends \OCA\News\Utility\MapperTestUtility { $params = array($id, $userId); $this->setMapperResult($sql, $params); - $this->setExpectedException('\OCA\News\Db\DoesNotExistException'); + $this->setExpectedException('\OCP\AppFramework\Db\DoesNotExistException'); $this->mapper->find($id, $userId); } @@ -110,7 +110,7 @@ class FeedMapperTest extends \OCA\News\Utility\MapperTestUtility { $params = array($id, $userId); $this->setMapperResult($sql, $params, $rows); - $this->setExpectedException('\OCA\News\Db\MultipleObjectsReturnedException'); + $this->setExpectedException('\OCP\AppFramework\Db\MultipleObjectsReturnedException'); $this->mapper->find($id, $userId); } @@ -225,7 +225,7 @@ class FeedMapperTest extends \OCA\News\Utility\MapperTestUtility { $this->setMapperResult($sql, array($urlHash, $this->user)); - $this->setExpectedException('\OCA\News\Db\DoesNotExistException'); + $this->setExpectedException('\OCP\AppFramework\Db\DoesNotExistException'); $this->mapper->findByUrlHash($urlHash, $this->user); } @@ -251,7 +251,7 @@ class FeedMapperTest extends \OCA\News\Utility\MapperTestUtility { $this->setMapperResult($sql, array($urlHash, $this->user), $rows); - $this->setExpectedException('\OCA\News\Db\MultipleObjectsReturnedException'); + $this->setExpectedException('\OCP\AppFramework\Db\MultipleObjectsReturnedException'); $this->mapper->findByUrlHash($urlHash, $this->user); } diff --git a/tests/unit/db/FolderMapperTest.php b/tests/unit/db/FolderMapperTest.php index c979f8ce0..359d63894 100644 --- a/tests/unit/db/FolderMapperTest.php +++ b/tests/unit/db/FolderMapperTest.php @@ -16,14 +16,14 @@ namespace OCA\News\Db; require_once(__DIR__ . "/../../classloader.php"); -class FolderMapperTest extends \OCA\News\Utility\MapperTestUtility { +class FolderMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { private $folderMapper; private $folders; private $user; protected function setUp(){ - $this->beforeEach(); + parent::setUp(); $this->folderMapper = new FolderMapper($this->db); @@ -66,7 +66,7 @@ class FolderMapperTest extends \OCA\News\Utility\MapperTestUtility { $this->setMapperResult($sql, array($id, $userId)); - $this->setExpectedException('\OCA\News\Db\DoesNotExistException'); + $this->setExpectedException('\OCP\AppFramework\Db\DoesNotExistException'); $this->folderMapper->find($id, $userId); } @@ -84,7 +84,7 @@ class FolderMapperTest extends \OCA\News\Utility\MapperTestUtility { $this->setMapperResult($sql, array($id, $userId), $rows); - $this->setExpectedException('\OCA\News\Db\MultipleObjectsReturnedException'); + $this->setExpectedException('\OCP\AppFramework\Db\MultipleObjectsReturnedException'); $this->folderMapper->find($id, $userId); } diff --git a/tests/unit/db/ItemMapperTest.php b/tests/unit/db/ItemMapperTest.php index d9d6bf02c..b0a64a16d 100644 --- a/tests/unit/db/ItemMapperTest.php +++ b/tests/unit/db/ItemMapperTest.php @@ -16,7 +16,7 @@ namespace OCA\News\Db; require_once(__DIR__ . "/../../classloader.php"); -class ItemMapperTest extends \OCA\News\Utility\MapperTestUtility { +class ItemMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { private $mapper; private $items; @@ -28,9 +28,8 @@ class ItemMapperTest extends \OCA\News\Utility\MapperTestUtility { private $status; - public function setUp() - { - $this->beforeEach(); + public function setUp() { + parent::setUp(); $this->mapper = new ItemMapper($this->db); @@ -387,7 +386,7 @@ class ItemMapperTest extends \OCA\News\Utility\MapperTestUtility { $rows = array(); $this->setMapperResult($sql, $params, $rows); - $this->setExpectedException('\OCA\News\Db\DoesNotExistException'); + $this->setExpectedException('\OCP\AppFramework\Db\DoesNotExistException'); $this->mapper->getNewestItemId($this->user); } diff --git a/tests/unit/db/ItemTest.php b/tests/unit/db/ItemTest.php index b979450aa..2da81cda0 100644 --- a/tests/unit/db/ItemTest.php +++ b/tests/unit/db/ItemTest.php @@ -141,18 +141,24 @@ class ItemTest extends \PHPUnit_Framework_TestCase { $item->setBody('body'); $item->setEnclosureMime('audio/ogg'); $item->setEnclosureLink('enclink'); - $item->setFeedId(1); $item->setUnread(); $item->setStarred(); - $feed = new Feed(); - $feed->setLink('http://test'); - $feeds = array( - "feed1" => $feed + $import = array( + 'guid' => $item->getGuid(), + 'url' => $item->getUrl(), + 'title' => $item->getTitle(), + 'author' => $item->getAuthor(), + 'pubDate' => $item->getPubDate(), + 'body' => $item->getBody(), + 'enclosureMime' => $item->getEnclosureMime(), + 'enclosureLink' => $item->getEnclosureLink(), + 'unread' => $item->isUnread(), + 'starred' => $item->isStarred(), ); - $compareWith = Item::fromImport($item->toExport($feeds)); - $item->setFeedId(null); + $compareWith = Item::fromImport($import); + $this->assertEquals($item, $compareWith); } diff --git a/tests/unit/db/MapperFactoryTest.php b/tests/unit/db/MapperFactoryTest.php index 2f0e86be4..c1acd0dbc 100644 --- a/tests/unit/db/MapperFactoryTest.php +++ b/tests/unit/db/MapperFactoryTest.php @@ -23,7 +23,7 @@ class MapperFactoryTest extends \PHPUnit_Framework_TestCase { private $settings; public function setUp() { - $this->db = $this->getMockBuilder('\OCA\News\Core\Db') + $this->db = $this->getMockBuilder('\OCP\IDb') ->disableOriginalConstructor() ->getMock(); } diff --git a/tests/unit/db/postgres/ItemMapperTest.php b/tests/unit/db/postgres/ItemMapperTest.php index 1bc298566..24a0e8e25 100644 --- a/tests/unit/db/postgres/ItemMapperTest.php +++ b/tests/unit/db/postgres/ItemMapperTest.php @@ -20,7 +20,7 @@ use \OCA\News\Db\StatusFlag; require_once(__DIR__ . "/../../../classloader.php"); -class ItemMapperTest extends \OCA\News\Utility\MapperTestUtility { +class ItemMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { private $mapper; private $items; @@ -32,9 +32,8 @@ class ItemMapperTest extends \OCA\News\Utility\MapperTestUtility { private $status; - public function setUp() - { - $this->beforeEach(); + public function setUp() { + parent::setUp(); $this->mapper = new ItemMapper($this->db); -- cgit v1.2.3