summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDaniel Schaal <daniel@schaal.email>2016-10-01 08:34:40 +0200
committerBernhard Posselt <BernhardPosselt@users.noreply.github.com>2016-10-01 08:34:40 +0200
commite45511f6ba5a53a137538e4647148aa749009233 (patch)
treec4f1265f1129556f09d6fb2b110325e9958f2d99 /tests
parentf46ed33ea553bc45cff973150f69227da13baace (diff)
Add updatedDate to item model (#43)
* Update picoFeed to 0.1.25 * Add updated_date to database * Add updatedDate to item model * Bump version to 9.0.5 * Check for updatedDate when updating a feed * Fix unit test to check for newer updatedDate
Diffstat (limited to 'tests')
-rw-r--r--tests/Unit/Controller/ExportControllerTest.php4
-rw-r--r--tests/Unit/Db/ItemTest.php9
-rw-r--r--tests/Unit/Fetcher/FeedFetcherTest.php12
-rw-r--r--tests/Unit/Service/FeedServiceTest.php4
4 files changed, 23 insertions, 6 deletions
diff --git a/tests/Unit/Controller/ExportControllerTest.php b/tests/Unit/Controller/ExportControllerTest.php
index 89dcb0198..42fb2ac85 100644
--- a/tests/Unit/Controller/ExportControllerTest.php
+++ b/tests/Unit/Controller/ExportControllerTest.php
@@ -119,10 +119,10 @@ class ExportControllerTest extends \PHPUnit_Framework_TestCase {
);
$this->assertEquals('[{"guid":null,"url":null,"title":null,' .
- '"author":null,"pubDate":null,"body":null,"enclosureMime":null,' .
+ '"author":null,"pubDate":null,"updatedDate":null,"body":null,"enclosureMime":null,' .
'"enclosureLink":null,"unread":false,"starred":false,' .
'"feedLink":"http:\/\/goo","rtl":null},{"guid":null,"url":null,' .
- '"title":null,"author":null,"pubDate":null,"body":null,' .
+ '"title":null,"author":null,"pubDate":null,"updatedDate":null,"body":null,' .
'"enclosureMime":null,"enclosureLink":null,"unread":false,' .
'"starred":false,"feedLink":"http:\/\/gee","rtl":null}]',
$return->render());
diff --git a/tests/Unit/Db/ItemTest.php b/tests/Unit/Db/ItemTest.php
index bdc0793a2..f26cf6ff9 100644
--- a/tests/Unit/Db/ItemTest.php
+++ b/tests/Unit/Db/ItemTest.php
@@ -61,6 +61,7 @@ class ItemTest extends \PHPUnit_Framework_TestCase {
$item->setTitle('title');
$item->setAuthor('author');
$item->setPubDate(123);
+ $item->setUpdatedDate(234);
$item->setBody('body');
$item->setEnclosureMime('audio/ogg');
$item->setEnclosureLink('enclink');
@@ -81,6 +82,7 @@ class ItemTest extends \PHPUnit_Framework_TestCase {
'title' => 'title',
'author' => 'author',
'pubDate' => 123,
+ 'updatedDate' => 234,
'body' => 'body',
'enclosureMime' => 'audio/ogg',
'enclosureLink' => 'enclink',
@@ -104,6 +106,7 @@ class ItemTest extends \PHPUnit_Framework_TestCase {
$item->setTitle('title');
$item->setAuthor('author');
$item->setPubDate(123);
+ $item->setUpdatedDate(234);
$item->setBody('<body><div>this is a test</body>');
$item->setEnclosureMime('audio/ogg');
$item->setEnclosureLink('enclink');
@@ -123,6 +126,7 @@ class ItemTest extends \PHPUnit_Framework_TestCase {
'title' => 'title',
'author' => 'author',
'pubDate' => 123,
+ 'updatedDate' => 234,
'body' => '<body><div>this is a test</body>',
'enclosureMime' => 'audio/ogg',
'enclosureLink' => 'enclink',
@@ -145,6 +149,7 @@ class ItemTest extends \PHPUnit_Framework_TestCase {
$item->setTitle('title');
$item->setAuthor('author');
$item->setPubDate(123);
+ $item->setUpdatedDate(234);
$item->setBody('body');
$item->setEnclosureMime('audio/ogg');
$item->setEnclosureLink('enclink');
@@ -165,6 +170,7 @@ class ItemTest extends \PHPUnit_Framework_TestCase {
'title' => 'title',
'author' => 'author',
'pubDate' => 123,
+ 'updatedDate' => 234,
'body' => 'body',
'enclosureMime' => 'audio/ogg',
'enclosureLink' => 'enclink',
@@ -184,6 +190,7 @@ class ItemTest extends \PHPUnit_Framework_TestCase {
$item->setTitle('title');
$item->setAuthor('author');
$item->setPubDate(123);
+ $item->setUpdatedDate(234);
$item->setBody('body');
$item->setEnclosureMime('audio/ogg');
$item->setEnclosureLink('enclink');
@@ -221,6 +228,7 @@ class ItemTest extends \PHPUnit_Framework_TestCase {
'title' => $item->getTitle(),
'author' => $item->getAuthor(),
'pubDate' => $item->getPubDate(),
+ 'updatedDate' => $item->getUpdatedDate(),
'body' => $item->getBody(),
'enclosureMime' => $item->getEnclosureMime(),
'enclosureLink' => $item->getEnclosureLink(),
@@ -244,6 +252,7 @@ class ItemTest extends \PHPUnit_Framework_TestCase {
'title' => $item->getTitle(),
'author' => $item->getAuthor(),
'pubDate' => $item->getPubDate(),
+ 'updatedDate' => $item->getUpdatedDate(),
'body' => $item->getBody(),
'enclosureMime' => $item->getEnclosureMime(),
'enclosureLink' => $item->getEnclosureLink(),
diff --git a/tests/Unit/Fetcher/FeedFetcherTest.php b/tests/Unit/Fetcher/FeedFetcherTest.php
index 5266f0708..930cf4c99 100644
--- a/tests/Unit/Fetcher/FeedFetcherTest.php
+++ b/tests/Unit/Fetcher/FeedFetcherTest.php
@@ -38,6 +38,7 @@ class FeedFetcherTest extends \PHPUnit_Framework_TestCase {
private $title;
private $guid;
private $pub;
+ private $updated;
private $body;
private $author;
private $enclosureLink;
@@ -110,6 +111,7 @@ class FeedFetcherTest extends \PHPUnit_Framework_TestCase {
$this->body2 = 'let the bodies hit the floor ' .
'<a target="_blank" href="test">test</a>';
$this->pub = 23111;
+ $this->updated = 23444;
$this->author = '&lt;boogieman';
$this->enclosureLink = 'http://enclosure.you';
@@ -209,11 +211,15 @@ class FeedFetcherTest extends \PHPUnit_Framework_TestCase {
$item = new Item();
date_default_timezone_set('America/Los_Angeles');
- $date = new \DateTime();
- $date->setTimestamp($this->pub);
- $this->expectItem('getDate', $date);
+
+ $pubdate = \Datetime::createFromFormat('U',$this->pub);
+ $this->expectItem('getPublishedDate', $pubdate);
$item->setPubDate($this->pub);
+ $update = \Datetime::createFromFormat('U',$this->updated);
+ $this->expectItem('getUpdatedDate', $update);
+ $item->setUpdatedDate($this->updated);
+
$item->setStatus(0);
$item->setUnread();
$item->setUrl($this->permalink);
diff --git a/tests/Unit/Service/FeedServiceTest.php b/tests/Unit/Service/FeedServiceTest.php
index 99cd9b11b..68d25df9e 100644
--- a/tests/Unit/Service/FeedServiceTest.php
+++ b/tests/Unit/Service/FeedServiceTest.php
@@ -384,6 +384,7 @@ class FeedServiceTest extends \PHPUnit_Framework_TestCase {
$item->setGuidHash(md5('hi'));
$item->setFeedId(3);
$item->setPubDate(2);
+ $item->setUpdatedDate(2);
$item->setTitle('hey');
$item->setAuthor('aut');
$item->setBody('new');
@@ -396,6 +397,7 @@ class FeedServiceTest extends \PHPUnit_Framework_TestCase {
$item->setGuidHash(md5('hi'));
$item->setFeedId(3);
$item->setPubDate(1);
+ $item->setUpdatedDate(1);
$item->setTitle('ho');
$item->setAuthor('auto');
$item->setBody('old');
@@ -403,7 +405,7 @@ class FeedServiceTest extends \PHPUnit_Framework_TestCase {
return $item;
}
- public function testUpdateUpdatesWhenPubdateIsNewer() {
+ public function testUpdateUpdatesWhenUpdateddateIsNewer() {
$feed = $this->createUpdateFeed();
$item = $this->createUpdateItem();
$item2 = $this->createUpdateItem2();