]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - tests/front/controller/admin/PostBookmarkControllerTest.php
Use multi-level routes for existing controllers instead of 1 level everywhere
[github/shaarli/Shaarli.git] / tests / front / controller / admin / PostBookmarkControllerTest.php
index f00a15c96dcfd2d16b2c932dc72272d34fb1ca67..8dcd1b50d226f2657168fbaa3ca15ba296f71729 100644 (file)
@@ -13,7 +13,6 @@ use Shaarli\Security\SessionManager;
 use Shaarli\Thumbnailer;
 use Slim\Http\Request;
 use Slim\Http\Response;
-use Slim\Http\Uri;
 
 class PostBookmarkControllerTest extends TestCase
 {
@@ -396,7 +395,7 @@ class PostBookmarkControllerTest extends TestCase
             'lf_description' => 'Provided description.',
             'lf_tags' => 'abc def',
             'lf_private' => '1',
-            'returnurl' => 'http://shaarli.tld/subfolder/add-shaare'
+            'returnurl' => 'http://shaarli.tld/subfolder/admin/add-shaare'
         ];
 
         $request = $this->createMock(Request::class);
@@ -406,12 +405,6 @@ class PostBookmarkControllerTest extends TestCase
                 return $parameters[$key] ?? null;
             })
         ;
-        $request->method('getUri')->willReturnCallback(function (): Uri {
-            $uri = $this->createMock(Uri::class);
-            $uri->method('getBasePath')->willReturn('/subfolder');
-
-            return $uri;
-        });
         $response = new Response();
 
         $checkBookmark = function (Bookmark $bookmark) use ($parameters) {
@@ -466,7 +459,7 @@ class PostBookmarkControllerTest extends TestCase
         $result = $this->controller->save($request, $response);
 
         static::assertSame(302, $result->getStatusCode());
-        static::assertRegExp('@/subfolder/#\w{6}@', $result->getHeader('location')[0]);
+        static::assertRegExp('@/subfolder/#[\w\-]{6}@', $result->getHeader('location')[0]);
     }
 
 
@@ -493,12 +486,6 @@ class PostBookmarkControllerTest extends TestCase
                 return $parameters[$key] ?? null;
             })
         ;
-        $request->method('getUri')->willReturnCallback(function (): Uri {
-            $uri = $this->createMock(Uri::class);
-            $uri->method('getBasePath')->willReturn('/subfolder');
-
-            return $uri;
-        });
         $response = new Response();
 
         $checkBookmark = function (Bookmark $bookmark) use ($parameters, $id) {
@@ -558,7 +545,7 @@ class PostBookmarkControllerTest extends TestCase
         $result = $this->controller->save($request, $response);
 
         static::assertSame(302, $result->getStatusCode());
-        static::assertRegExp('@/subfolder/\?page=2#\w{6}@', $result->getHeader('location')[0]);
+        static::assertRegExp('@/subfolder/\?page=2#[\w\-]{6}@', $result->getHeader('location')[0]);
     }
 
     /**
@@ -575,12 +562,6 @@ class PostBookmarkControllerTest extends TestCase
                 return $parameters[$key] ?? null;
             })
         ;
-        $request->method('getUri')->willReturnCallback(function (): Uri {
-            $uri = $this->createMock(Uri::class);
-            $uri->method('getBasePath')->willReturn('/subfolder');
-
-            return $uri;
-        });
         $response = new Response();
 
         $this->container->conf = $this->createMock(ConfigManager::class);