summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2014-10-09 09:33:59 +0200
committerBernhard Posselt <dev@bernhard-posselt.com>2014-10-09 09:33:59 +0200
commitb32fc30d68e18994d2b17bbb30eac0b33ec6af3c (patch)
treed2f7532beabf82d55d3df3e39486265c7e975021
parent6fa7d6e4db1a953aa87b47b74128465c7957ebf9 (diff)
even more code coverage
-rw-r--r--db/itemmapper.php5
-rw-r--r--tests/unit/db/ItemTest.php32
-rw-r--r--tests/unit/service/ItemServiceTest.php33
3 files changed, 65 insertions, 5 deletions
diff --git a/db/itemmapper.php b/db/itemmapper.php
index d0ea4bea3..636df0667 100644
--- a/db/itemmapper.php
+++ b/db/itemmapper.php
@@ -49,11 +49,6 @@ class ItemMapper extends NewsMapper {
// code: we take them variables and we cast the shit out of them
$status = (int) $status;
- // prepare for the unexpected
- if(!is_numeric($status)) {
- die('If you can read this something is terribly wrong');
- }
-
// now im gonna slowly stick them in the query, be careful!
return $this->makeSelectQuery(
diff --git a/tests/unit/db/ItemTest.php b/tests/unit/db/ItemTest.php
index 4c9569ed4..70d4e34e7 100644
--- a/tests/unit/db/ItemTest.php
+++ b/tests/unit/db/ItemTest.php
@@ -194,6 +194,38 @@ class ItemTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($item, $compareWith);
}
+ public function testFromImportRead() {
+ $item = new Item();
+ $item->setGuid('guid');
+ $item->setUrl('https://google');
+ $item->setTitle('title');
+ $item->setAuthor('author');
+ $item->setPubDate(123);
+ $item->setBody('body');
+ $item->setEnclosureMime('audio/ogg');
+ $item->setEnclosureLink('enclink');
+ $item->setRead();
+ $item->setStarred();
+
+ $import = [
+ '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($import);
+
+ $this->assertEquals($item, $compareWith);
+ }
+
+
public function testSetAuthor(){
$item = new Item();
diff --git a/tests/unit/service/ItemServiceTest.php b/tests/unit/service/ItemServiceTest.php
index 557d31816..d5947b406 100644
--- a/tests/unit/service/ItemServiceTest.php
+++ b/tests/unit/service/ItemServiceTest.php
@@ -210,6 +210,39 @@ class ItemServiceTest extends \PHPUnit_Framework_TestCase {
}
+ public function testUnstar(){
+ $itemId = 3;
+ $feedId = 5;
+ $guidHash = md5('hihi');
+
+ $item = new Item();
+ $item->setStatus(128);
+ $item->setId($itemId);
+ $item->setStarred();
+
+ $expectedItem = new Item();
+ $expectedItem->setStatus(128);
+ $expectedItem->setUnstarred();
+ $expectedItem->setId($itemId);
+ $expectedItem->setLastModified($this->time);
+
+ $this->mapper->expects($this->once())
+ ->method('findByGuidHash')
+ ->with(
+ $this->equalTo($guidHash),
+ $this->equalTo($feedId),
+ $this->equalTo($this->user))
+ ->will($this->returnValue($item));
+
+ $this->mapper->expects($this->once())
+ ->method('update')
+ ->with($this->equalTo($expectedItem));
+
+ $this->itemService->star($feedId, $guidHash, false, $this->user);
+
+ $this->assertTrue($item->isUnstarred());
+ }
+
public function testRead(){
$itemId = 3;
$item = new Item();