aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/front/controller
diff options
context:
space:
mode:
Diffstat (limited to 'tests/front/controller')
-rw-r--r--tests/front/controller/admin/ManageShaareControllerTest/DeleteBookmarkTest.php23
-rw-r--r--tests/front/controller/admin/PluginsControllerTest.php14
-rw-r--r--tests/front/controller/admin/SessionFilterControllerTest.php2
-rw-r--r--tests/front/controller/visitor/ShaarliVisitorControllerTest.php2
4 files changed, 34 insertions, 7 deletions
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
59 ->with('raw') 59 ->with('raw')
60 ->willReturnCallback(function () use ($bookmark): BookmarkFormatter { 60 ->willReturnCallback(function () use ($bookmark): BookmarkFormatter {
61 $formatter = $this->createMock(BookmarkFormatter::class); 61 $formatter = $this->createMock(BookmarkFormatter::class);
62 62 $formatter
63 $formatter->expects(static::once())->method('format')->with($bookmark); 63 ->expects(static::once())
64 ->method('format')
65 ->with($bookmark)
66 ->willReturn(['formatted' => $bookmark])
67 ;
64 68
65 return $formatter; 69 return $formatter;
66 }) 70 })
@@ -70,7 +74,7 @@ class DeleteBookmarkTest extends TestCase
70 $this->container->pluginManager 74 $this->container->pluginManager
71 ->expects(static::once()) 75 ->expects(static::once())
72 ->method('executeHooks') 76 ->method('executeHooks')
73 ->with('delete_link') 77 ->with('delete_link', ['formatted' => $bookmark])
74 ; 78 ;
75 79
76 $result = $this->controller->deleteBookmark($request, $response); 80 $result = $this->controller->deleteBookmark($request, $response);
@@ -129,6 +133,9 @@ class DeleteBookmarkTest extends TestCase
129 ->withConsecutive(...array_map(function (Bookmark $bookmark): array { 133 ->withConsecutive(...array_map(function (Bookmark $bookmark): array {
130 return [$bookmark]; 134 return [$bookmark];
131 }, $bookmarks)) 135 }, $bookmarks))
136 ->willReturnOnConsecutiveCalls(...array_map(function (Bookmark $bookmark): array {
137 return ['formatted' => $bookmark];
138 }, $bookmarks))
132 ; 139 ;
133 140
134 return $formatter; 141 return $formatter;
@@ -254,6 +261,9 @@ class DeleteBookmarkTest extends TestCase
254 ->withConsecutive(...array_map(function (Bookmark $bookmark): array { 261 ->withConsecutive(...array_map(function (Bookmark $bookmark): array {
255 return [$bookmark]; 262 return [$bookmark];
256 }, $bookmarks)) 263 }, $bookmarks))
264 ->willReturnOnConsecutiveCalls(...array_map(function (Bookmark $bookmark): array {
265 return ['formatted' => $bookmark];
266 }, $bookmarks))
257 ; 267 ;
258 268
259 return $formatter; 269 return $formatter;
@@ -350,7 +360,12 @@ class DeleteBookmarkTest extends TestCase
350 $this->container->formatterFactory 360 $this->container->formatterFactory
351 ->expects(static::once()) 361 ->expects(static::once())
352 ->method('getFormatter') 362 ->method('getFormatter')
353 ->willReturn($this->createMock(BookmarkFormatter::class)) 363 ->willReturnCallback(function (): BookmarkFormatter {
364 $formatter = $this->createMock(BookmarkFormatter::class);
365 $formatter->method('format')->willReturn(['formatted']);
366
367 return $formatter;
368 })
354 ; 369 ;
355 370
356 $result = $this->controller->deleteBookmark($request, $response); 371 $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;
7use PHPUnit\Framework\TestCase; 7use PHPUnit\Framework\TestCase;
8use Shaarli\Config\ConfigManager; 8use Shaarli\Config\ConfigManager;
9use Shaarli\Front\Exception\WrongTokenException; 9use Shaarli\Front\Exception\WrongTokenException;
10use Shaarli\Plugin\PluginManager;
10use Shaarli\Security\SessionManager; 11use Shaarli\Security\SessionManager;
11use Slim\Http\Request; 12use Slim\Http\Request;
12use Slim\Http\Response; 13use Slim\Http\Response;
@@ -15,6 +16,8 @@ class PluginsControllerTest extends TestCase
15{ 16{
16 use FrontAdminControllerMockHelper; 17 use FrontAdminControllerMockHelper;
17 18
19 const PLUGIN_NAMES = ['plugin1', 'plugin2', 'plugin3', 'plugin4'];
20
18 /** @var PluginsController */ 21 /** @var PluginsController */
19 protected $controller; 22 protected $controller;
20 23
@@ -23,6 +26,17 @@ class PluginsControllerTest extends TestCase
23 $this->createContainer(); 26 $this->createContainer();
24 27
25 $this->controller = new PluginsController($this->container); 28 $this->controller = new PluginsController($this->container);
29
30 mkdir($path = __DIR__ . '/folder');
31 PluginManager::$PLUGINS_PATH = $path;
32 array_map(function (string $plugin) use ($path) { touch($path . '/' . $plugin); }, static::PLUGIN_NAMES);
33 }
34
35 public function tearDown()
36 {
37 $path = __DIR__ . '/folder';
38 array_map(function (string $plugin) use ($path) { unlink($path . '/' . $plugin); }, static::PLUGIN_NAMES);
39 rmdir($path);
26 } 40 }
27 41
28 /** 42 /**
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
23 23
24 $this->controller = new SessionFilterController($this->container); 24 $this->controller = new SessionFilterController($this->container);
25 } 25 }
26 26
27 /** 27 /**
28 * Visibility - Default call for private filter while logged in without current value 28 * Visibility - Default call for private filter while logged in without current value
29 */ 29 */
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
96 static::assertSame(10, $this->assignedValues['linkcount']); 96 static::assertSame(10, $this->assignedValues['linkcount']);
97 static::assertSame(5, $this->assignedValues['privateLinkcount']); 97 static::assertSame(5, $this->assignedValues['privateLinkcount']);
98 static::assertSame(['error'], $this->assignedValues['plugin_errors']); 98 static::assertSame(['error'], $this->assignedValues['plugin_errors']);
99 static::assertSame('/subfolder', $this->assignedValues['base_path']);
100 static::assertSame('/subfolder/tpl/default', $this->assignedValues['asset_path']);
101 99
102 static::assertSame('templateName', $this->assignedValues['plugins_includes']['render_includes']['target']); 100 static::assertSame('templateName', $this->assignedValues['plugins_includes']['render_includes']['target']);
103 static::assertTrue($this->assignedValues['plugins_includes']['render_includes']['loggedin']); 101 static::assertTrue($this->assignedValues['plugins_includes']['render_includes']['loggedin']);