From 65d28653ae1a1d2a7680ccfa694dbb7e2d4d750f Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Wed, 6 Apr 2016 23:43:27 +0200 Subject: try marking same items as read if they contain the same content --- tests/integration/db/ItemMapperTest.php | 83 +++++++++++++++++++++++++-------- 1 file changed, 63 insertions(+), 20 deletions(-) (limited to 'tests/integration/db/ItemMapperTest.php') diff --git a/tests/integration/db/ItemMapperTest.php b/tests/integration/db/ItemMapperTest.php index a36b1db9e..14c989cbf 100644 --- a/tests/integration/db/ItemMapperTest.php +++ b/tests/integration/db/ItemMapperTest.php @@ -225,30 +225,73 @@ class ItemMapperTest extends IntegrationTest { } - /* TBD - public function testFindAllFolder () { - + public function testReadItem() { + $this->loadFixtures('readitem'); + // assert that all items are unread + $feed = $this->feedMapper->where(['userId' => 'john'])[0]; + $items = $this->itemMapper->where(['feedId' => $feed->getId()]); + foreach ($items as $item) { + $this->assertTrue($item->isUnread()); + } + $feed = $this->feedMapper->where(['userId' => 'test'])[0]; + $items = $this->itemMapper->where(['feedId' => $feed->getId()]); + foreach ($items as $item) { + $this->assertTrue($item->isUnread()); + } + + // read an item + $duplicateItem = $this->itemMapper->where(['feedId' => $feed->getId()])[0]; + $this->itemMapper->readItem($duplicateItem->getId(), true, 1000, $this->user); + + // assert that all test user's same items are read + $items = $this->itemMapper->where(['feedId' => $feed->getId(), 'title' => 'blubb']); + foreach ($items as $item) { + $this->assertTrue($item->isRead()); + } + + // assert that a different item is not read + $items = $this->itemMapper->where(['feedId' => $feed->getId(), 'title' => 'blubbs']); + foreach ($items as $item) { + $this->assertTrue($item->isUnread()); + } + + // assert that other user's same items stayed the same + $johnsFeed = $this->feedMapper->where(['userId' => 'john'])[0]; + $items = $this->itemMapper->where(['feedId' => $johnsFeed->getId()]); + foreach ($items as $item) { + $this->assertTrue($item->isUnread()); + } } - - public function testFindAllFeed () { - - } - - - public function testFindAllNew () { - + public function testUnreadItem() { + $this->loadFixtures('readitem'); + // unread an item + $feed = $this->feedMapper->where(['userId' => 'test'])[0]; + $duplicateItem = $this->itemMapper->where(['feedId' => $feed->getId()])[0]; + $this->itemMapper->readItem($duplicateItem->getId(), true, 1000, $this->user); + $this->itemMapper->readItem($duplicateItem->getId(), false, 1000, $this->user); + + // assert that only one item is now unread + $items = $this->itemMapper->where(['feedId' => $feed->getId(), 'title' => 'blubb']); + foreach ($items as $item) { + if ($item->getId() === $duplicateItem->getId()) { + $this->assertTrue($item->isUnread()); + } else { + $this->assertTrue($item->isRead()); + } + } + + // assert that other user's same items stayed the same + $johnsFeed = $this->feedMapper->where(['userId' => 'john'])[0]; + $items = $this->itemMapper->where(['feedId' => $johnsFeed->getId()]); + foreach ($items as $item) { + $this->assertTrue($item->isUnread()); + } } - - public function testFindAllNewFolder () { - - } - - - public function testFindAllNewFeed () { - + protected function tearDown() { + parent::tearDown(); + $this->clearUserNewsDatabase('john'); } - */ } -- cgit v1.2.3