X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2Fnetscape%2FBookmarkExportTest.php;h=b8a88cd83c235d2facc0acb57d8a2e3878a31c2b;hb=refs%2Fpull%2F1698%2Fhead;hp=6c948bba4a0d805f09927af06e3e5d6d68482d57;hpb=1001cc108fec759b076c9f6e12b71dea5d49fe9b;p=github%2Fshaarli%2FShaarli.git diff --git a/tests/netscape/BookmarkExportTest.php b/tests/netscape/BookmarkExportTest.php index 6c948bba..b8a88cd8 100644 --- a/tests/netscape/BookmarkExportTest.php +++ b/tests/netscape/BookmarkExportTest.php @@ -1,25 +1,33 @@ 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'); + $mutex = new NoMutex(); + 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::$pluginManager = new PluginManager(static::$conf); + static::$bookmarkService = new BookmarkFileService( + static::$conf, + static::$pluginManager, + static::$history, + $mutex, + 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 + ); } /** * Attempt to export an invalid link selection - * @expectedException Exception - * @expectedExceptionMessageRegExp /Invalid export selection/ */ public function testFilterAndFormatInvalid() { - NetscapeBookmarkUtils::filterAndFormat( - self::$bookmarkService, + $this->expectException(\Exception::class); + $this->expectExceptionMessageRegExp('/Invalid export selection/'); + + $this->netscapeBookmarkUtils->filterAndFormat( self::$formatter, 'derp', false, @@ -71,8 +109,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 +134,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 +159,7 @@ class BookmarkExportTest extends \PHPUnit\Framework\TestCase */ public function testFilterAndFormatPublic() { - $links = NetscapeBookmarkUtils::filterAndFormat( - self::$bookmarkService, + $links = $this->netscapeBookmarkUtils->filterAndFormat( self::$formatter, 'public', false, @@ -149,15 +184,14 @@ class BookmarkExportTest extends \PHPUnit\Framework\TestCase */ public function testFilterAndFormatDoNotPrependNoteUrl() { - $links = NetscapeBookmarkUtils::filterAndFormat( - self::$bookmarkService, + $links = $this->netscapeBookmarkUtils->filterAndFormat( self::$formatter, 'public', false, '' ); $this->assertEquals( - '?WDWyig', + '/shaare/WDWyig', $links[2]['url'] ); } @@ -168,15 +202,14 @@ 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, $indexUrl ); $this->assertEquals( - $indexUrl . '?WDWyig', + $indexUrl . 'shaare/WDWyig', $links[2]['url'] ); }