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.
/**
* 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);
);
}
+ /**
+ * 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
*/
/**
* 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');
}
/**
* 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');
}