diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-06-13 13:08:01 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2020-07-23 21:19:21 +0200 |
commit | 9c75f877935fa6adec951a4d8d32b328aaab314f (patch) | |
tree | 1cdd09ddfc00c6cebb92bb2b90381a06fd31246d /tests | |
parent | 818b3193ffabec57501e3bdfa997206e3c0671ef (diff) | |
download | Shaarli-9c75f877935fa6adec951a4d8d32b328aaab314f.tar.gz Shaarli-9c75f877935fa6adec951a4d8d32b328aaab314f.tar.zst Shaarli-9c75f877935fa6adec951a4d8d32b328aaab314f.zip |
Use multi-level routes for existing controllers instead of 1 level everywhere
Also prefix most admin routes with /admin/
Diffstat (limited to 'tests')
8 files changed, 33 insertions, 24 deletions
diff --git a/tests/container/ContainerBuilderTest.php b/tests/container/ContainerBuilderTest.php index 65647249..db533f37 100644 --- a/tests/container/ContainerBuilderTest.php +++ b/tests/container/ContainerBuilderTest.php | |||
@@ -7,12 +7,16 @@ namespace Shaarli\Container; | |||
7 | use PHPUnit\Framework\TestCase; | 7 | use PHPUnit\Framework\TestCase; |
8 | use Shaarli\Bookmark\BookmarkServiceInterface; | 8 | use Shaarli\Bookmark\BookmarkServiceInterface; |
9 | use Shaarli\Config\ConfigManager; | 9 | use Shaarli\Config\ConfigManager; |
10 | use Shaarli\Feed\FeedBuilder; | ||
10 | use Shaarli\Formatter\FormatterFactory; | 11 | use Shaarli\Formatter\FormatterFactory; |
11 | use Shaarli\History; | 12 | use Shaarli\History; |
13 | use Shaarli\Http\HttpAccess; | ||
14 | use Shaarli\Plugin\PluginManager; | ||
12 | use Shaarli\Render\PageBuilder; | 15 | use Shaarli\Render\PageBuilder; |
13 | use Shaarli\Render\PageCacheManager; | 16 | use Shaarli\Render\PageCacheManager; |
14 | use Shaarli\Security\LoginManager; | 17 | use Shaarli\Security\LoginManager; |
15 | use Shaarli\Security\SessionManager; | 18 | use Shaarli\Security\SessionManager; |
19 | use Shaarli\Thumbnailer; | ||
16 | 20 | ||
17 | class ContainerBuilderTest extends TestCase | 21 | class ContainerBuilderTest extends TestCase |
18 | { | 22 | { |
@@ -39,8 +43,7 @@ class ContainerBuilderTest extends TestCase | |||
39 | $this->containerBuilder = new ContainerBuilder( | 43 | $this->containerBuilder = new ContainerBuilder( |
40 | $this->conf, | 44 | $this->conf, |
41 | $this->sessionManager, | 45 | $this->sessionManager, |
42 | $this->loginManager, | 46 | $this->loginManager |
43 | 'UT web path' | ||
44 | ); | 47 | ); |
45 | } | 48 | } |
46 | 49 | ||
@@ -51,11 +54,17 @@ class ContainerBuilderTest extends TestCase | |||
51 | static::assertInstanceOf(ConfigManager::class, $container->conf); | 54 | static::assertInstanceOf(ConfigManager::class, $container->conf); |
52 | static::assertInstanceOf(SessionManager::class, $container->sessionManager); | 55 | static::assertInstanceOf(SessionManager::class, $container->sessionManager); |
53 | static::assertInstanceOf(LoginManager::class, $container->loginManager); | 56 | static::assertInstanceOf(LoginManager::class, $container->loginManager); |
54 | static::assertSame('UT web path', $container->webPath); | ||
55 | static::assertInstanceOf(History::class, $container->history); | 57 | static::assertInstanceOf(History::class, $container->history); |
56 | static::assertInstanceOf(BookmarkServiceInterface::class, $container->bookmarkService); | 58 | static::assertInstanceOf(BookmarkServiceInterface::class, $container->bookmarkService); |
57 | static::assertInstanceOf(PageBuilder::class, $container->pageBuilder); | 59 | static::assertInstanceOf(PageBuilder::class, $container->pageBuilder); |
60 | static::assertInstanceOf(PluginManager::class, $container->pluginManager); | ||
58 | static::assertInstanceOf(FormatterFactory::class, $container->formatterFactory); | 61 | static::assertInstanceOf(FormatterFactory::class, $container->formatterFactory); |
59 | static::assertInstanceOf(PageCacheManager::class, $container->pageCacheManager); | 62 | static::assertInstanceOf(PageCacheManager::class, $container->pageCacheManager); |
63 | static::assertInstanceOf(FeedBuilder::class, $container->feedBuilder); | ||
64 | static::assertInstanceOf(Thumbnailer::class, $container->thumbnailer); | ||
65 | static::assertInstanceOf(HttpAccess::class, $container->httpAccess); | ||
66 | |||
67 | // Set by the middleware | ||
68 | static::assertNull($container->basePath); | ||
60 | } | 69 | } |
61 | } | 70 | } |
diff --git a/tests/feed/CachedPageTest.php b/tests/feed/CachedPageTest.php index 57f3b09b..2e716432 100644 --- a/tests/feed/CachedPageTest.php +++ b/tests/feed/CachedPageTest.php | |||
@@ -11,7 +11,7 @@ class CachedPageTest extends \PHPUnit\Framework\TestCase | |||
11 | { | 11 | { |
12 | // test cache directory | 12 | // test cache directory |
13 | protected static $testCacheDir = 'sandbox/pagecache'; | 13 | protected static $testCacheDir = 'sandbox/pagecache'; |
14 | protected static $url = 'http://shaar.li/feed-atom'; | 14 | protected static $url = 'http://shaar.li/feed/atom'; |
15 | protected static $filename; | 15 | protected static $filename; |
16 | 16 | ||
17 | /** | 17 | /** |
@@ -42,8 +42,8 @@ class CachedPageTest extends \PHPUnit\Framework\TestCase | |||
42 | { | 42 | { |
43 | new CachedPage(self::$testCacheDir, '', true); | 43 | new CachedPage(self::$testCacheDir, '', true); |
44 | new CachedPage(self::$testCacheDir, '', false); | 44 | new CachedPage(self::$testCacheDir, '', false); |
45 | new CachedPage(self::$testCacheDir, 'http://shaar.li/feed-rss', true); | 45 | new CachedPage(self::$testCacheDir, 'http://shaar.li/feed/rss', true); |
46 | new CachedPage(self::$testCacheDir, 'http://shaar.li/feed-atom', false); | 46 | new CachedPage(self::$testCacheDir, 'http://shaar.li/feed/atom', false); |
47 | $this->addToAssertionCount(1); | 47 | $this->addToAssertionCount(1); |
48 | } | 48 | } |
49 | 49 | ||
diff --git a/tests/front/controller/admin/ConfigureControllerTest.php b/tests/front/controller/admin/ConfigureControllerTest.php index 40304a18..f2f84bac 100644 --- a/tests/front/controller/admin/ConfigureControllerTest.php +++ b/tests/front/controller/admin/ConfigureControllerTest.php | |||
@@ -142,7 +142,7 @@ class ConfigureControllerTest extends TestCase | |||
142 | 142 | ||
143 | $result = $this->controller->save($request, $response); | 143 | $result = $this->controller->save($request, $response); |
144 | static::assertSame(302, $result->getStatusCode()); | 144 | static::assertSame(302, $result->getStatusCode()); |
145 | static::assertSame(['./configure'], $result->getHeader('Location')); | 145 | static::assertSame(['/subfolder/admin/configure'], $result->getHeader('Location')); |
146 | 146 | ||
147 | static::assertArrayNotHasKey(SessionManager::KEY_WARNING_MESSAGES, $session); | 147 | static::assertArrayNotHasKey(SessionManager::KEY_WARNING_MESSAGES, $session); |
148 | static::assertArrayNotHasKey(SessionManager::KEY_ERROR_MESSAGES, $session); | 148 | static::assertArrayNotHasKey(SessionManager::KEY_ERROR_MESSAGES, $session); |
@@ -193,7 +193,7 @@ class ConfigureControllerTest extends TestCase | |||
193 | $result = $this->controller->save($request, $response); | 193 | $result = $this->controller->save($request, $response); |
194 | 194 | ||
195 | static::assertSame(302, $result->getStatusCode()); | 195 | static::assertSame(302, $result->getStatusCode()); |
196 | static::assertSame(['./configure'], $result->getHeader('Location')); | 196 | static::assertSame(['/subfolder/admin/configure'], $result->getHeader('Location')); |
197 | 197 | ||
198 | static::assertArrayNotHasKey(SessionManager::KEY_ERROR_MESSAGES, $session); | 198 | static::assertArrayNotHasKey(SessionManager::KEY_ERROR_MESSAGES, $session); |
199 | static::assertArrayHasKey(SessionManager::KEY_WARNING_MESSAGES, $session); | 199 | static::assertArrayHasKey(SessionManager::KEY_WARNING_MESSAGES, $session); |
@@ -242,7 +242,7 @@ class ConfigureControllerTest extends TestCase | |||
242 | $result = $this->controller->save($request, $response); | 242 | $result = $this->controller->save($request, $response); |
243 | 243 | ||
244 | static::assertSame(302, $result->getStatusCode()); | 244 | static::assertSame(302, $result->getStatusCode()); |
245 | static::assertSame(['./configure'], $result->getHeader('Location')); | 245 | static::assertSame(['/subfolder/admin/configure'], $result->getHeader('Location')); |
246 | 246 | ||
247 | static::assertArrayNotHasKey(SessionManager::KEY_ERROR_MESSAGES, $session); | 247 | static::assertArrayNotHasKey(SessionManager::KEY_ERROR_MESSAGES, $session); |
248 | static::assertArrayNotHasKey(SessionManager::KEY_WARNING_MESSAGES, $session); | 248 | static::assertArrayNotHasKey(SessionManager::KEY_WARNING_MESSAGES, $session); |
diff --git a/tests/front/controller/admin/LogoutControllerTest.php b/tests/front/controller/admin/LogoutControllerTest.php index 78a0fe73..ca177085 100644 --- a/tests/front/controller/admin/LogoutControllerTest.php +++ b/tests/front/controller/admin/LogoutControllerTest.php | |||
@@ -49,7 +49,7 @@ class LogoutControllerTest extends TestCase | |||
49 | 49 | ||
50 | static::assertInstanceOf(Response::class, $result); | 50 | static::assertInstanceOf(Response::class, $result); |
51 | static::assertSame(302, $result->getStatusCode()); | 51 | static::assertSame(302, $result->getStatusCode()); |
52 | static::assertContains('./', $result->getHeader('Location')); | 52 | static::assertSame(['/subfolder/'], $result->getHeader('location')); |
53 | static::assertSame('false', $_COOKIE[LoginManager::$STAY_SIGNED_IN_COOKIE]); | 53 | static::assertSame('false', $_COOKIE[LoginManager::$STAY_SIGNED_IN_COOKIE]); |
54 | } | 54 | } |
55 | } | 55 | } |
diff --git a/tests/front/controller/admin/ManageTagControllerTest.php b/tests/front/controller/admin/ManageTagControllerTest.php index eed99231..09ba0b4b 100644 --- a/tests/front/controller/admin/ManageTagControllerTest.php +++ b/tests/front/controller/admin/ManageTagControllerTest.php | |||
@@ -93,7 +93,7 @@ class ManageTagControllerTest extends TestCase | |||
93 | $result = $this->controller->save($request, $response); | 93 | $result = $this->controller->save($request, $response); |
94 | 94 | ||
95 | static::assertSame(302, $result->getStatusCode()); | 95 | static::assertSame(302, $result->getStatusCode()); |
96 | static::assertSame(['./?searchtags=new-tag'], $result->getHeader('location')); | 96 | static::assertSame(['/subfolder/?searchtags=new-tag'], $result->getHeader('location')); |
97 | 97 | ||
98 | static::assertArrayNotHasKey(SessionManager::KEY_ERROR_MESSAGES, $session); | 98 | static::assertArrayNotHasKey(SessionManager::KEY_ERROR_MESSAGES, $session); |
99 | static::assertArrayNotHasKey(SessionManager::KEY_WARNING_MESSAGES, $session); | 99 | static::assertArrayNotHasKey(SessionManager::KEY_WARNING_MESSAGES, $session); |
@@ -146,7 +146,7 @@ class ManageTagControllerTest extends TestCase | |||
146 | $result = $this->controller->save($request, $response); | 146 | $result = $this->controller->save($request, $response); |
147 | 147 | ||
148 | static::assertSame(302, $result->getStatusCode()); | 148 | static::assertSame(302, $result->getStatusCode()); |
149 | static::assertSame(['./manage-tags'], $result->getHeader('location')); | 149 | static::assertSame(['/subfolder/admin/tags'], $result->getHeader('location')); |
150 | 150 | ||
151 | static::assertArrayNotHasKey(SessionManager::KEY_ERROR_MESSAGES, $session); | 151 | static::assertArrayNotHasKey(SessionManager::KEY_ERROR_MESSAGES, $session); |
152 | static::assertArrayNotHasKey(SessionManager::KEY_WARNING_MESSAGES, $session); | 152 | static::assertArrayNotHasKey(SessionManager::KEY_WARNING_MESSAGES, $session); |
@@ -197,7 +197,7 @@ class ManageTagControllerTest extends TestCase | |||
197 | $result = $this->controller->save($request, $response); | 197 | $result = $this->controller->save($request, $response); |
198 | 198 | ||
199 | static::assertSame(302, $result->getStatusCode()); | 199 | static::assertSame(302, $result->getStatusCode()); |
200 | static::assertSame(['./manage-tags'], $result->getHeader('location')); | 200 | static::assertSame(['/subfolder/admin/tags'], $result->getHeader('location')); |
201 | 201 | ||
202 | static::assertArrayNotHasKey(SessionManager::KEY_ERROR_MESSAGES, $session); | 202 | static::assertArrayNotHasKey(SessionManager::KEY_ERROR_MESSAGES, $session); |
203 | static::assertArrayHasKey(SessionManager::KEY_WARNING_MESSAGES, $session); | 203 | static::assertArrayHasKey(SessionManager::KEY_WARNING_MESSAGES, $session); |
@@ -229,7 +229,7 @@ class ManageTagControllerTest extends TestCase | |||
229 | $result = $this->controller->save($request, $response); | 229 | $result = $this->controller->save($request, $response); |
230 | 230 | ||
231 | static::assertSame(302, $result->getStatusCode()); | 231 | static::assertSame(302, $result->getStatusCode()); |
232 | static::assertSame(['./manage-tags'], $result->getHeader('location')); | 232 | static::assertSame(['/subfolder/admin/tags'], $result->getHeader('location')); |
233 | 233 | ||
234 | static::assertArrayNotHasKey(SessionManager::KEY_ERROR_MESSAGES, $session); | 234 | static::assertArrayNotHasKey(SessionManager::KEY_ERROR_MESSAGES, $session); |
235 | static::assertArrayHasKey(SessionManager::KEY_WARNING_MESSAGES, $session); | 235 | static::assertArrayHasKey(SessionManager::KEY_WARNING_MESSAGES, $session); |
@@ -262,7 +262,7 @@ class ManageTagControllerTest extends TestCase | |||
262 | $result = $this->controller->save($request, $response); | 262 | $result = $this->controller->save($request, $response); |
263 | 263 | ||
264 | static::assertSame(302, $result->getStatusCode()); | 264 | static::assertSame(302, $result->getStatusCode()); |
265 | static::assertSame(['./manage-tags'], $result->getHeader('location')); | 265 | static::assertSame(['/subfolder/admin/tags'], $result->getHeader('location')); |
266 | 266 | ||
267 | static::assertArrayNotHasKey(SessionManager::KEY_ERROR_MESSAGES, $session); | 267 | static::assertArrayNotHasKey(SessionManager::KEY_ERROR_MESSAGES, $session); |
268 | static::assertArrayHasKey(SessionManager::KEY_WARNING_MESSAGES, $session); | 268 | static::assertArrayHasKey(SessionManager::KEY_WARNING_MESSAGES, $session); |
diff --git a/tests/front/controller/admin/PostBookmarkControllerTest.php b/tests/front/controller/admin/PostBookmarkControllerTest.php index 69673bd2..8dcd1b50 100644 --- a/tests/front/controller/admin/PostBookmarkControllerTest.php +++ b/tests/front/controller/admin/PostBookmarkControllerTest.php | |||
@@ -395,7 +395,7 @@ class PostBookmarkControllerTest extends TestCase | |||
395 | 'lf_description' => 'Provided description.', | 395 | 'lf_description' => 'Provided description.', |
396 | 'lf_tags' => 'abc def', | 396 | 'lf_tags' => 'abc def', |
397 | 'lf_private' => '1', | 397 | 'lf_private' => '1', |
398 | 'returnurl' => 'http://shaarli.tld/subfolder/add-shaare' | 398 | 'returnurl' => 'http://shaarli.tld/subfolder/admin/add-shaare' |
399 | ]; | 399 | ]; |
400 | 400 | ||
401 | $request = $this->createMock(Request::class); | 401 | $request = $this->createMock(Request::class); |
@@ -459,7 +459,7 @@ class PostBookmarkControllerTest extends TestCase | |||
459 | $result = $this->controller->save($request, $response); | 459 | $result = $this->controller->save($request, $response); |
460 | 460 | ||
461 | static::assertSame(302, $result->getStatusCode()); | 461 | static::assertSame(302, $result->getStatusCode()); |
462 | static::assertRegExp('@/subfolder/#\w{6}@', $result->getHeader('location')[0]); | 462 | static::assertRegExp('@/subfolder/#[\w\-]{6}@', $result->getHeader('location')[0]); |
463 | } | 463 | } |
464 | 464 | ||
465 | 465 | ||
@@ -545,7 +545,7 @@ class PostBookmarkControllerTest extends TestCase | |||
545 | $result = $this->controller->save($request, $response); | 545 | $result = $this->controller->save($request, $response); |
546 | 546 | ||
547 | static::assertSame(302, $result->getStatusCode()); | 547 | static::assertSame(302, $result->getStatusCode()); |
548 | static::assertRegExp('@/subfolder/\?page=2#\w{6}@', $result->getHeader('location')[0]); | 548 | static::assertRegExp('@/subfolder/\?page=2#[\w\-]{6}@', $result->getHeader('location')[0]); |
549 | } | 549 | } |
550 | 550 | ||
551 | /** | 551 | /** |
diff --git a/tests/front/controller/visitor/LoginControllerTest.php b/tests/front/controller/visitor/LoginControllerTest.php index faa8ac71..e57f44b9 100644 --- a/tests/front/controller/visitor/LoginControllerTest.php +++ b/tests/front/controller/visitor/LoginControllerTest.php | |||
@@ -95,7 +95,7 @@ class LoginControllerTest extends TestCase | |||
95 | 95 | ||
96 | static::assertInstanceOf(Response::class, $result); | 96 | static::assertInstanceOf(Response::class, $result); |
97 | static::assertSame(302, $result->getStatusCode()); | 97 | static::assertSame(302, $result->getStatusCode()); |
98 | static::assertSame(['./'], $result->getHeader('Location')); | 98 | static::assertSame(['/subfolder/'], $result->getHeader('Location')); |
99 | } | 99 | } |
100 | 100 | ||
101 | public function testLoginControllerOpenShaarli(): void | 101 | public function testLoginControllerOpenShaarli(): void |
@@ -116,7 +116,7 @@ class LoginControllerTest extends TestCase | |||
116 | 116 | ||
117 | static::assertInstanceOf(Response::class, $result); | 117 | static::assertInstanceOf(Response::class, $result); |
118 | static::assertSame(302, $result->getStatusCode()); | 118 | static::assertSame(302, $result->getStatusCode()); |
119 | static::assertSame(['./'], $result->getHeader('Location')); | 119 | static::assertSame(['/subfolder/'], $result->getHeader('Location')); |
120 | } | 120 | } |
121 | 121 | ||
122 | public function testLoginControllerWhileBanned(): void | 122 | public function testLoginControllerWhileBanned(): void |
diff --git a/tests/front/controller/visitor/TagControllerTest.php b/tests/front/controller/visitor/TagControllerTest.php index 1242a2e9..43076086 100644 --- a/tests/front/controller/visitor/TagControllerTest.php +++ b/tests/front/controller/visitor/TagControllerTest.php | |||
@@ -64,7 +64,7 @@ class TagControllerTest extends TestCase | |||
64 | 64 | ||
65 | static::assertInstanceOf(Response::class, $result); | 65 | static::assertInstanceOf(Response::class, $result); |
66 | static::assertSame(302, $result->getStatusCode()); | 66 | static::assertSame(302, $result->getStatusCode()); |
67 | static::assertSame(['./?searchtags=abc'], $result->getHeader('location')); | 67 | static::assertSame(['/subfolder/?searchtags=abc'], $result->getHeader('location')); |
68 | } | 68 | } |
69 | 69 | ||
70 | public function testAddTagRemoveLegacyQueryParam(): void | 70 | public function testAddTagRemoveLegacyQueryParam(): void |
@@ -138,7 +138,7 @@ class TagControllerTest extends TestCase | |||
138 | 138 | ||
139 | static::assertInstanceOf(Response::class, $result); | 139 | static::assertInstanceOf(Response::class, $result); |
140 | static::assertSame(302, $result->getStatusCode()); | 140 | static::assertSame(302, $result->getStatusCode()); |
141 | static::assertSame(['./'], $result->getHeader('location')); | 141 | static::assertSame(['/subfolder/'], $result->getHeader('location')); |
142 | } | 142 | } |
143 | 143 | ||
144 | public function testRemoveTagWithoutMatchingTag(): void | 144 | public function testRemoveTagWithoutMatchingTag(): void |
@@ -184,7 +184,7 @@ class TagControllerTest extends TestCase | |||
184 | 184 | ||
185 | static::assertInstanceOf(Response::class, $result); | 185 | static::assertInstanceOf(Response::class, $result); |
186 | static::assertSame(302, $result->getStatusCode()); | 186 | static::assertSame(302, $result->getStatusCode()); |
187 | static::assertSame(['./'], $result->getHeader('location')); | 187 | static::assertSame(['/subfolder/'], $result->getHeader('location')); |
188 | } | 188 | } |
189 | 189 | ||
190 | public function testRemoveTagWithoutTag(): void | 190 | public function testRemoveTagWithoutTag(): void |
@@ -210,6 +210,6 @@ class TagControllerTest extends TestCase | |||
210 | 210 | ||
211 | static::assertInstanceOf(Response::class, $result); | 211 | static::assertInstanceOf(Response::class, $result); |
212 | static::assertSame(302, $result->getStatusCode()); | 212 | static::assertSame(302, $result->getStatusCode()); |
213 | static::assertSame(['./'], $result->getHeader('location')); | 213 | static::assertSame(['/subfolder/'], $result->getHeader('location')); |
214 | } | 214 | } |
215 | } | 215 | } |