+ static::assertCount(2, $bookmarks);
+
+ static::assertSame(1, $bookmarks[0]->getId());
+ static::assertSame(9, $bookmarks[1]->getId());
+ static::assertEquals(DateTime::createFromFormat('Ymd_His', '20121206_142300'), $before);
+ static::assertEquals(DateTime::createFromFormat('Ymd_His', '20121206_182539'), $after);
+ }
+
+ /**
+ * Test find by dates at the end of the datastore (sorted by dates).
+ */
+ public function testFilterByDateLastTimePeriod(): void
+ {
+ $after = new DateTime();
+ $bookmarks = $this->privateLinkDB->findByDate(
+ DateTime::createFromFormat('Ymd_His', '20150310_114640'),
+ DateTime::createFromFormat('Ymd_His', '20450101_010101'),
+ $before,
+ $after
+ );
+
+ static::assertCount(1, $bookmarks);
+
+ static::assertSame(41, $bookmarks[0]->getId());
+ static::assertEquals(DateTime::createFromFormat('Ymd_His', '20150310_114633'), $before);
+ static::assertNull($after);
+ }
+
+ /**
+ * Test find by dates at the beginning of the datastore (sorted by dates).
+ */
+ public function testFilterByDateFirstTimePeriod(): void
+ {
+ $before = new DateTime();
+ $bookmarks = $this->privateLinkDB->findByDate(
+ DateTime::createFromFormat('Ymd_His', '20000101_101010'),
+ DateTime::createFromFormat('Ymd_His', '20100309_110000'),
+ $before,
+ $after
+ );
+
+ static::assertCount(1, $bookmarks);
+
+ static::assertSame(11, $bookmarks[0]->getId());
+ static::assertNull($before);
+ static::assertEquals(DateTime::createFromFormat('Ymd_His', '20100310_101010'), $after);
+ }
+
+ /**
+ * Test getLatest with a sticky bookmark: it should be ignored and return the latest by creation date instead.
+ */
+ public function testGetLatestWithSticky(): void
+ {
+ $bookmark = $this->publicLinkDB->getLatest();
+
+ static::assertSame(41, $bookmark->getId());
+ }
+
+ /**
+ * Test getLatest with a sticky bookmark: it should be ignored and return the latest by creation date instead.
+ */
+ public function testGetLatestEmptyDatastore(): void
+ {
+ unlink($this->conf->get('resource.datastore'));
+ $this->publicLinkDB = new BookmarkFileService(
+ $this->conf,
+ $this->pluginManager,
+ $this->history,
+ $this->mutex,
+ false
+ );
+
+ $bookmark = $this->publicLinkDB->getLatest();
+
+ static::assertNull($bookmark);