use Shaarli\Config\ConfigManager;
use Shaarli\Formatter\BookmarkMarkdownFormatter;
use Shaarli\History;
+use Shaarli\Plugin\PluginManager;
use Shaarli\TestCase;
/**
/** @var NoMutex */
protected $mutex;
+ /** @var PluginManager */
+ protected $pluginManager;
+
/**
* Instantiates public and private LinkDBs with test data
*
$this->refDB = new \ReferenceLinkDB();
$this->refDB->write(self::$testDatastore);
$this->history = new History('sandbox/history.php');
- $this->publicLinkDB = new BookmarkFileService($this->conf, $this->history, $this->mutex, false);
- $this->privateLinkDB = new BookmarkFileService($this->conf, $this->history, $this->mutex, true);
+ $this->pluginManager = new PluginManager($this->conf);
+ $this->publicLinkDB = new BookmarkFileService(
+ $this->conf,
+ $this->pluginManager,
+ $this->history,
+ $this->mutex,
+ false
+ );
+ $this->privateLinkDB = new BookmarkFileService(
+ $this->conf,
+ $this->pluginManager,
+ $this->history,
+ $this->mutex,
+ true
+ );
}
/**
$db = self::getMethod('migrate');
$db->invokeArgs($this->privateLinkDB, []);
- $db = new \FakeBookmarkService($this->conf, $this->history, $this->mutex, true);
+ $db = new \FakeBookmarkService(
+ $this->conf,
+ $this->pluginManager,
+ $this->history,
+ $this->mutex,
+ true
+ );
$this->assertInstanceOf(BookmarkArray::class, $db->getBookmarks());
$this->assertEquals($this->refDB->countLinks(), $db->count());
}
$this->assertEquals($updated, $bookmark->getUpdated());
// reload from file
- $this->privateLinkDB = new BookmarkFileService($this->conf, $this->history, $this->mutex, true);
+ $this->privateLinkDB = new \FakeBookmarkService(
+ $this->conf,
+ $this->pluginManager,
+ $this->history,
+ $this->mutex,
+ true
+ );
$bookmark = $this->privateLinkDB->get(43);
$this->assertEquals(43, $bookmark->getId());
$this->assertNull($bookmark->getUpdated());
// reload from file
- $this->privateLinkDB = new BookmarkFileService($this->conf, $this->history, $this->mutex, true);
+ $this->privateLinkDB = new BookmarkFileService(
+ $this->conf,
+ $this->pluginManager,
+ $this->history,
+ $this->mutex,
+ true
+ );
$bookmark = $this->privateLinkDB->get(43);
$this->assertEquals(43, $bookmark->getId());
$this->assertEquals(43, $bookmark->getId());
// reload from file
- $this->privateLinkDB = new BookmarkFileService($this->conf, $this->history, $this->mutex, true);
+ $this->privateLinkDB = new BookmarkFileService(
+ $this->conf,
+ $this->pluginManager,
+ $this->history,
+ $this->mutex,
+ true
+ );
$this->privateLinkDB->get(43);
}
$this->assertTrue(new \DateTime('5 seconds ago') < $bookmark->getUpdated());
// reload from file
- $this->privateLinkDB = new BookmarkFileService($this->conf, $this->history, $this->mutex, true);
+ $this->privateLinkDB = new BookmarkFileService(
+ $this->conf,
+ $this->pluginManager,
+ $this->history,
+ $this->mutex,
+ true
+ );
$bookmark = $this->privateLinkDB->get(42);
$this->assertEquals(42, $bookmark->getId());
$this->assertTrue(new \DateTime('5 seconds ago') < $bookmark->getUpdated());
// reload from file
- $this->privateLinkDB = new BookmarkFileService($this->conf, $this->history, $this->mutex, true);
+ $this->privateLinkDB = new BookmarkFileService(
+ $this->conf,
+ $this->pluginManager,
+ $this->history,
+ $this->mutex,
+ true
+ );
$bookmark = $this->privateLinkDB->get(42);
$this->assertEquals(42, $bookmark->getId());
$this->assertEquals($title, $bookmark->getTitle());
// reload from file
- $this->privateLinkDB = new BookmarkFileService($this->conf, $this->history, $this->mutex, true);
+ $this->privateLinkDB = new BookmarkFileService(
+ $this->conf,
+ $this->pluginManager,
+ $this->history,
+ $this->mutex,
+ true
+ );
$bookmark = $this->privateLinkDB->get(42);
$this->assertEquals(42, $bookmark->getId());
$this->assertEquals(43, $bookmark->getId());
// reload from file
- $this->privateLinkDB = new BookmarkFileService($this->conf, $this->history, $this->mutex, true);
+ $this->privateLinkDB = new BookmarkFileService(
+ $this->conf,
+ $this->pluginManager,
+ $this->history,
+ $this->mutex,
+ true
+ );
$bookmark = $this->privateLinkDB->get(43);
$this->assertEquals(43, $bookmark->getId());
$this->assertEquals($title, $bookmark->getTitle());
// reload from file
- $this->privateLinkDB = new BookmarkFileService($this->conf, $this->history, $this->mutex, true);
+ $this->privateLinkDB = new BookmarkFileService(
+ $this->conf,
+ $this->pluginManager,
+ $this->history,
+ $this->mutex,
+ true
+ );
$bookmark = $this->privateLinkDB->get(42);
$this->assertEquals(42, $bookmark->getId());
$this->assertEquals($title, $bookmark->getTitle());
// reload from file
- $this->privateLinkDB = new BookmarkFileService($this->conf, $this->history, $this->mutex, true);
+ $this->privateLinkDB = new BookmarkFileService(
+ $this->conf,
+ $this->pluginManager,
+ $this->history,
+ $this->mutex,
+ true
+ );
$bookmark = $this->privateLinkDB->get(42);
$this->assertEquals(42, $bookmark->getId());
$this->assertInstanceOf(BookmarkNotFoundException::class, $exception);
// reload from file
- $this->privateLinkDB = new BookmarkFileService($this->conf, $this->history, $this->mutex, true);
+ $this->privateLinkDB = new BookmarkFileService(
+ $this->conf,
+ $this->pluginManager,
+ $this->history,
+ $this->mutex,
+ true
+ );
$this->privateLinkDB->get(42);
}
$conf = new ConfigManager('tests/utils/config/configJson');
$conf->set('resource.datastore', 'null/store.db');
- new BookmarkFileService($conf, $this->history, $this->mutex, true);
+ new BookmarkFileService($conf, $this->pluginManager, $this->history, $this->mutex, true);
}
/**
{
unlink(self::$testDatastore);
$this->assertFileNotExists(self::$testDatastore);
- new BookmarkFileService($this->conf, $this->history, $this->mutex, true);
+ new BookmarkFileService($this->conf, $this->pluginManager, $this->history, $this->mutex, true);
$this->assertFileExists(self::$testDatastore);
// ensure the correct data has been written
{
unlink(self::$testDatastore);
$this->assertFileNotExists(self::$testDatastore);
- $db = new \FakeBookmarkService($this->conf, $this->history, $this->mutex, false);
+ $db = new \FakeBookmarkService($this->conf, $this->pluginManager, $this->history, $this->mutex, false);
$this->assertFileNotExists(self::$testDatastore);
$this->assertInstanceOf(BookmarkArray::class, $db->getBookmarks());
$this->assertCount(0, $db->getBookmarks());
*/
public function testSave()
{
- $testDB = new BookmarkFileService($this->conf, $this->history, $this->mutex, true);
+ $testDB = new BookmarkFileService($this->conf, $this->pluginManager, $this->history, $this->mutex, true);
$dbSize = $testDB->count();
$bookmark = new Bookmark();
$testDB->add($bookmark);
- $testDB = new BookmarkFileService($this->conf, $this->history, $this->mutex, true);
+ $testDB = new BookmarkFileService($this->conf, $this->pluginManager, $this->history, $this->mutex, true);
$this->assertEquals($dbSize + 1, $testDB->count());
}
public function testCountHiddenPublic()
{
$this->conf->set('privacy.hide_public_links', true);
- $linkDB = new BookmarkFileService($this->conf, $this->history, $this->mutex, false);
+ $linkDB = new BookmarkFileService($this->conf, $this->pluginManager, $this->history, $this->mutex, false);
$this->assertEquals(0, $linkDB->count());
}
$bookmark->addAdditionalContentEntry('private_key', $privateKey);
$this->privateLinkDB->save();
- $this->privateLinkDB = new BookmarkFileService($this->conf, $this->history, $this->mutex, false);
+ $this->privateLinkDB = new BookmarkFileService(
+ $this->conf,
+ $this->pluginManager,
+ $this->history,
+ $this->mutex,
+ false
+ );
$bookmark = $this->privateLinkDB->findByHash($hash, $privateKey);
static::assertSame(6, $bookmark->getId());
public function testGetLatestEmptyDatastore(): void
{
unlink($this->conf->get('resource.datastore'));
- $this->publicLinkDB = new BookmarkFileService($this->conf, $this->history, $this->mutex, false);
+ $this->publicLinkDB = new BookmarkFileService(
+ $this->conf,
+ $this->pluginManager,
+ $this->history,
+ $this->mutex,
+ false
+ );
$bookmark = $this->publicLinkDB->getLatest();