X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2Fbookmark%2FBookmarkFilterTest.php;h=48c7f8247bc02ca32900886e7f7d86aac90027c8;hb=458b6b9918ec27154dd45416947bb93bedb97109;hp=d4c71cb94388ca86dede43b8c9054ce96f4e8261;hpb=e26e2060f5470ce8bf4c5973284bae07b8af170a;p=github%2Fshaarli%2FShaarli.git 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 @@ namespace Shaarli\Bookmark; use Exception; -use PHPUnit\Framework\TestCase; use ReferenceLinkDB; use Shaarli\Config\ConfigManager; -use Shaarli\Formatter\FormatterFactory; use Shaarli\History; +use Shaarli\TestCase; /** * Class BookmarkFilterTest. @@ -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 */ @@ -202,21 +212,23 @@ class BookmarkFilterTest extends TestCase /** * Use an invalid date format - * @expectedException Exception - * @expectedExceptionMessageRegExp /Invalid date format/ */ public function testFilterInvalidDayWithChars() { + $this->expectException(\Exception::class); + $this->expectExceptionMessageRegExp('/Invalid date format/'); + self::$linkFilter->filter(BookmarkFilter::$FILTER_DAY, 'Rainy day, dream away'); } /** * Use an invalid date format - * @expectedException Exception - * @expectedExceptionMessageRegExp /Invalid date format/ */ public function testFilterInvalidDayDigits() { + $this->expectException(\Exception::class); + $this->expectExceptionMessageRegExp('/Invalid date format/'); + self::$linkFilter->filter(BookmarkFilter::$FILTER_DAY, '20'); } @@ -240,11 +252,11 @@ class BookmarkFilterTest extends TestCase /** * No link for this hash - * - * @expectedException \Shaarli\Bookmark\Exception\BookmarkNotFoundException */ public function testFilterUnknownSmallHash() { + $this->expectException(\Shaarli\Bookmark\Exception\BookmarkNotFoundException::class); + self::$linkFilter->filter(BookmarkFilter::$FILTER_HASH, 'Iblaah'); }