phpmyadmin/tests/unit/Controllers/LogoutControllerTest.php
Maurício Meneghini Fauth 606f66b5df
Rename tests/classes to tests/unit
This directory is for unit tests only, so let's rename it to unit to be
more clear.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2024-02-23 13:29:07 -03:00

35 lines
1011 B
PHP

<?php
declare(strict_types=1);
namespace PhpMyAdmin\Tests\Controllers;
use PhpMyAdmin\Controllers\LogoutController;
use PhpMyAdmin\Http\ServerRequest;
use PhpMyAdmin\Plugins\AuthenticationPlugin;
use PhpMyAdmin\Plugins\AuthenticationPluginFactory;
use PhpMyAdmin\Tests\AbstractTestCase;
use PHPUnit\Framework\Attributes\CoversClass;
#[CoversClass(LogoutController::class)]
class LogoutControllerTest extends AbstractTestCase
{
public function testValidLogout(): void
{
$GLOBALS['token_mismatch'] = false;
$request = self::createStub(ServerRequest::class);
$request->method('isPost')->willReturn(true);
$authPlugin = self::createMock(AuthenticationPlugin::class);
$authPlugin->expects(self::once())->method('logOut');
$factory = self::createStub(AuthenticationPluginFactory::class);
$factory->method('create')->willReturn($authPlugin);
(new LogoutController($factory))($request);
unset($GLOBALS['token_mismatch']);
}
}