aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/bookmark/BookmarkFilterTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/bookmark/BookmarkFilterTest.php')
-rw-r--r--tests/bookmark/BookmarkFilterTest.php30
1 files changed, 21 insertions, 9 deletions
diff --git a/tests/bookmark/BookmarkFilterTest.php b/tests/bookmark/BookmarkFilterTest.php
index d4c71cb9..48c7f824 100644
--- a/tests/bookmark/BookmarkFilterTest.php
+++ b/tests/bookmark/BookmarkFilterTest.php
@@ -3,11 +3,10 @@
3namespace Shaarli\Bookmark; 3namespace Shaarli\Bookmark;
4 4
5use Exception; 5use Exception;
6use PHPUnit\Framework\TestCase;
7use ReferenceLinkDB; 6use ReferenceLinkDB;
8use Shaarli\Config\ConfigManager; 7use Shaarli\Config\ConfigManager;
9use Shaarli\Formatter\FormatterFactory;
10use Shaarli\History; 8use Shaarli\History;
9use Shaarli\TestCase;
11 10
12/** 11/**
13 * Class BookmarkFilterTest. 12 * Class BookmarkFilterTest.
@@ -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()
@@ -202,21 +212,23 @@ class BookmarkFilterTest extends TestCase
202 212
203 /** 213 /**
204 * Use an invalid date format 214 * Use an invalid date format
205 * @expectedException Exception
206 * @expectedExceptionMessageRegExp /Invalid date format/
207 */ 215 */
208 public function testFilterInvalidDayWithChars() 216 public function testFilterInvalidDayWithChars()
209 { 217 {
218 $this->expectException(\Exception::class);
219 $this->expectExceptionMessageRegExp('/Invalid date format/');
220
210 self::$linkFilter->filter(BookmarkFilter::$FILTER_DAY, 'Rainy day, dream away'); 221 self::$linkFilter->filter(BookmarkFilter::$FILTER_DAY, 'Rainy day, dream away');
211 } 222 }
212 223
213 /** 224 /**
214 * Use an invalid date format 225 * Use an invalid date format
215 * @expectedException Exception
216 * @expectedExceptionMessageRegExp /Invalid date format/
217 */ 226 */
218 public function testFilterInvalidDayDigits() 227 public function testFilterInvalidDayDigits()
219 { 228 {
229 $this->expectException(\Exception::class);
230 $this->expectExceptionMessageRegExp('/Invalid date format/');
231
220 self::$linkFilter->filter(BookmarkFilter::$FILTER_DAY, '20'); 232 self::$linkFilter->filter(BookmarkFilter::$FILTER_DAY, '20');
221 } 233 }
222 234
@@ -240,11 +252,11 @@ class BookmarkFilterTest extends TestCase
240 252
241 /** 253 /**
242 * No link for this hash 254 * No link for this hash
243 *
244 * @expectedException \Shaarli\Bookmark\Exception\BookmarkNotFoundException
245 */ 255 */
246 public function testFilterUnknownSmallHash() 256 public function testFilterUnknownSmallHash()
247 { 257 {
258 $this->expectException(\Shaarli\Bookmark\Exception\BookmarkNotFoundException::class);
259
248 self::$linkFilter->filter(BookmarkFilter::$FILTER_HASH, 'Iblaah'); 260 self::$linkFilter->filter(BookmarkFilter::$FILTER_HASH, 'Iblaah');
249 } 261 }
250 262