From d6e5f04d3987e498c5cb859eed6bff33d67949df Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sat, 1 Aug 2020 11:10:57 +0200 Subject: Remove anonymous permission and initialize bookmarks on login --- tests/bookmark/BookmarkInitializerTest.php | 14 +++++++++----- tests/front/controller/visitor/InstallControllerTest.php | 3 --- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/bookmark/BookmarkInitializerTest.php b/tests/bookmark/BookmarkInitializerTest.php index d23eb069..3906cc7f 100644 --- a/tests/bookmark/BookmarkInitializerTest.php +++ b/tests/bookmark/BookmarkInitializerTest.php @@ -3,7 +3,6 @@ namespace Shaarli\Bookmark; use PHPUnit\Framework\TestCase; -use ReferenceLinkDB; use Shaarli\Config\ConfigManager; use Shaarli\History; @@ -54,9 +53,9 @@ class BookmarkInitializerTest extends TestCase } /** - * 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); @@ -79,6 +78,8 @@ class BookmarkInitializerTest extends TestCase ); $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()); @@ -97,10 +98,13 @@ class BookmarkInitializerTest extends TestCase } /** - * 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()); diff --git a/tests/front/controller/visitor/InstallControllerTest.php b/tests/front/controller/visitor/InstallControllerTest.php index 089c64ac..3b855365 100644 --- a/tests/front/controller/visitor/InstallControllerTest.php +++ b/tests/front/controller/visitor/InstallControllerTest.php @@ -224,9 +224,6 @@ class InstallControllerTest extends TestCase ; $this->container->conf->expects(static::once())->method('write'); - $this->container->bookmarkService->expects(static::once())->method('count')->willReturn(0); - $this->container->bookmarkService->expects(static::once())->method('initialize'); - $this->container->sessionManager ->expects(static::once()) ->method('setSessionParameter') -- cgit v1.2.3