From 27ddfec3c3847f10ab0de246f4a174b751c5f19e Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sun, 6 Sep 2020 14:11:02 +0200 Subject: Fix visibility issue on daily page This filter (links by day) didn't apply any visibility parameter. Fixes #1543 --- tests/bookmark/BookmarkFileServiceTest.php | 30 ++++++++++++++++++++++++++++++ tests/bookmark/BookmarkFilterTest.php | 14 ++++++++++++-- 2 files changed, 42 insertions(+), 2 deletions(-) (limited to 'tests/bookmark') diff --git a/tests/bookmark/BookmarkFileServiceTest.php b/tests/bookmark/BookmarkFileServiceTest.php index 7b1906d3..c59fd443 100644 --- a/tests/bookmark/BookmarkFileServiceTest.php +++ b/tests/bookmark/BookmarkFileServiceTest.php @@ -1061,6 +1061,36 @@ class BookmarkFileServiceTest extends TestCase $this->assertEquals($expected, $tags, var_export($tags, true)); } + /** + * Test filterDay while logged in + */ + public function testFilterDayLoggedIn(): void + { + $bookmarks = $this->privateLinkDB->filterDay('20121206'); + $expectedIds = [4, 9, 1, 0]; + + static::assertCount(4, $bookmarks); + foreach ($bookmarks as $bookmark) { + $i = ($i ?? -1) + 1; + static::assertSame($expectedIds[$i], $bookmark->getId()); + } + } + + /** + * Test filterDay while logged out + */ + public function testFilterDayLoggedOut(): void + { + $bookmarks = $this->publicLinkDB->filterDay('20121206'); + $expectedIds = [4, 9, 1]; + + static::assertCount(3, $bookmarks); + foreach ($bookmarks as $bookmark) { + $i = ($i ?? -1) + 1; + static::assertSame($expectedIds[$i], $bookmark->getId()); + } + } + /** * Allows to test LinkDB's private methods * diff --git a/tests/bookmark/BookmarkFilterTest.php b/tests/bookmark/BookmarkFilterTest.php index d4c71cb9..91e139c2 100644 --- a/tests/bookmark/BookmarkFilterTest.php +++ b/tests/bookmark/BookmarkFilterTest.php @@ -6,7 +6,6 @@ use Exception; use PHPUnit\Framework\TestCase; use ReferenceLinkDB; use Shaarli\Config\ConfigManager; -use Shaarli\Formatter\FormatterFactory; use Shaarli\History; /** @@ -36,7 +35,7 @@ class BookmarkFilterTest extends TestCase /** * Instantiate linkFilter with ReferenceLinkDB data. */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { $conf = new ConfigManager('tests/utils/config/configJson'); $conf->set('resource.datastore', self::$testDatastore); @@ -189,6 +188,17 @@ class BookmarkFilterTest extends TestCase ); } + /** + * Return bookmarks for a given day + */ + public function testFilterDayRestrictedVisibility(): void + { + $this->assertEquals( + 3, + count(self::$linkFilter->filter(BookmarkFilter::$FILTER_DAY, '20121206', false, BookmarkFilter::$PUBLIC)) + ); + } + /** * 404 - day not found */ -- cgit v1.2.3