From dcf96e729991764e5dc5d5d9cc384540427dfdc4 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Thu, 6 Nov 2014 14:45:14 +0100 Subject: more integration tests --- tests/integration/bootstrap.php | 8 +-- tests/integration/db/ItemMapperTest.php | 36 ++++++++++ tests/integration/fixtures/feeds.json | 4 +- tests/integration/fixtures/items.json | 117 +++++++++++++++++++++++++++++++- 4 files changed, 156 insertions(+), 9 deletions(-) (limited to 'tests') diff --git a/tests/integration/bootstrap.php b/tests/integration/bootstrap.php index 8096cbacd..815913e3a 100644 --- a/tests/integration/bootstrap.php +++ b/tests/integration/bootstrap.php @@ -78,7 +78,7 @@ class NewsIntegrationTest extends \PHPUnit_Framework_TestCase { if (array_key_exists($feed['title'], $items)) { foreach ($items[$feed['title']] as $item) { $item['feedId'] = $newFeed->getId(); - $this->items[$item->getTitle()] = + $this->items[$item['title']] = $this->createItem($item); } } @@ -95,7 +95,7 @@ class NewsIntegrationTest extends \PHPUnit_Framework_TestCase { if (array_key_exists($feed['title'], $items)) { foreach ($items[$feed['title']] as $item) { $item['feedId'] = $newFeed->getId(); - $this->items[$item->getTitle()] = + $this->items[$item['title']] = $this->createItem($item); } } @@ -147,13 +147,13 @@ class NewsIntegrationTest extends \PHPUnit_Framework_TestCase { $newItem->setLastModified($item['lastModified']); $newItem->setEnclosureMime($item['enclosureMime']); $newItem->setEnclosureLink($item['enclosureLink']); - return $this->itemMapper->insert($item); + return $this->itemMapper->insert($newItem); } protected function whenOlderThan($olderThan, $callback) { $ocVersion = $this->ownCloudVersion; - if (version_compare(implode('.', $ocVersion), $olderThan, '<=')) { + if (version_compare(implode('.', $ocVersion), $olderThan, '<')) { $callback(); } } diff --git a/tests/integration/db/ItemMapperTest.php b/tests/integration/db/ItemMapperTest.php index dcc27ab98..c86112d46 100644 --- a/tests/integration/db/ItemMapperTest.php +++ b/tests/integration/db/ItemMapperTest.php @@ -28,4 +28,40 @@ class ItemMapperTest extends NewsIntegrationTest { $this->assertEquals('Döner', $fetched->getBody()); } + + /** + * @expectedException OCP\AppFramework\Db\DoesNotExistException + */ + public function testFindNotFoundWhenDeletedFeed() { + $id = $this->items['not found feed']->getId(); + $this->itemMapper->find($id, $this->userId); + } + + + /** + * @expectedException OCP\AppFramework\Db\DoesNotExistException + */ + public function testFindNotFoundWhenDeletedFolder() { + $id = $this->items['not found folder']->getId(); + $this->itemMapper->find($id, $this->userId); + } + + + public function testDeleteOlderThanThreshold() { + $this->itemMapper->deleteReadOlderThanThreshold(1); + $item1 = $this->items['del1']; + $item2 = $this->items['del2']; + $item3 = $this->items['del3']; + $item4 = $this->items['del4']; + + $this->itemMapper->find($item3->getId(), $this->userId); + $this->itemMapper->find($item4->getId(), $this->userId); + + //$this->setExpectedException( + // 'OCP\AppFramework\Db\DoesNotExistException'); + $this->itemMapper->find($item1->getId(), $this->userId); + $this->itemMapper->find($item2->getId(), $this->userId); + } + + } \ No newline at end of file diff --git a/tests/integration/fixtures/feeds.json b/tests/integration/fixtures/feeds.json index c3848bd78..b1696a9eb 100644 --- a/tests/integration/fixtures/feeds.json +++ b/tests/integration/fixtures/feeds.json @@ -10,7 +10,7 @@ "added": 3000, "link": "http://feed.com/rss", "preventUpdate": false, - "articlesPerUpdate": 40, + "articlesPerUpdate": 1, "lastModified": "", "etag": "" }, @@ -44,7 +44,7 @@ "etag": "" }, { - "title": "fifth feed", + "title": "sixth feed", "url": "http://gremlins.de", "deletedAt": 999999999, "location": "http://feed.com/rss", diff --git a/tests/integration/fixtures/items.json b/tests/integration/fixtures/items.json index 56c70edbe..780796afe 100644 --- a/tests/integration/fixtures/items.json +++ b/tests/integration/fixtures/items.json @@ -1,5 +1,116 @@ { - "first feed": [ - - ] + "first feed": [ + { + "status": 2, + "body": "this is a body", + "title": "a title1", + "author": "my author", + "guid": "abc", + "url": "http://google.de", + "pubDate": 2323, + "lastModified": 113, + "enclosureMime": "video/mpeg", + "enclosureLink": "http://google.de/web.webm" + }, + { + "status": 0, + "body": "this is a body", + "title": "del1", + "author": "my author", + "guid": "del1", + "url": "http://google.de", + "pubDate": 2323, + "lastModified": 113, + "enclosureMime": "video/mpeg", + "enclosureLink": "http://google.de/web.webm" + }, + { + "status": 0, + "body": "this is a body", + "title": "del2", + "author": "my author", + "guid": "del2", + "url": "http://google.de", + "pubDate": 2323, + "lastModified": 113, + "enclosureMime": "video/mpeg", + "enclosureLink": "http://google.de/web.webm" + }, + { + "status": 0, + "body": "this is a body", + "title": "del3", + "author": "my author", + "guid": "del3", + "url": "http://google.de", + "pubDate": 2323, + "lastModified": 113, + "enclosureMime": "video/mpeg", + "enclosureLink": "http://google.de/web.webm" + }, + { + "status": 0, + "body": "this is a body", + "title": "del4", + "author": "my author", + "guid": "del4", + "url": "http://google.de", + "pubDate": 2323, + "lastModified": 113, + "enclosureMime": "video/mpeg", + "enclosureLink": "http://google.de/web.webm" + }, + { + "status": 4, + "body": "this is a body", + "title": "a title2", + "author": "my author", + "guid": "def", + "url": "http://google.de", + "pubDate": 2323, + "lastModified": 113, + "enclosureMime": "video/mpeg", + "enclosureLink": "http://google.de/web.webm" + }, + { + "status": 6, + "body": "this is a body", + "title": "a title3", + "author": "my author", + "guid": "gih", + "url": "http://google.de", + "pubDate": 2323, + "lastModified": 113, + "enclosureMime": "video/mpeg", + "enclosureLink": "http://google.de/web.webm" + } + ], + "fifth feed": [ + { + "status": 2, + "body": "this is a body", + "title": "not found folder", + "author": "my author", + "guid": "not found", + "url": "http://google.de", + "pubDate": 2323, + "lastModified": 113, + "enclosureMime": "video/mpeg", + "enclosureLink": "http://google.de/web.webm" + } + ], + "sixth feed": [ + { + "status": 2, + "body": "this is a body", + "title": "not found feed", + "author": "my author", + "guid": "not found", + "url": "http://google.de", + "pubDate": 2323, + "lastModified": 113, + "enclosureMime": "video/mpeg", + "enclosureLink": "http://google.de/web.webm" + } + ] } \ No newline at end of file -- cgit v1.2.3