]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - tests/front/controller/admin/FrontAdminControllerMockHelper.php
Merge pull request #1512 from shaarli/dependabot/npm_and_yarn/elliptic-6.5.3
[github/shaarli/Shaarli.git] / tests / front / controller / admin / FrontAdminControllerMockHelper.php
index bd40c0c7ccf67981a7e4513886f71fa99d5369b8..2b9f2ef197c963edfd6b15d19a4313d941b2eec5 100644 (file)
@@ -6,6 +6,7 @@ namespace Shaarli\Front\Controller\Admin;
 
 use Shaarli\Container\ShaarliTestContainer;
 use Shaarli\Front\Controller\Visitor\FrontControllerMockHelper;
+use Shaarli\History;
 
 /**
  * Trait FrontControllerMockHelper
@@ -27,7 +28,29 @@ trait FrontAdminControllerMockHelper
     {
         $this->parentCreateContainer();
 
+        $this->container->history = $this->createMock(History::class);
+
         $this->container->loginManager->method('isLoggedIn')->willReturn(true);
         $this->container->sessionManager->method('checkToken')->willReturn(true);
     }
+
+
+    /**
+     * Pass a reference of an array which will be populated by `sessionManager->setSessionParameter`
+     * calls during execution.
+     *
+     * @param mixed $variables Array reference to populate.
+     */
+    protected function assignSessionVars(array &$variables): void
+    {
+        $this->container->sessionManager
+            ->expects(static::atLeastOnce())
+            ->method('setSessionParameter')
+            ->willReturnCallback(function ($key, $value) use (&$variables) {
+                $variables[$key] = $value;
+
+                return $this->container->sessionManager;
+            })
+        ;
+    }
 }