aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/bookmark
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-09-06 14:11:02 +0200
committerArthurHoaro <arthur@hoa.ro>2020-09-06 14:11:02 +0200
commit27ddfec3c3847f10ab0de246f4a174b751c5f19e (patch)
tree9fb085dd6f83ad73743950ca0de1549f28eeeef5 /tests/bookmark
parent21163a3329ef19dc6ebadb75d6452ac02fd59ab3 (diff)
downloadShaarli-27ddfec3c3847f10ab0de246f4a174b751c5f19e.tar.gz
Shaarli-27ddfec3c3847f10ab0de246f4a174b751c5f19e.tar.zst
Shaarli-27ddfec3c3847f10ab0de246f4a174b751c5f19e.zip
Fix visibility issue on daily page
This filter (links by day) didn't apply any visibility parameter. Fixes #1543
Diffstat (limited to 'tests/bookmark')
-rw-r--r--tests/bookmark/BookmarkFileServiceTest.php30
-rw-r--r--tests/bookmark/BookmarkFilterTest.php14
2 files changed, 42 insertions, 2 deletions
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
@@ -1062,6 +1062,36 @@ class BookmarkFileServiceTest extends TestCase
1062 } 1062 }
1063 1063
1064 /** 1064 /**
1065 * Test filterDay while logged in
1066 */
1067 public function testFilterDayLoggedIn(): void
1068 {
1069 $bookmarks = $this->privateLinkDB->filterDay('20121206');
1070 $expectedIds = [4, 9, 1, 0];
1071
1072 static::assertCount(4, $bookmarks);
1073 foreach ($bookmarks as $bookmark) {
1074 $i = ($i ?? -1) + 1;
1075 static::assertSame($expectedIds[$i], $bookmark->getId());
1076 }
1077 }
1078
1079 /**
1080 * Test filterDay while logged out
1081 */
1082 public function testFilterDayLoggedOut(): void
1083 {
1084 $bookmarks = $this->publicLinkDB->filterDay('20121206');
1085 $expectedIds = [4, 9, 1];
1086
1087 static::assertCount(3, $bookmarks);
1088 foreach ($bookmarks as $bookmark) {
1089 $i = ($i ?? -1) + 1;
1090 static::assertSame($expectedIds[$i], $bookmark->getId());
1091 }
1092 }
1093
1094 /**
1065 * Allows to test LinkDB's private methods 1095 * Allows to test LinkDB's private methods
1066 * 1096 *
1067 * @see 1097 * @see
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;
6use PHPUnit\Framework\TestCase; 6use PHPUnit\Framework\TestCase;
7use ReferenceLinkDB; 7use ReferenceLinkDB;
8use Shaarli\Config\ConfigManager; 8use Shaarli\Config\ConfigManager;
9use Shaarli\Formatter\FormatterFactory;
10use Shaarli\History; 9use Shaarli\History;
11 10
12/** 11/**
@@ -36,7 +35,7 @@ class BookmarkFilterTest extends TestCase
36 /** 35 /**
37 * Instantiate linkFilter with ReferenceLinkDB data. 36 * Instantiate linkFilter with ReferenceLinkDB data.
38 */ 37 */
39 public static function setUpBeforeClass() 38 public static function setUpBeforeClass(): void
40 { 39 {
41 $conf = new ConfigManager('tests/utils/config/configJson'); 40 $conf = new ConfigManager('tests/utils/config/configJson');
42 $conf->set('resource.datastore', self::$testDatastore); 41 $conf->set('resource.datastore', self::$testDatastore);
@@ -190,6 +189,17 @@ class BookmarkFilterTest extends TestCase
190 } 189 }
191 190
192 /** 191 /**
192 * Return bookmarks for a given day
193 */
194 public function testFilterDayRestrictedVisibility(): void
195 {
196 $this->assertEquals(
197 3,
198 count(self::$linkFilter->filter(BookmarkFilter::$FILTER_DAY, '20121206', false, BookmarkFilter::$PUBLIC))
199 );
200 }
201
202 /**
193 * 404 - day not found 203 * 404 - day not found
194 */ 204 */
195 public function testFilterUnknownDay() 205 public function testFilterUnknownDay()