From 9fbc42294e7667c5ef19cafa0d1fcfbc1c0f36a9 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sun, 26 Jul 2020 14:43:10 +0200 Subject: New basePath: fix officiel plugin paths and vintage template --- .../DeleteBookmarkTest.php | 23 ++++++++++++++++++---- .../controller/admin/PluginsControllerTest.php | 14 +++++++++++++ .../admin/SessionFilterControllerTest.php | 2 +- .../visitor/ShaarliVisitorControllerTest.php | 2 -- 4 files changed, 34 insertions(+), 7 deletions(-) (limited to 'tests/front') diff --git a/tests/front/controller/admin/ManageShaareControllerTest/DeleteBookmarkTest.php b/tests/front/controller/admin/ManageShaareControllerTest/DeleteBookmarkTest.php index caaf549d..dee622bb 100644 --- a/tests/front/controller/admin/ManageShaareControllerTest/DeleteBookmarkTest.php +++ b/tests/front/controller/admin/ManageShaareControllerTest/DeleteBookmarkTest.php @@ -59,8 +59,12 @@ class DeleteBookmarkTest extends TestCase ->with('raw') ->willReturnCallback(function () use ($bookmark): BookmarkFormatter { $formatter = $this->createMock(BookmarkFormatter::class); - - $formatter->expects(static::once())->method('format')->with($bookmark); + $formatter + ->expects(static::once()) + ->method('format') + ->with($bookmark) + ->willReturn(['formatted' => $bookmark]) + ; return $formatter; }) @@ -70,7 +74,7 @@ class DeleteBookmarkTest extends TestCase $this->container->pluginManager ->expects(static::once()) ->method('executeHooks') - ->with('delete_link') + ->with('delete_link', ['formatted' => $bookmark]) ; $result = $this->controller->deleteBookmark($request, $response); @@ -129,6 +133,9 @@ class DeleteBookmarkTest extends TestCase ->withConsecutive(...array_map(function (Bookmark $bookmark): array { return [$bookmark]; }, $bookmarks)) + ->willReturnOnConsecutiveCalls(...array_map(function (Bookmark $bookmark): array { + return ['formatted' => $bookmark]; + }, $bookmarks)) ; return $formatter; @@ -254,6 +261,9 @@ class DeleteBookmarkTest extends TestCase ->withConsecutive(...array_map(function (Bookmark $bookmark): array { return [$bookmark]; }, $bookmarks)) + ->willReturnOnConsecutiveCalls(...array_map(function (Bookmark $bookmark): array { + return ['formatted' => $bookmark]; + }, $bookmarks)) ; return $formatter; @@ -350,7 +360,12 @@ class DeleteBookmarkTest extends TestCase $this->container->formatterFactory ->expects(static::once()) ->method('getFormatter') - ->willReturn($this->createMock(BookmarkFormatter::class)) + ->willReturnCallback(function (): BookmarkFormatter { + $formatter = $this->createMock(BookmarkFormatter::class); + $formatter->method('format')->willReturn(['formatted']); + + return $formatter; + }) ; $result = $this->controller->deleteBookmark($request, $response); diff --git a/tests/front/controller/admin/PluginsControllerTest.php b/tests/front/controller/admin/PluginsControllerTest.php index ad0cda70..5b59285c 100644 --- a/tests/front/controller/admin/PluginsControllerTest.php +++ b/tests/front/controller/admin/PluginsControllerTest.php @@ -7,6 +7,7 @@ namespace Shaarli\Front\Controller\Admin; use PHPUnit\Framework\TestCase; use Shaarli\Config\ConfigManager; use Shaarli\Front\Exception\WrongTokenException; +use Shaarli\Plugin\PluginManager; use Shaarli\Security\SessionManager; use Slim\Http\Request; use Slim\Http\Response; @@ -15,6 +16,8 @@ class PluginsControllerTest extends TestCase { use FrontAdminControllerMockHelper; + const PLUGIN_NAMES = ['plugin1', 'plugin2', 'plugin3', 'plugin4']; + /** @var PluginsController */ protected $controller; @@ -23,6 +26,17 @@ class PluginsControllerTest extends TestCase $this->createContainer(); $this->controller = new PluginsController($this->container); + + mkdir($path = __DIR__ . '/folder'); + PluginManager::$PLUGINS_PATH = $path; + array_map(function (string $plugin) use ($path) { touch($path . '/' . $plugin); }, static::PLUGIN_NAMES); + } + + public function tearDown() + { + $path = __DIR__ . '/folder'; + array_map(function (string $plugin) use ($path) { unlink($path . '/' . $plugin); }, static::PLUGIN_NAMES); + rmdir($path); } /** diff --git a/tests/front/controller/admin/SessionFilterControllerTest.php b/tests/front/controller/admin/SessionFilterControllerTest.php index 124b0bf2..7d5511ed 100644 --- a/tests/front/controller/admin/SessionFilterControllerTest.php +++ b/tests/front/controller/admin/SessionFilterControllerTest.php @@ -23,7 +23,7 @@ class SessionFilterControllerTest extends TestCase $this->controller = new SessionFilterController($this->container); } - + /** * Visibility - Default call for private filter while logged in without current value */ diff --git a/tests/front/controller/visitor/ShaarliVisitorControllerTest.php b/tests/front/controller/visitor/ShaarliVisitorControllerTest.php index 83d08358..316ce49c 100644 --- a/tests/front/controller/visitor/ShaarliVisitorControllerTest.php +++ b/tests/front/controller/visitor/ShaarliVisitorControllerTest.php @@ -96,8 +96,6 @@ class ShaarliVisitorControllerTest extends TestCase static::assertSame(10, $this->assignedValues['linkcount']); static::assertSame(5, $this->assignedValues['privateLinkcount']); static::assertSame(['error'], $this->assignedValues['plugin_errors']); - static::assertSame('/subfolder', $this->assignedValues['base_path']); - static::assertSame('/subfolder/tpl/default', $this->assignedValues['asset_path']); static::assertSame('templateName', $this->assignedValues['plugins_includes']['render_includes']['target']); static::assertTrue($this->assignedValues['plugins_includes']['render_includes']['loggedin']); -- cgit v1.2.3