diff options
-rw-r--r-- | db/enclosure.php | 35 | ||||
-rw-r--r-- | db/item.php | 55 | ||||
-rw-r--r-- | db/statusflag.php | 2 | ||||
-rw-r--r-- | tests/db/ItemTest.php | 22 |
4 files changed, 50 insertions, 64 deletions
diff --git a/db/enclosure.php b/db/enclosure.php deleted file mode 100644 index 7eaddf158..000000000 --- a/db/enclosure.php +++ /dev/null @@ -1,35 +0,0 @@ -<?php -/** -* ownCloud - News app -* -* @author Alessandro Cosentino -* Copyright (c) 2012 - Alessandro Cosentino <cosenal@gmail.com> -* -* This file is licensed under the Affero General Public License version 3 or later. -* See the COPYING-README file -* -*/ - -namespace OCA\News; - - -class Enclosure { - private $mimetype; - private $link; - - public function getMimeType() { - return $this->mimetype; - } - - public function setMimeType($mimetype) { - $this->mimetype = $mimetype; - } - - public function getLink() { - return $this->link; - } - - public function setLink($link) { - $this->link = $link; - } -} diff --git a/db/item.php b/db/item.php index 66ee0ef7e..4eaa294d3 100644 --- a/db/item.php +++ b/db/item.php @@ -36,7 +36,8 @@ class Item extends Entity { public $author; public $date; public $feedTitle; - public $enclosure; + public $enclosureMime; + public $enclosureLink; public function setRead() { $this->markFieldUpdated('status'); @@ -44,7 +45,31 @@ class Item extends Entity { } public function isRead() { - return !($this->status & StatusFlag::UNREAD); + return !(($this->status & StatusFlag::UNREAD) === StatusFlag::UNREAD); + } + + public function setUnread() { + $this->status |= StatusFlag::UNREAD; + } + + public function isUnread() { + return !$this->isRead(); + } + + public function setStarred() { + $this->status |= StatusFlag::STARRED; + } + + public function isStarred() { + return ($this->status & StatusFlag::STARRED) === StatusFlag::STARRED; + } + + public function setUnstarred() { + $this->status &= ~StatusFlag::STARRED; + } + + public function isUnstarred() { + return !$this->isStarred(); } } @@ -77,32 +102,6 @@ class Item extends Entity { $this->id = $id; } } - - - - - - - - public function setUnread() { - $this->status |= StatusFlag::UNREAD; - } - - - - public function setImportant() { - $this->status |= StatusFlag::IMPORTANT; - } - - public function setUnimportant() { - $this->status &= ~StatusFlag::IMPORTANT; - } - - public function isImportant() { - return ($this->status & StatusFlag::IMPORTANT); - } - - public function getBody() { diff --git a/db/statusflag.php b/db/statusflag.php index 1b01ab42b..351d5d40a 100644 --- a/db/statusflag.php +++ b/db/statusflag.php @@ -27,7 +27,7 @@ namespace OCA\News\Db; class StatusFlag { const UNREAD = 0x02; - const IMPORTANT = 0x04; + const STARRED = 0x04; const DELETED = 0x08; const UPDATED = 0x16; }
\ No newline at end of file diff --git a/tests/db/ItemTest.php b/tests/db/ItemTest.php index a590856c4..792085733 100644 --- a/tests/db/ItemTest.php +++ b/tests/db/ItemTest.php @@ -37,10 +37,32 @@ class ItemTest extends \PHPUnit_Framework_TestCase { $this->item->setStatus(0); } + public function testSetRead(){ $this->item->setRead(); $this->assertTrue($this->item->isRead()); } + + public function testSetUnread(){ + $this->item->setUnread(); + + $this->assertTrue($this->item->isUnread()); + } + + + public function testSetStarred(){ + $this->item->setStarred(); + + $this->assertTrue($this->item->isStarred()); + } + + + public function testSetUnstarred(){ + $this->item->setUnstarred(); + + $this->assertTrue($this->item->isUnstarred()); + } + }
\ No newline at end of file |