diff options
author | François D <franek@users.noreply.github.com> | 2017-08-23 23:06:40 +0200 |
---|---|---|
committer | François D <franek@users.noreply.github.com> | 2017-08-25 21:19:47 +0200 |
commit | a991c46eedec0efb24d0a9974b1c7fcabf8cfa66 (patch) | |
tree | fa33236c5ef67e023833c889eb52d5bed99d35bd /tests/Wallabag | |
parent | 2490f61dca635026a3eb9b5e9b6978b1981b1172 (diff) | |
download | wallabag-a991c46eedec0efb24d0a9974b1c7fcabf8cfa66.tar.gz wallabag-a991c46eedec0efb24d0a9974b1c7fcabf8cfa66.tar.zst wallabag-a991c46eedec0efb24d0a9974b1c7fcabf8cfa66.zip |
Set a starred_at field when an entry is starred.
This date is used to sort starred entries.
Can not use Entry::timestamps method otherwise starred_at will be updated each time entry is updated.
Add an updateStar method into Entry class
A migration script has been added in order to set starred_at field.
Diffstat (limited to 'tests/Wallabag')
-rw-r--r-- | tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php index 2dc08be2..f4c8a630 100644 --- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | |||
@@ -407,6 +407,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
407 | $this->assertSame('http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html', $content['url']); | 407 | $this->assertSame('http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html', $content['url']); |
408 | $this->assertSame(0, $content['is_archived']); | 408 | $this->assertSame(0, $content['is_archived']); |
409 | $this->assertSame(0, $content['is_starred']); | 409 | $this->assertSame(0, $content['is_starred']); |
410 | $this->assertNull($content['starred_at']); | ||
410 | $this->assertSame('New title for my article', $content['title']); | 411 | $this->assertSame('New title for my article', $content['title']); |
411 | $this->assertSame(1, $content['user_id']); | 412 | $this->assertSame(1, $content['user_id']); |
412 | $this->assertCount(2, $content['tags']); | 413 | $this->assertCount(2, $content['tags']); |
@@ -483,6 +484,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
483 | 484 | ||
484 | public function testPostArchivedAndStarredEntry() | 485 | public function testPostArchivedAndStarredEntry() |
485 | { | 486 | { |
487 | $now = new \DateTime(); | ||
486 | $this->client->request('POST', '/api/entries.json', [ | 488 | $this->client->request('POST', '/api/entries.json', [ |
487 | 'url' => 'http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html', | 489 | 'url' => 'http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html', |
488 | 'archive' => '1', | 490 | 'archive' => '1', |
@@ -497,6 +499,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
497 | $this->assertSame('http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html', $content['url']); | 499 | $this->assertSame('http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html', $content['url']); |
498 | $this->assertSame(1, $content['is_archived']); | 500 | $this->assertSame(1, $content['is_archived']); |
499 | $this->assertSame(1, $content['is_starred']); | 501 | $this->assertSame(1, $content['is_starred']); |
502 | $this->assertGreaterThanOrEqual($now->getTimestamp(), (new \DateTime($content['starred_at']))->getTimestamp()); | ||
500 | $this->assertSame(1, $content['user_id']); | 503 | $this->assertSame(1, $content['user_id']); |
501 | } | 504 | } |
502 | 505 | ||
@@ -753,6 +756,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
753 | 756 | ||
754 | public function testSaveIsStarredAfterPatch() | 757 | public function testSaveIsStarredAfterPatch() |
755 | { | 758 | { |
759 | $now = new \DateTime(); | ||
756 | $entry = $this->client->getContainer() | 760 | $entry = $this->client->getContainer() |
757 | ->get('doctrine.orm.entity_manager') | 761 | ->get('doctrine.orm.entity_manager') |
758 | ->getRepository('WallabagCoreBundle:Entry') | 762 | ->getRepository('WallabagCoreBundle:Entry') |
@@ -770,6 +774,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
770 | $content = json_decode($this->client->getResponse()->getContent(), true); | 774 | $content = json_decode($this->client->getResponse()->getContent(), true); |
771 | 775 | ||
772 | $this->assertSame(1, $content['is_starred']); | 776 | $this->assertSame(1, $content['is_starred']); |
777 | $this->assertGreaterThanOrEqual($now->getTimestamp(), (new \DateTime($content['starred_at']))->getTimestamp()); | ||
773 | } | 778 | } |
774 | 779 | ||
775 | public function dataForEntriesExistWithUrl() | 780 | public function dataForEntriesExistWithUrl() |