From e8a10f312a5c44314292402bb44e6ee2e71f3d5d Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Wed, 17 Jun 2020 15:55:31 +0200 Subject: Use NetscapeBookmarkUtils object instance instead of static calls --- tests/netscape/BookmarkExportTest.php | 65 ++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 23 deletions(-) (limited to 'tests/netscape/BookmarkExportTest.php') diff --git a/tests/netscape/BookmarkExportTest.php b/tests/netscape/BookmarkExportTest.php index 6c948bba..344c1dc0 100644 --- a/tests/netscape/BookmarkExportTest.php +++ b/tests/netscape/BookmarkExportTest.php @@ -1,11 +1,12 @@ set('resource.datastore', self::$testDatastore); - self::$refDb = new \ReferenceLinkDB(); - self::$refDb->write(self::$testDatastore); - $history = new History('sandbox/history.php'); - self::$bookmarkService = new BookmarkFileService($conf, $history, true); - $factory = new FormatterFactory($conf, true); - self::$formatter = $factory->getFormatter('raw'); + static::$conf = new ConfigManager('tests/utils/config/configJson'); + static::$conf->set('resource.datastore', static::$testDatastore); + static::$refDb = new \ReferenceLinkDB(); + static::$refDb->write(static::$testDatastore); + static::$history = new History('sandbox/history.php'); + static::$bookmarkService = new BookmarkFileService(static::$conf, static::$history, true); + $factory = new FormatterFactory(static::$conf, true); + static::$formatter = $factory->getFormatter('raw'); + } + + public function setUp(): void + { + $this->netscapeBookmarkUtils = new NetscapeBookmarkUtils( + static::$bookmarkService, + static::$conf, + static::$history + ); } /** @@ -57,8 +82,7 @@ class BookmarkExportTest extends \PHPUnit\Framework\TestCase */ public function testFilterAndFormatInvalid() { - NetscapeBookmarkUtils::filterAndFormat( - self::$bookmarkService, + $this->netscapeBookmarkUtils->filterAndFormat( self::$formatter, 'derp', false, @@ -71,8 +95,7 @@ class BookmarkExportTest extends \PHPUnit\Framework\TestCase */ public function testFilterAndFormatAll() { - $links = NetscapeBookmarkUtils::filterAndFormat( - self::$bookmarkService, + $links = $this->netscapeBookmarkUtils->filterAndFormat( self::$formatter, 'all', false, @@ -97,8 +120,7 @@ class BookmarkExportTest extends \PHPUnit\Framework\TestCase */ public function testFilterAndFormatPrivate() { - $links = NetscapeBookmarkUtils::filterAndFormat( - self::$bookmarkService, + $links = $this->netscapeBookmarkUtils->filterAndFormat( self::$formatter, 'private', false, @@ -123,8 +145,7 @@ class BookmarkExportTest extends \PHPUnit\Framework\TestCase */ public function testFilterAndFormatPublic() { - $links = NetscapeBookmarkUtils::filterAndFormat( - self::$bookmarkService, + $links = $this->netscapeBookmarkUtils->filterAndFormat( self::$formatter, 'public', false, @@ -149,8 +170,7 @@ class BookmarkExportTest extends \PHPUnit\Framework\TestCase */ public function testFilterAndFormatDoNotPrependNoteUrl() { - $links = NetscapeBookmarkUtils::filterAndFormat( - self::$bookmarkService, + $links = $this->netscapeBookmarkUtils->filterAndFormat( self::$formatter, 'public', false, @@ -168,8 +188,7 @@ class BookmarkExportTest extends \PHPUnit\Framework\TestCase public function testFilterAndFormatPrependNoteUrl() { $indexUrl = 'http://localhost:7469/shaarli/'; - $links = NetscapeBookmarkUtils::filterAndFormat( - self::$bookmarkService, + $links = $this->netscapeBookmarkUtils->filterAndFormat( self::$formatter, 'public', true, -- cgit v1.2.3