diff options
Diffstat (limited to 'tests/front/controller/admin')
19 files changed, 84 insertions, 56 deletions
diff --git a/tests/front/controller/admin/ConfigureControllerTest.php b/tests/front/controller/admin/ConfigureControllerTest.php index f2f84bac..d82db0a7 100644 --- a/tests/front/controller/admin/ConfigureControllerTest.php +++ b/tests/front/controller/admin/ConfigureControllerTest.php | |||
@@ -4,10 +4,10 @@ declare(strict_types=1); | |||
4 | 4 | ||
5 | namespace Shaarli\Front\Controller\Admin; | 5 | namespace Shaarli\Front\Controller\Admin; |
6 | 6 | ||
7 | use PHPUnit\Framework\TestCase; | ||
8 | use Shaarli\Config\ConfigManager; | 7 | use Shaarli\Config\ConfigManager; |
9 | use Shaarli\Front\Exception\WrongTokenException; | 8 | use Shaarli\Front\Exception\WrongTokenException; |
10 | use Shaarli\Security\SessionManager; | 9 | use Shaarli\Security\SessionManager; |
10 | use Shaarli\TestCase; | ||
11 | use Shaarli\Thumbnailer; | 11 | use Shaarli\Thumbnailer; |
12 | use Slim\Http\Request; | 12 | use Slim\Http\Request; |
13 | use Slim\Http\Response; | 13 | use Slim\Http\Response; |
@@ -51,7 +51,7 @@ class ConfigureControllerTest extends TestCase | |||
51 | static::assertSame('general.title', $assignedVariables['title']); | 51 | static::assertSame('general.title', $assignedVariables['title']); |
52 | static::assertSame('resource.theme', $assignedVariables['theme']); | 52 | static::assertSame('resource.theme', $assignedVariables['theme']); |
53 | static::assertEmpty($assignedVariables['theme_available']); | 53 | static::assertEmpty($assignedVariables['theme_available']); |
54 | static::assertSame(['default', 'markdown'], $assignedVariables['formatter_available']); | 54 | static::assertSame(['default', 'markdown', 'markdownExtra'], $assignedVariables['formatter_available']); |
55 | static::assertNotEmpty($assignedVariables['continents']); | 55 | static::assertNotEmpty($assignedVariables['continents']); |
56 | static::assertNotEmpty($assignedVariables['cities']); | 56 | static::assertNotEmpty($assignedVariables['cities']); |
57 | static::assertSame('general.retrieve_description', $assignedVariables['retrieve_description']); | 57 | static::assertSame('general.retrieve_description', $assignedVariables['retrieve_description']); |
@@ -62,7 +62,7 @@ class ConfigureControllerTest extends TestCase | |||
62 | static::assertSame('privacy.hide_public_links', $assignedVariables['hide_public_links']); | 62 | static::assertSame('privacy.hide_public_links', $assignedVariables['hide_public_links']); |
63 | static::assertSame('api.enabled', $assignedVariables['api_enabled']); | 63 | static::assertSame('api.enabled', $assignedVariables['api_enabled']); |
64 | static::assertSame('api.secret', $assignedVariables['api_secret']); | 64 | static::assertSame('api.secret', $assignedVariables['api_secret']); |
65 | static::assertCount(4, $assignedVariables['languages']); | 65 | static::assertCount(5, $assignedVariables['languages']); |
66 | static::assertArrayHasKey('gd_enabled', $assignedVariables); | 66 | static::assertArrayHasKey('gd_enabled', $assignedVariables); |
67 | static::assertSame('thumbnails.mode', $assignedVariables['thumbnails_mode']); | 67 | static::assertSame('thumbnails.mode', $assignedVariables['thumbnails_mode']); |
68 | } | 68 | } |
diff --git a/tests/front/controller/admin/ExportControllerTest.php b/tests/front/controller/admin/ExportControllerTest.php index 50d9e378..0e6f2762 100644 --- a/tests/front/controller/admin/ExportControllerTest.php +++ b/tests/front/controller/admin/ExportControllerTest.php | |||
@@ -4,12 +4,12 @@ declare(strict_types=1); | |||
4 | 4 | ||
5 | namespace Shaarli\Front\Controller\Admin; | 5 | namespace Shaarli\Front\Controller\Admin; |
6 | 6 | ||
7 | use PHPUnit\Framework\TestCase; | ||
8 | use Shaarli\Bookmark\Bookmark; | 7 | use Shaarli\Bookmark\Bookmark; |
9 | use Shaarli\Formatter\BookmarkFormatter; | 8 | use Shaarli\Formatter\BookmarkFormatter; |
10 | use Shaarli\Formatter\BookmarkRawFormatter; | 9 | use Shaarli\Formatter\BookmarkRawFormatter; |
11 | use Shaarli\Netscape\NetscapeBookmarkUtils; | 10 | use Shaarli\Netscape\NetscapeBookmarkUtils; |
12 | use Shaarli\Security\SessionManager; | 11 | use Shaarli\Security\SessionManager; |
12 | use Shaarli\TestCase; | ||
13 | use Slim\Http\Request; | 13 | use Slim\Http\Request; |
14 | use Slim\Http\Response; | 14 | use Slim\Http\Response; |
15 | 15 | ||
@@ -84,7 +84,7 @@ class ExportControllerTest extends TestCase | |||
84 | static::assertInstanceOf(BookmarkRawFormatter::class, $formatter); | 84 | static::assertInstanceOf(BookmarkRawFormatter::class, $formatter); |
85 | static::assertSame($parameters['selection'], $selection); | 85 | static::assertSame($parameters['selection'], $selection); |
86 | static::assertTrue($prependNoteUrl); | 86 | static::assertTrue($prependNoteUrl); |
87 | static::assertSame('http://shaarli', $indexUrl); | 87 | static::assertSame('http://shaarli/subfolder/', $indexUrl); |
88 | 88 | ||
89 | return $bookmarks; | 89 | return $bookmarks; |
90 | } | 90 | } |
diff --git a/tests/front/controller/admin/ImportControllerTest.php b/tests/front/controller/admin/ImportControllerTest.php index eb31fad0..c266caa5 100644 --- a/tests/front/controller/admin/ImportControllerTest.php +++ b/tests/front/controller/admin/ImportControllerTest.php | |||
@@ -4,10 +4,10 @@ declare(strict_types=1); | |||
4 | 4 | ||
5 | namespace Shaarli\Front\Controller\Admin; | 5 | namespace Shaarli\Front\Controller\Admin; |
6 | 6 | ||
7 | use PHPUnit\Framework\TestCase; | ||
8 | use Psr\Http\Message\UploadedFileInterface; | 7 | use Psr\Http\Message\UploadedFileInterface; |
9 | use Shaarli\Netscape\NetscapeBookmarkUtils; | 8 | use Shaarli\Netscape\NetscapeBookmarkUtils; |
10 | use Shaarli\Security\SessionManager; | 9 | use Shaarli\Security\SessionManager; |
10 | use Shaarli\TestCase; | ||
11 | use Slim\Http\Request; | 11 | use Slim\Http\Request; |
12 | use Slim\Http\Response; | 12 | use Slim\Http\Response; |
13 | use Slim\Http\UploadedFile; | 13 | use Slim\Http\UploadedFile; |
diff --git a/tests/front/controller/admin/LogoutControllerTest.php b/tests/front/controller/admin/LogoutControllerTest.php index 45e84dc0..94e53019 100644 --- a/tests/front/controller/admin/LogoutControllerTest.php +++ b/tests/front/controller/admin/LogoutControllerTest.php | |||
@@ -4,10 +4,9 @@ declare(strict_types=1); | |||
4 | 4 | ||
5 | namespace Shaarli\Front\Controller\Admin; | 5 | namespace Shaarli\Front\Controller\Admin; |
6 | 6 | ||
7 | use PHPUnit\Framework\TestCase; | ||
8 | use Shaarli\Security\CookieManager; | 7 | use Shaarli\Security\CookieManager; |
9 | use Shaarli\Security\LoginManager; | ||
10 | use Shaarli\Security\SessionManager; | 8 | use Shaarli\Security\SessionManager; |
9 | use Shaarli\TestCase; | ||
11 | use Slim\Http\Request; | 10 | use Slim\Http\Request; |
12 | use Slim\Http\Response; | 11 | use Slim\Http\Response; |
13 | 12 | ||
diff --git a/tests/front/controller/admin/ManageShaareControllerTest/AddShaareTest.php b/tests/front/controller/admin/ManageShaareControllerTest/AddShaareTest.php index 7d5b752a..0f27ec2f 100644 --- a/tests/front/controller/admin/ManageShaareControllerTest/AddShaareTest.php +++ b/tests/front/controller/admin/ManageShaareControllerTest/AddShaareTest.php | |||
@@ -4,10 +4,10 @@ declare(strict_types=1); | |||
4 | 4 | ||
5 | namespace Shaarli\Front\Controller\Admin\ManageShaareControllerTest; | 5 | namespace Shaarli\Front\Controller\Admin\ManageShaareControllerTest; |
6 | 6 | ||
7 | use PHPUnit\Framework\TestCase; | ||
8 | use Shaarli\Front\Controller\Admin\FrontAdminControllerMockHelper; | 7 | use Shaarli\Front\Controller\Admin\FrontAdminControllerMockHelper; |
9 | use Shaarli\Front\Controller\Admin\ManageShaareController; | 8 | use Shaarli\Front\Controller\Admin\ManageShaareController; |
10 | use Shaarli\Http\HttpAccess; | 9 | use Shaarli\Http\HttpAccess; |
10 | use Shaarli\TestCase; | ||
11 | use Slim\Http\Request; | 11 | use Slim\Http\Request; |
12 | use Slim\Http\Response; | 12 | use Slim\Http\Response; |
13 | 13 | ||
diff --git a/tests/front/controller/admin/ManageShaareControllerTest/ChangeVisibilityBookmarkTest.php b/tests/front/controller/admin/ManageShaareControllerTest/ChangeVisibilityBookmarkTest.php index 5a615791..096d0774 100644 --- a/tests/front/controller/admin/ManageShaareControllerTest/ChangeVisibilityBookmarkTest.php +++ b/tests/front/controller/admin/ManageShaareControllerTest/ChangeVisibilityBookmarkTest.php | |||
@@ -4,7 +4,6 @@ declare(strict_types=1); | |||
4 | 4 | ||
5 | namespace Shaarli\Front\Controller\Admin\ManageShaareControllerTest; | 5 | namespace Shaarli\Front\Controller\Admin\ManageShaareControllerTest; |
6 | 6 | ||
7 | use PHPUnit\Framework\TestCase; | ||
8 | use Shaarli\Bookmark\Bookmark; | 7 | use Shaarli\Bookmark\Bookmark; |
9 | use Shaarli\Bookmark\Exception\BookmarkNotFoundException; | 8 | use Shaarli\Bookmark\Exception\BookmarkNotFoundException; |
10 | use Shaarli\Formatter\BookmarkFormatter; | 9 | use Shaarli\Formatter\BookmarkFormatter; |
@@ -14,6 +13,7 @@ use Shaarli\Front\Controller\Admin\FrontAdminControllerMockHelper; | |||
14 | use Shaarli\Front\Controller\Admin\ManageShaareController; | 13 | use Shaarli\Front\Controller\Admin\ManageShaareController; |
15 | use Shaarli\Http\HttpAccess; | 14 | use Shaarli\Http\HttpAccess; |
16 | use Shaarli\Security\SessionManager; | 15 | use Shaarli\Security\SessionManager; |
16 | use Shaarli\TestCase; | ||
17 | use Slim\Http\Request; | 17 | use Slim\Http\Request; |
18 | use Slim\Http\Response; | 18 | use Slim\Http\Response; |
19 | 19 | ||
diff --git a/tests/front/controller/admin/ManageShaareControllerTest/DeleteBookmarkTest.php b/tests/front/controller/admin/ManageShaareControllerTest/DeleteBookmarkTest.php index dee622bb..ba774e21 100644 --- a/tests/front/controller/admin/ManageShaareControllerTest/DeleteBookmarkTest.php +++ b/tests/front/controller/admin/ManageShaareControllerTest/DeleteBookmarkTest.php | |||
@@ -4,7 +4,6 @@ declare(strict_types=1); | |||
4 | 4 | ||
5 | namespace Shaarli\Front\Controller\Admin\ManageShaareControllerTest; | 5 | namespace Shaarli\Front\Controller\Admin\ManageShaareControllerTest; |
6 | 6 | ||
7 | use PHPUnit\Framework\TestCase; | ||
8 | use Shaarli\Bookmark\Bookmark; | 7 | use Shaarli\Bookmark\Bookmark; |
9 | use Shaarli\Bookmark\Exception\BookmarkNotFoundException; | 8 | use Shaarli\Bookmark\Exception\BookmarkNotFoundException; |
10 | use Shaarli\Formatter\BookmarkFormatter; | 9 | use Shaarli\Formatter\BookmarkFormatter; |
@@ -13,6 +12,7 @@ use Shaarli\Front\Controller\Admin\FrontAdminControllerMockHelper; | |||
13 | use Shaarli\Front\Controller\Admin\ManageShaareController; | 12 | use Shaarli\Front\Controller\Admin\ManageShaareController; |
14 | use Shaarli\Http\HttpAccess; | 13 | use Shaarli\Http\HttpAccess; |
15 | use Shaarli\Security\SessionManager; | 14 | use Shaarli\Security\SessionManager; |
15 | use Shaarli\TestCase; | ||
16 | use Slim\Http\Request; | 16 | use Slim\Http\Request; |
17 | use Slim\Http\Response; | 17 | use Slim\Http\Response; |
18 | 18 | ||
diff --git a/tests/front/controller/admin/ManageShaareControllerTest/DisplayCreateFormTest.php b/tests/front/controller/admin/ManageShaareControllerTest/DisplayCreateFormTest.php index 777583d5..2eb95251 100644 --- a/tests/front/controller/admin/ManageShaareControllerTest/DisplayCreateFormTest.php +++ b/tests/front/controller/admin/ManageShaareControllerTest/DisplayCreateFormTest.php | |||
@@ -4,12 +4,12 @@ declare(strict_types=1); | |||
4 | 4 | ||
5 | namespace Shaarli\Front\Controller\Admin\ManageShaareControllerTest; | 5 | namespace Shaarli\Front\Controller\Admin\ManageShaareControllerTest; |
6 | 6 | ||
7 | use PHPUnit\Framework\TestCase; | ||
8 | use Shaarli\Bookmark\Bookmark; | 7 | use Shaarli\Bookmark\Bookmark; |
9 | use Shaarli\Config\ConfigManager; | 8 | use Shaarli\Config\ConfigManager; |
10 | use Shaarli\Front\Controller\Admin\FrontAdminControllerMockHelper; | 9 | use Shaarli\Front\Controller\Admin\FrontAdminControllerMockHelper; |
11 | use Shaarli\Front\Controller\Admin\ManageShaareController; | 10 | use Shaarli\Front\Controller\Admin\ManageShaareController; |
12 | use Shaarli\Http\HttpAccess; | 11 | use Shaarli\Http\HttpAccess; |
12 | use Shaarli\TestCase; | ||
13 | use Slim\Http\Request; | 13 | use Slim\Http\Request; |
14 | use Slim\Http\Response; | 14 | use Slim\Http\Response; |
15 | 15 | ||
@@ -96,12 +96,14 @@ class DisplayCreateFormTest extends TestCase | |||
96 | 96 | ||
97 | // Make sure that PluginManager hook is triggered | 97 | // Make sure that PluginManager hook is triggered |
98 | $this->container->pluginManager | 98 | $this->container->pluginManager |
99 | ->expects(static::at(0)) | 99 | ->expects(static::atLeastOnce()) |
100 | ->method('executeHooks') | 100 | ->method('executeHooks') |
101 | ->withConsecutive(['render_editlink'], ['render_includes']) | ||
101 | ->willReturnCallback(function (string $hook, array $data) use ($remoteTitle, $remoteDesc): array { | 102 | ->willReturnCallback(function (string $hook, array $data) use ($remoteTitle, $remoteDesc): array { |
102 | static::assertSame('render_editlink', $hook); | 103 | if ('render_editlink' === $hook) { |
103 | static::assertSame($remoteTitle, $data['link']['title']); | 104 | static::assertSame($remoteTitle, $data['link']['title']); |
104 | static::assertSame($remoteDesc, $data['link']['description']); | 105 | static::assertSame($remoteDesc, $data['link']['description']); |
106 | } | ||
105 | 107 | ||
106 | return $data; | 108 | return $data; |
107 | }) | 109 | }) |
diff --git a/tests/front/controller/admin/ManageShaareControllerTest/DisplayEditFormTest.php b/tests/front/controller/admin/ManageShaareControllerTest/DisplayEditFormTest.php index 1a1cdcf3..2dc3f41c 100644 --- a/tests/front/controller/admin/ManageShaareControllerTest/DisplayEditFormTest.php +++ b/tests/front/controller/admin/ManageShaareControllerTest/DisplayEditFormTest.php | |||
@@ -4,13 +4,13 @@ declare(strict_types=1); | |||
4 | 4 | ||
5 | namespace Shaarli\Front\Controller\Admin\ManageShaareControllerTest; | 5 | namespace Shaarli\Front\Controller\Admin\ManageShaareControllerTest; |
6 | 6 | ||
7 | use PHPUnit\Framework\TestCase; | ||
8 | use Shaarli\Bookmark\Bookmark; | 7 | use Shaarli\Bookmark\Bookmark; |
9 | use Shaarli\Bookmark\Exception\BookmarkNotFoundException; | 8 | use Shaarli\Bookmark\Exception\BookmarkNotFoundException; |
10 | use Shaarli\Front\Controller\Admin\FrontAdminControllerMockHelper; | 9 | use Shaarli\Front\Controller\Admin\FrontAdminControllerMockHelper; |
11 | use Shaarli\Front\Controller\Admin\ManageShaareController; | 10 | use Shaarli\Front\Controller\Admin\ManageShaareController; |
12 | use Shaarli\Http\HttpAccess; | 11 | use Shaarli\Http\HttpAccess; |
13 | use Shaarli\Security\SessionManager; | 12 | use Shaarli\Security\SessionManager; |
13 | use Shaarli\TestCase; | ||
14 | use Slim\Http\Request; | 14 | use Slim\Http\Request; |
15 | use Slim\Http\Response; | 15 | use Slim\Http\Response; |
16 | 16 | ||
diff --git a/tests/front/controller/admin/ManageShaareControllerTest/PinBookmarkTest.php b/tests/front/controller/admin/ManageShaareControllerTest/PinBookmarkTest.php index 1607b475..50ce7df1 100644 --- a/tests/front/controller/admin/ManageShaareControllerTest/PinBookmarkTest.php +++ b/tests/front/controller/admin/ManageShaareControllerTest/PinBookmarkTest.php | |||
@@ -4,13 +4,13 @@ declare(strict_types=1); | |||
4 | 4 | ||
5 | namespace Shaarli\Front\Controller\Admin\ManageShaareControllerTest; | 5 | namespace Shaarli\Front\Controller\Admin\ManageShaareControllerTest; |
6 | 6 | ||
7 | use PHPUnit\Framework\TestCase; | ||
8 | use Shaarli\Bookmark\Bookmark; | 7 | use Shaarli\Bookmark\Bookmark; |
9 | use Shaarli\Bookmark\Exception\BookmarkNotFoundException; | 8 | use Shaarli\Bookmark\Exception\BookmarkNotFoundException; |
10 | use Shaarli\Front\Controller\Admin\FrontAdminControllerMockHelper; | 9 | use Shaarli\Front\Controller\Admin\FrontAdminControllerMockHelper; |
11 | use Shaarli\Front\Controller\Admin\ManageShaareController; | 10 | use Shaarli\Front\Controller\Admin\ManageShaareController; |
12 | use Shaarli\Http\HttpAccess; | 11 | use Shaarli\Http\HttpAccess; |
13 | use Shaarli\Security\SessionManager; | 12 | use Shaarli\Security\SessionManager; |
13 | use Shaarli\TestCase; | ||
14 | use Slim\Http\Request; | 14 | use Slim\Http\Request; |
15 | use Slim\Http\Response; | 15 | use Slim\Http\Response; |
16 | 16 | ||
diff --git a/tests/front/controller/admin/ManageShaareControllerTest/SaveBookmarkTest.php b/tests/front/controller/admin/ManageShaareControllerTest/SaveBookmarkTest.php index dabcd60d..f7a68226 100644 --- a/tests/front/controller/admin/ManageShaareControllerTest/SaveBookmarkTest.php +++ b/tests/front/controller/admin/ManageShaareControllerTest/SaveBookmarkTest.php | |||
@@ -4,7 +4,6 @@ declare(strict_types=1); | |||
4 | 4 | ||
5 | namespace Shaarli\Front\Controller\Admin\ManageShaareControllerTest; | 5 | namespace Shaarli\Front\Controller\Admin\ManageShaareControllerTest; |
6 | 6 | ||
7 | use PHPUnit\Framework\TestCase; | ||
8 | use Shaarli\Bookmark\Bookmark; | 7 | use Shaarli\Bookmark\Bookmark; |
9 | use Shaarli\Config\ConfigManager; | 8 | use Shaarli\Config\ConfigManager; |
10 | use Shaarli\Front\Controller\Admin\FrontAdminControllerMockHelper; | 9 | use Shaarli\Front\Controller\Admin\FrontAdminControllerMockHelper; |
@@ -12,6 +11,7 @@ use Shaarli\Front\Controller\Admin\ManageShaareController; | |||
12 | use Shaarli\Front\Exception\WrongTokenException; | 11 | use Shaarli\Front\Exception\WrongTokenException; |
13 | use Shaarli\Http\HttpAccess; | 12 | use Shaarli\Http\HttpAccess; |
14 | use Shaarli\Security\SessionManager; | 13 | use Shaarli\Security\SessionManager; |
14 | use Shaarli\TestCase; | ||
15 | use Shaarli\Thumbnailer; | 15 | use Shaarli\Thumbnailer; |
16 | use Slim\Http\Request; | 16 | use Slim\Http\Request; |
17 | use Slim\Http\Response; | 17 | use Slim\Http\Response; |
@@ -43,7 +43,7 @@ class SaveBookmarkTest extends TestCase | |||
43 | 'lf_description' => 'Provided description.', | 43 | 'lf_description' => 'Provided description.', |
44 | 'lf_tags' => 'abc def', | 44 | 'lf_tags' => 'abc def', |
45 | 'lf_private' => '1', | 45 | 'lf_private' => '1', |
46 | 'returnurl' => 'http://shaarli.tld/subfolder/admin/add-shaare' | 46 | 'returnurl' => 'http://shaarli/subfolder/admin/add-shaare' |
47 | ]; | 47 | ]; |
48 | 48 | ||
49 | $request = $this->createMock(Request::class); | 49 | $request = $this->createMock(Request::class); |
@@ -88,17 +88,18 @@ class SaveBookmarkTest extends TestCase | |||
88 | 88 | ||
89 | // Make sure that PluginManager hook is triggered | 89 | // Make sure that PluginManager hook is triggered |
90 | $this->container->pluginManager | 90 | $this->container->pluginManager |
91 | ->expects(static::at(0)) | 91 | ->expects(static::atLeastOnce()) |
92 | ->method('executeHooks') | 92 | ->method('executeHooks') |
93 | ->withConsecutive(['save_link']) | ||
93 | ->willReturnCallback(function (string $hook, array $data) use ($parameters, $id): array { | 94 | ->willReturnCallback(function (string $hook, array $data) use ($parameters, $id): array { |
94 | static::assertSame('save_link', $hook); | 95 | if ('save_link' === $hook) { |
95 | 96 | static::assertSame($id, $data['id']); | |
96 | static::assertSame($id, $data['id']); | 97 | static::assertSame($parameters['lf_url'], $data['url']); |
97 | static::assertSame($parameters['lf_url'], $data['url']); | 98 | static::assertSame($parameters['lf_title'], $data['title']); |
98 | static::assertSame($parameters['lf_title'], $data['title']); | 99 | static::assertSame($parameters['lf_description'], $data['description']); |
99 | static::assertSame($parameters['lf_description'], $data['description']); | 100 | static::assertSame($parameters['lf_tags'], $data['tags']); |
100 | static::assertSame($parameters['lf_tags'], $data['tags']); | 101 | static::assertTrue($data['private']); |
101 | static::assertTrue($data['private']); | 102 | } |
102 | 103 | ||
103 | return $data; | 104 | return $data; |
104 | }) | 105 | }) |
@@ -124,7 +125,7 @@ class SaveBookmarkTest extends TestCase | |||
124 | 'lf_description' => 'Provided description.', | 125 | 'lf_description' => 'Provided description.', |
125 | 'lf_tags' => 'abc def', | 126 | 'lf_tags' => 'abc def', |
126 | 'lf_private' => '1', | 127 | 'lf_private' => '1', |
127 | 'returnurl' => 'http://shaarli.tld/subfolder/?page=2' | 128 | 'returnurl' => 'http://shaarli/subfolder/?page=2' |
128 | ]; | 129 | ]; |
129 | 130 | ||
130 | $request = $this->createMock(Request::class); | 131 | $request = $this->createMock(Request::class); |
@@ -174,17 +175,18 @@ class SaveBookmarkTest extends TestCase | |||
174 | 175 | ||
175 | // Make sure that PluginManager hook is triggered | 176 | // Make sure that PluginManager hook is triggered |
176 | $this->container->pluginManager | 177 | $this->container->pluginManager |
177 | ->expects(static::at(0)) | 178 | ->expects(static::atLeastOnce()) |
178 | ->method('executeHooks') | 179 | ->method('executeHooks') |
180 | ->withConsecutive(['save_link']) | ||
179 | ->willReturnCallback(function (string $hook, array $data) use ($parameters, $id): array { | 181 | ->willReturnCallback(function (string $hook, array $data) use ($parameters, $id): array { |
180 | static::assertSame('save_link', $hook); | 182 | if ('save_link' === $hook) { |
181 | 183 | static::assertSame($id, $data['id']); | |
182 | static::assertSame($id, $data['id']); | 184 | static::assertSame($parameters['lf_url'], $data['url']); |
183 | static::assertSame($parameters['lf_url'], $data['url']); | 185 | static::assertSame($parameters['lf_title'], $data['title']); |
184 | static::assertSame($parameters['lf_title'], $data['title']); | 186 | static::assertSame($parameters['lf_description'], $data['description']); |
185 | static::assertSame($parameters['lf_description'], $data['description']); | 187 | static::assertSame($parameters['lf_tags'], $data['tags']); |
186 | static::assertSame($parameters['lf_tags'], $data['tags']); | 188 | static::assertTrue($data['private']); |
187 | static::assertTrue($data['private']); | 189 | } |
188 | 190 | ||
189 | return $data; | 191 | return $data; |
190 | }) | 192 | }) |
@@ -239,6 +241,30 @@ class SaveBookmarkTest extends TestCase | |||
239 | } | 241 | } |
240 | 242 | ||
241 | /** | 243 | /** |
244 | * Test save a bookmark - with ID #0 | ||
245 | */ | ||
246 | public function testSaveBookmarkWithIdZero(): void | ||
247 | { | ||
248 | $parameters = ['lf_id' => '0']; | ||
249 | |||
250 | $request = $this->createMock(Request::class); | ||
251 | $request | ||
252 | ->method('getParam') | ||
253 | ->willReturnCallback(function (string $key) use ($parameters): ?string { | ||
254 | return $parameters[$key] ?? null; | ||
255 | }) | ||
256 | ; | ||
257 | $response = new Response(); | ||
258 | |||
259 | $this->container->bookmarkService->expects(static::once())->method('exists')->with(0)->willReturn(true); | ||
260 | $this->container->bookmarkService->expects(static::once())->method('get')->with(0)->willReturn(new Bookmark()); | ||
261 | |||
262 | $result = $this->controller->save($request, $response); | ||
263 | |||
264 | static::assertSame(302, $result->getStatusCode()); | ||
265 | } | ||
266 | |||
267 | /** | ||
242 | * Change the password with a wrong existing password | 268 | * Change the password with a wrong existing password |
243 | */ | 269 | */ |
244 | public function testSaveBookmarkFromBookmarklet(): void | 270 | public function testSaveBookmarkFromBookmarklet(): void |
diff --git a/tests/front/controller/admin/ManageTagControllerTest.php b/tests/front/controller/admin/ManageTagControllerTest.php index 09ba0b4b..8a0ff7a9 100644 --- a/tests/front/controller/admin/ManageTagControllerTest.php +++ b/tests/front/controller/admin/ManageTagControllerTest.php | |||
@@ -4,11 +4,11 @@ declare(strict_types=1); | |||
4 | 4 | ||
5 | namespace Shaarli\Front\Controller\Admin; | 5 | namespace Shaarli\Front\Controller\Admin; |
6 | 6 | ||
7 | use PHPUnit\Framework\TestCase; | ||
8 | use Shaarli\Bookmark\Bookmark; | 7 | use Shaarli\Bookmark\Bookmark; |
9 | use Shaarli\Bookmark\BookmarkFilter; | 8 | use Shaarli\Bookmark\BookmarkFilter; |
10 | use Shaarli\Front\Exception\WrongTokenException; | 9 | use Shaarli\Front\Exception\WrongTokenException; |
11 | use Shaarli\Security\SessionManager; | 10 | use Shaarli\Security\SessionManager; |
11 | use Shaarli\TestCase; | ||
12 | use Slim\Http\Request; | 12 | use Slim\Http\Request; |
13 | use Slim\Http\Response; | 13 | use Slim\Http\Response; |
14 | 14 | ||
diff --git a/tests/front/controller/admin/PasswordControllerTest.php b/tests/front/controller/admin/PasswordControllerTest.php index 9a01089e..58f47b49 100644 --- a/tests/front/controller/admin/PasswordControllerTest.php +++ b/tests/front/controller/admin/PasswordControllerTest.php | |||
@@ -4,11 +4,11 @@ declare(strict_types=1); | |||
4 | 4 | ||
5 | namespace Shaarli\Front\Controller\Admin; | 5 | namespace Shaarli\Front\Controller\Admin; |
6 | 6 | ||
7 | use PHPUnit\Framework\TestCase; | ||
8 | use Shaarli\Config\ConfigManager; | 7 | use Shaarli\Config\ConfigManager; |
9 | use Shaarli\Front\Exception\OpenShaarliPasswordException; | 8 | use Shaarli\Front\Exception\OpenShaarliPasswordException; |
10 | use Shaarli\Front\Exception\WrongTokenException; | 9 | use Shaarli\Front\Exception\WrongTokenException; |
11 | use Shaarli\Security\SessionManager; | 10 | use Shaarli\Security\SessionManager; |
11 | use Shaarli\TestCase; | ||
12 | use Slim\Http\Request; | 12 | use Slim\Http\Request; |
13 | use Slim\Http\Response; | 13 | use Slim\Http\Response; |
14 | 14 | ||
diff --git a/tests/front/controller/admin/PluginsControllerTest.php b/tests/front/controller/admin/PluginsControllerTest.php index 5b59285c..974d614d 100644 --- a/tests/front/controller/admin/PluginsControllerTest.php +++ b/tests/front/controller/admin/PluginsControllerTest.php | |||
@@ -4,11 +4,11 @@ declare(strict_types=1); | |||
4 | 4 | ||
5 | namespace Shaarli\Front\Controller\Admin; | 5 | namespace Shaarli\Front\Controller\Admin; |
6 | 6 | ||
7 | use PHPUnit\Framework\TestCase; | ||
8 | use Shaarli\Config\ConfigManager; | 7 | use Shaarli\Config\ConfigManager; |
9 | use Shaarli\Front\Exception\WrongTokenException; | 8 | use Shaarli\Front\Exception\WrongTokenException; |
10 | use Shaarli\Plugin\PluginManager; | 9 | use Shaarli\Plugin\PluginManager; |
11 | use Shaarli\Security\SessionManager; | 10 | use Shaarli\Security\SessionManager; |
11 | use Shaarli\TestCase; | ||
12 | use Slim\Http\Request; | 12 | use Slim\Http\Request; |
13 | use Slim\Http\Response; | 13 | use Slim\Http\Response; |
14 | 14 | ||
@@ -32,7 +32,7 @@ class PluginsControllerTest extends TestCase | |||
32 | array_map(function (string $plugin) use ($path) { touch($path . '/' . $plugin); }, static::PLUGIN_NAMES); | 32 | array_map(function (string $plugin) use ($path) { touch($path . '/' . $plugin); }, static::PLUGIN_NAMES); |
33 | } | 33 | } |
34 | 34 | ||
35 | public function tearDown() | 35 | public function tearDown(): void |
36 | { | 36 | { |
37 | $path = __DIR__ . '/folder'; | 37 | $path = __DIR__ . '/folder'; |
38 | array_map(function (string $plugin) use ($path) { unlink($path . '/' . $plugin); }, static::PLUGIN_NAMES); | 38 | array_map(function (string $plugin) use ($path) { unlink($path . '/' . $plugin); }, static::PLUGIN_NAMES); |
@@ -125,6 +125,7 @@ class PluginsControllerTest extends TestCase | |||
125 | 'parameters_form' => true, | 125 | 'parameters_form' => true, |
126 | 'parameter1' => 'blip', | 126 | 'parameter1' => 'blip', |
127 | 'parameter2' => 'blop', | 127 | 'parameter2' => 'blop', |
128 | 'token' => 'this parameter should not be saved' | ||
128 | ]; | 129 | ]; |
129 | 130 | ||
130 | $request = $this->createMock(Request::class); | 131 | $request = $this->createMock(Request::class); |
@@ -143,7 +144,7 @@ class PluginsControllerTest extends TestCase | |||
143 | ->with('save_plugin_parameters', $parameters) | 144 | ->with('save_plugin_parameters', $parameters) |
144 | ; | 145 | ; |
145 | $this->container->conf | 146 | $this->container->conf |
146 | ->expects(static::atLeastOnce()) | 147 | ->expects(static::exactly(2)) |
147 | ->method('set') | 148 | ->method('set') |
148 | ->withConsecutive(['plugins.parameter1', 'blip'], ['plugins.parameter2', 'blop']) | 149 | ->withConsecutive(['plugins.parameter1', 'blip'], ['plugins.parameter2', 'blop']) |
149 | ; | 150 | ; |
diff --git a/tests/front/controller/admin/SessionFilterControllerTest.php b/tests/front/controller/admin/SessionFilterControllerTest.php index d306c6e9..712a625b 100644 --- a/tests/front/controller/admin/SessionFilterControllerTest.php +++ b/tests/front/controller/admin/SessionFilterControllerTest.php | |||
@@ -4,9 +4,9 @@ declare(strict_types=1); | |||
4 | 4 | ||
5 | namespace Shaarli\Front\Controller\Admin; | 5 | namespace Shaarli\Front\Controller\Admin; |
6 | 6 | ||
7 | use PHPUnit\Framework\TestCase; | ||
8 | use Shaarli\Security\LoginManager; | 7 | use Shaarli\Security\LoginManager; |
9 | use Shaarli\Security\SessionManager; | 8 | use Shaarli\Security\SessionManager; |
9 | use Shaarli\TestCase; | ||
10 | use Slim\Http\Request; | 10 | use Slim\Http\Request; |
11 | use Slim\Http\Response; | 11 | use Slim\Http\Response; |
12 | 12 | ||
@@ -31,7 +31,7 @@ class SessionFilterControllerTest extends TestCase | |||
31 | { | 31 | { |
32 | $arg = ['visibility' => 'private']; | 32 | $arg = ['visibility' => 'private']; |
33 | 33 | ||
34 | $this->container->environment = ['HTTP_REFERER' => 'http://shaarli/subfolder/controller/?searchtag=abc']; | 34 | $this->container->environment['HTTP_REFERER'] = 'http://shaarli/subfolder/controller/?searchtag=abc'; |
35 | 35 | ||
36 | $this->container->loginManager->method('isLoggedIn')->willReturn(true); | 36 | $this->container->loginManager->method('isLoggedIn')->willReturn(true); |
37 | $this->container->sessionManager | 37 | $this->container->sessionManager |
@@ -57,7 +57,7 @@ class SessionFilterControllerTest extends TestCase | |||
57 | { | 57 | { |
58 | $arg = ['visibility' => 'private']; | 58 | $arg = ['visibility' => 'private']; |
59 | 59 | ||
60 | $this->container->environment = ['HTTP_REFERER' => 'http://shaarli/subfolder/controller/?searchtag=abc']; | 60 | $this->container->environment['HTTP_REFERER'] = 'http://shaarli/subfolder/controller/?searchtag=abc'; |
61 | 61 | ||
62 | $this->container->loginManager->method('isLoggedIn')->willReturn(true); | 62 | $this->container->loginManager->method('isLoggedIn')->willReturn(true); |
63 | $this->container->sessionManager | 63 | $this->container->sessionManager |
@@ -121,7 +121,7 @@ class SessionFilterControllerTest extends TestCase | |||
121 | { | 121 | { |
122 | $arg = ['visibility' => 'test']; | 122 | $arg = ['visibility' => 'test']; |
123 | 123 | ||
124 | $this->container->environment = ['HTTP_REFERER' => 'http://shaarli/subfolder/controller/?searchtag=abc']; | 124 | $this->container->environment['HTTP_REFERER'] = 'http://shaarli/subfolder/controller/?searchtag=abc'; |
125 | 125 | ||
126 | $this->container->loginManager->method('isLoggedIn')->willReturn(true); | 126 | $this->container->loginManager->method('isLoggedIn')->willReturn(true); |
127 | $this->container->sessionManager | 127 | $this->container->sessionManager |
@@ -151,7 +151,7 @@ class SessionFilterControllerTest extends TestCase | |||
151 | { | 151 | { |
152 | $arg = ['visibility' => 'test']; | 152 | $arg = ['visibility' => 'test']; |
153 | 153 | ||
154 | $this->container->environment = ['HTTP_REFERER' => 'http://shaarli/subfolder/controller/?searchtag=abc']; | 154 | $this->container->environment['HTTP_REFERER'] = 'http://shaarli/subfolder/controller/?searchtag=abc'; |
155 | 155 | ||
156 | $this->container->loginManager = $this->createMock(LoginManager::class); | 156 | $this->container->loginManager = $this->createMock(LoginManager::class); |
157 | $this->container->loginManager->method('isLoggedIn')->willReturn(false); | 157 | $this->container->loginManager->method('isLoggedIn')->willReturn(false); |
diff --git a/tests/front/controller/admin/ShaarliAdminControllerTest.php b/tests/front/controller/admin/ShaarliAdminControllerTest.php index fff427cb..486d5d2d 100644 --- a/tests/front/controller/admin/ShaarliAdminControllerTest.php +++ b/tests/front/controller/admin/ShaarliAdminControllerTest.php | |||
@@ -4,9 +4,9 @@ declare(strict_types=1); | |||
4 | 4 | ||
5 | namespace Shaarli\Front\Controller\Admin; | 5 | namespace Shaarli\Front\Controller\Admin; |
6 | 6 | ||
7 | use PHPUnit\Framework\TestCase; | ||
8 | use Shaarli\Front\Exception\WrongTokenException; | 7 | use Shaarli\Front\Exception\WrongTokenException; |
9 | use Shaarli\Security\SessionManager; | 8 | use Shaarli\Security\SessionManager; |
9 | use Shaarli\TestCase; | ||
10 | use Slim\Http\Request; | 10 | use Slim\Http\Request; |
11 | 11 | ||
12 | /** | 12 | /** |
diff --git a/tests/front/controller/admin/ThumbnailsControllerTest.php b/tests/front/controller/admin/ThumbnailsControllerTest.php index 0c0c8a83..f4a8acff 100644 --- a/tests/front/controller/admin/ThumbnailsControllerTest.php +++ b/tests/front/controller/admin/ThumbnailsControllerTest.php | |||
@@ -4,9 +4,9 @@ declare(strict_types=1); | |||
4 | 4 | ||
5 | namespace Shaarli\Front\Controller\Admin; | 5 | namespace Shaarli\Front\Controller\Admin; |
6 | 6 | ||
7 | use PHPUnit\Framework\TestCase; | ||
8 | use Shaarli\Bookmark\Bookmark; | 7 | use Shaarli\Bookmark\Bookmark; |
9 | use Shaarli\Bookmark\Exception\BookmarkNotFoundException; | 8 | use Shaarli\Bookmark\Exception\BookmarkNotFoundException; |
9 | use Shaarli\TestCase; | ||
10 | use Shaarli\Thumbnailer; | 10 | use Shaarli\Thumbnailer; |
11 | use Slim\Http\Request; | 11 | use Slim\Http\Request; |
12 | use Slim\Http\Response; | 12 | use Slim\Http\Response; |
diff --git a/tests/front/controller/admin/TokenControllerTest.php b/tests/front/controller/admin/TokenControllerTest.php index 04b0c0fa..d2f0907f 100644 --- a/tests/front/controller/admin/TokenControllerTest.php +++ b/tests/front/controller/admin/TokenControllerTest.php | |||
@@ -4,7 +4,7 @@ declare(strict_types=1); | |||
4 | 4 | ||
5 | namespace Shaarli\Front\Controller\Admin; | 5 | namespace Shaarli\Front\Controller\Admin; |
6 | 6 | ||
7 | use PHPUnit\Framework\TestCase; | 7 | use Shaarli\TestCase; |
8 | use Slim\Http\Request; | 8 | use Slim\Http\Request; |
9 | use Slim\Http\Response; | 9 | use Slim\Http\Response; |
10 | 10 | ||
diff --git a/tests/front/controller/admin/ToolsControllerTest.php b/tests/front/controller/admin/ToolsControllerTest.php index fc756f0f..e82f8b14 100644 --- a/tests/front/controller/admin/ToolsControllerTest.php +++ b/tests/front/controller/admin/ToolsControllerTest.php | |||
@@ -4,11 +4,11 @@ declare(strict_types=1); | |||
4 | 4 | ||
5 | namespace Shaarli\Front\Controller\Admin; | 5 | namespace Shaarli\Front\Controller\Admin; |
6 | 6 | ||
7 | use PHPUnit\Framework\TestCase; | 7 | use Shaarli\TestCase; |
8 | use Slim\Http\Request; | 8 | use Slim\Http\Request; |
9 | use Slim\Http\Response; | 9 | use Slim\Http\Response; |
10 | 10 | ||
11 | class ToolsControllerTestControllerTest extends TestCase | 11 | class ToolsControllerTest extends TestCase |
12 | { | 12 | { |
13 | use FrontAdminControllerMockHelper; | 13 | use FrontAdminControllerMockHelper; |
14 | 14 | ||
@@ -41,7 +41,7 @@ class ToolsControllerTestControllerTest extends TestCase | |||
41 | 41 | ||
42 | static::assertSame(200, $result->getStatusCode()); | 42 | static::assertSame(200, $result->getStatusCode()); |
43 | static::assertSame('tools', (string) $result->getBody()); | 43 | static::assertSame('tools', (string) $result->getBody()); |
44 | static::assertSame('https://shaarli', $assignedVariables['pageabsaddr']); | 44 | static::assertSame('https://shaarli/', $assignedVariables['pageabsaddr']); |
45 | static::assertTrue($assignedVariables['sslenabled']); | 45 | static::assertTrue($assignedVariables['sslenabled']); |
46 | } | 46 | } |
47 | 47 | ||
@@ -63,7 +63,7 @@ class ToolsControllerTestControllerTest extends TestCase | |||
63 | 63 | ||
64 | static::assertSame(200, $result->getStatusCode()); | 64 | static::assertSame(200, $result->getStatusCode()); |
65 | static::assertSame('tools', (string) $result->getBody()); | 65 | static::assertSame('tools', (string) $result->getBody()); |
66 | static::assertSame('http://shaarli', $assignedVariables['pageabsaddr']); | 66 | static::assertSame('http://shaarli/', $assignedVariables['pageabsaddr']); |
67 | static::assertFalse($assignedVariables['sslenabled']); | 67 | static::assertFalse($assignedVariables['sslenabled']); |
68 | } | 68 | } |
69 | } | 69 | } |