}
use PHPUnit\Framework\TestCase;
-use Shaarli\Container\ShaarliContainer;
-use Shaarli\Render\PageCacheManager;
use Shaarli\Security\LoginManager;
use Shaarli\Security\SessionManager;
use Slim\Http\Request;
class LogoutControllerTest extends TestCase
{
- /** @var ShaarliContainer */
- protected $container;
+ use FrontControllerMockHelper;
/** @var LogoutController */
protected $controller;
public function setUp(): void
{
- $this->container = $this->createMock(ShaarliContainer::class);
+ $this->createContainer();
+
$this->controller = new LogoutController($this->container);
setcookie(LoginManager::$STAY_SIGNED_IN_COOKIE, $cookie = 'hi there');
public function testValidControllerInvoke(): void
{
+ $this->createValidContainerMockSet();
+
$request = $this->createMock(Request::class);
$response = new Response();
- $pageCacheManager = $this->createMock(PageCacheManager::class);
- $pageCacheManager->expects(static::once())->method('invalidateCaches');
- $this->container->pageCacheManager = $pageCacheManager;
+ $this->container->pageCacheManager->expects(static::once())->method('invalidateCaches');
- $sessionManager = $this->createMock(SessionManager::class);
- $sessionManager->expects(static::once())->method('logout');
- $this->container->sessionManager = $sessionManager;
+ $this->container->sessionManager = $this->createMock(SessionManager::class);
+ $this->container->sessionManager->expects(static::once())->method('logout');
static::assertSame('hi there', $_COOKIE[LoginManager::$STAY_SIGNED_IN_COOKIE]);