+ /**
+ * Test linksCountPerTag public tags with filter.
+ * Equal occurrences should be sorted alphabetically.
+ */
+ public function testCountTagsNoMarkdown()
+ {
+ $expected = [
+ 'cartoon' => 3,
+ 'dev' => 2,
+ 'tag1' => 1,
+ 'tag2' => 1,
+ 'tag3' => 1,
+ 'tag4' => 1,
+ 'web' => 4,
+ 'gnu' => 2,
+ 'hashtag' => 2,
+ 'sTuff' => 2,
+ '-exclude' => 1,
+ '.hidden' => 1,
+ 'Mercurial' => 1,
+ 'css' => 1,
+ 'free' => 1,
+ 'html' => 1,
+ 'media' => 1,
+ 'newTagToCount' => 1,
+ 'samba' => 1,
+ 'software' => 1,
+ 'stallman' => 1,
+ 'ut' => 1,
+ 'w3c' => 1,
+ ];
+ $bookmark = new Bookmark();
+ $bookmark->setTags(['newTagToCount', BookmarkMarkdownFormatter::NO_MD_TAG]);
+ $this->privateLinkDB->add($bookmark);
+
+ $tags = $this->privateLinkDB->bookmarksCountPerTag();
+
+ $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());
+ }
+ }
+