namespace Shaarli\Bookmark;
use PHPUnit\Framework\TestCase;
-use ReferenceLinkDB;
use Shaarli\Config\ConfigManager;
use Shaarli\History;
}
/**
- * Test initialize() with an empty data store.
+ * Test initialize() with a data store containing bookmarks.
*/
- public function testInitializeEmptyDataStore()
+ public function testInitializeNotEmptyDataStore(): void
{
$refDB = new \ReferenceLinkDB();
$refDB->write(self::$testDatastore);
);
$this->assertFalse($bookmark->isPrivate());
+ $this->bookmarkService->save();
+
// Reload from file
$this->bookmarkService = new BookmarkFileService($this->conf, $this->history, true);
$this->assertEquals($refDB->countLinks() + 2, $this->bookmarkService->count());
}
/**
- * Test initialize() with a data store containing bookmarks.
+ * Test initialize() with an a non existent datastore file .
*/
- public function testInitializeNotEmptyDataStore()
+ public function testInitializeNonExistentDataStore(): void
{
+ $this->conf->set('resource.datastore', static::$testDatastore . '_empty');
+ $this->bookmarkService = new BookmarkFileService($this->conf, $this->history, true);
+
$this->initializer->initialize();
$this->assertEquals(2, $this->bookmarkService->count());