do not mock event classes
This commit is contained in:
parent
09814d5548
commit
8da1969afc
@ -16,6 +16,7 @@ use Symfony\Bridge\Monolog\Processor\ConsoleCommandProcessor;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Event\ConsoleEvent;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class ConsoleCommandProcessorTest extends TestCase
|
||||
{
|
||||
@ -66,10 +67,7 @@ class ConsoleCommandProcessorTest extends TestCase
|
||||
$input->method('getOptions')->willReturn(self::TEST_OPTIONS);
|
||||
$command = $this->createMock(Command::class);
|
||||
$command->method('getName')->willReturn(self::TEST_NAME);
|
||||
$consoleEvent = $this->createMock(ConsoleEvent::class);
|
||||
$consoleEvent->method('getCommand')->willReturn($command);
|
||||
$consoleEvent->method('getInput')->willReturn($input);
|
||||
|
||||
return $consoleEvent;
|
||||
return new ConsoleEvent($command, $input, $this->createMock(OutputInterface::class));
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Event\RequestEvent;
|
||||
use Symfony\Component\HttpKernel\EventListener\AddRequestFormatsListener;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
|
||||
/**
|
||||
@ -54,7 +55,7 @@ class AddRequestFormatsListenerTest extends TestCase
|
||||
public function testSetAdditionalFormats()
|
||||
{
|
||||
$request = $this->createMock(Request::class);
|
||||
$event = $this->getRequestEventMock($request);
|
||||
$event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST);
|
||||
|
||||
$request->expects($this->once())
|
||||
->method('setFormat')
|
||||
@ -62,14 +63,4 @@ class AddRequestFormatsListenerTest extends TestCase
|
||||
|
||||
$this->listener->onKernelRequest($event);
|
||||
}
|
||||
|
||||
protected function getRequestEventMock(Request $request)
|
||||
{
|
||||
$event = $this->createMock(RequestEvent::class);
|
||||
$event->expects($this->any())
|
||||
->method('getRequest')
|
||||
->willReturn($request);
|
||||
|
||||
return $event;
|
||||
}
|
||||
}
|
||||
|
@ -26,13 +26,17 @@ class SaveSessionListenerTest extends TestCase
|
||||
{
|
||||
public function testOnlyTriggeredOnMasterRequest()
|
||||
{
|
||||
$session = $this->createMock(SessionInterface::class);
|
||||
$session->expects($this->never())->method('save');
|
||||
$session->expects($this->any())->method('isStarted')->willReturn(true);
|
||||
|
||||
$request = new Request();
|
||||
$request->setSession($session);
|
||||
|
||||
$listener = new SaveSessionListener();
|
||||
$event = $this->createMock(ResponseEvent::class);
|
||||
$event->expects($this->once())->method('isMasterRequest')->willReturn(false);
|
||||
$event->expects($this->never())->method('getRequest');
|
||||
|
||||
// sub request
|
||||
$listener->onKernelResponse($event);
|
||||
$listener->onKernelResponse(new ResponseEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::SUB_REQUEST, new Response()));
|
||||
}
|
||||
|
||||
public function testSessionSaved()
|
||||
|
@ -58,9 +58,7 @@ class SessionListenerTest extends TestCase
|
||||
$request = new Request();
|
||||
$listener = new SessionListener($container);
|
||||
|
||||
$event = $this->createMock(RequestEvent::class);
|
||||
$event->expects($this->exactly(2))->method('isMasterRequest')->willReturn(true);
|
||||
$event->expects($this->once())->method('getRequest')->willReturn($request);
|
||||
$event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST);
|
||||
|
||||
$listener->onKernelRequest($event);
|
||||
|
||||
|
@ -14,6 +14,7 @@ namespace Symfony\Component\Security\Http\Tests\Firewall;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Event\RequestEvent;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
@ -62,14 +63,7 @@ class AbstractPreAuthenticatedListenerTest extends TestCase
|
||||
->method('getPreAuthenticatedData')
|
||||
->willReturn($userCredentials);
|
||||
|
||||
$event = $this->createMock(RequestEvent::class);
|
||||
$event
|
||||
->expects($this->any())
|
||||
->method('getRequest')
|
||||
->willReturn($request)
|
||||
;
|
||||
|
||||
$listener($event);
|
||||
$listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST));
|
||||
}
|
||||
|
||||
public function testHandleWhenAuthenticationFails()
|
||||
@ -109,14 +103,7 @@ class AbstractPreAuthenticatedListenerTest extends TestCase
|
||||
->method('getPreAuthenticatedData')
|
||||
->willReturn($userCredentials);
|
||||
|
||||
$event = $this->createMock(RequestEvent::class);
|
||||
$event
|
||||
->expects($this->any())
|
||||
->method('getRequest')
|
||||
->willReturn($request)
|
||||
;
|
||||
|
||||
$listener($event);
|
||||
$listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST));
|
||||
}
|
||||
|
||||
public function testHandleWhenAuthenticationFailsWithDifferentToken()
|
||||
@ -158,12 +145,7 @@ class AbstractPreAuthenticatedListenerTest extends TestCase
|
||||
->method('getPreAuthenticatedData')
|
||||
->willReturn($userCredentials);
|
||||
|
||||
$event = $this->createMock(RequestEvent::class);
|
||||
$event
|
||||
->expects($this->any())
|
||||
->method('getRequest')
|
||||
->willReturn($request)
|
||||
;
|
||||
$event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST);
|
||||
|
||||
$listener($event);
|
||||
}
|
||||
@ -200,14 +182,7 @@ class AbstractPreAuthenticatedListenerTest extends TestCase
|
||||
->method('getPreAuthenticatedData')
|
||||
->willReturn($userCredentials);
|
||||
|
||||
$event = $this->createMock(RequestEvent::class);
|
||||
$event
|
||||
->expects($this->any())
|
||||
->method('getRequest')
|
||||
->willReturn($request)
|
||||
;
|
||||
|
||||
$listener($event);
|
||||
$listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST));
|
||||
}
|
||||
|
||||
public function testHandleWithAnInvalidSimilarToken()
|
||||
@ -250,13 +225,6 @@ class AbstractPreAuthenticatedListenerTest extends TestCase
|
||||
->method('getPreAuthenticatedData')
|
||||
->willReturn($userCredentials);
|
||||
|
||||
$event = $this->createMock(RequestEvent::class);
|
||||
$event
|
||||
->expects($this->any())
|
||||
->method('getRequest')
|
||||
->willReturn($request)
|
||||
;
|
||||
|
||||
$listener($event);
|
||||
$listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST));
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Event\RequestEvent;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager;
|
||||
use Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface;
|
||||
@ -64,14 +65,7 @@ class BasicAuthenticationListenerTest extends TestCase
|
||||
$this->createMock(AuthenticationEntryPointInterface::class)
|
||||
);
|
||||
|
||||
$event = $this->createMock(RequestEvent::class);
|
||||
$event
|
||||
->expects($this->any())
|
||||
->method('getRequest')
|
||||
->willReturn($request)
|
||||
;
|
||||
|
||||
$listener($event);
|
||||
$listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST));
|
||||
}
|
||||
|
||||
public function testHandleWhenAuthenticationFails()
|
||||
@ -109,19 +103,11 @@ class BasicAuthenticationListenerTest extends TestCase
|
||||
$authenticationEntryPoint
|
||||
);
|
||||
|
||||
$event = $this->createMock(RequestEvent::class);
|
||||
$event
|
||||
->expects($this->any())
|
||||
->method('getRequest')
|
||||
->willReturn($request)
|
||||
;
|
||||
$event
|
||||
->expects($this->once())
|
||||
->method('setResponse')
|
||||
->with($this->equalTo($response))
|
||||
;
|
||||
$event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST);
|
||||
|
||||
$listener($event);
|
||||
|
||||
$this->assertSame($response, $event->getResponse());
|
||||
}
|
||||
|
||||
public function testHandleWithNoUsernameServerParameter()
|
||||
@ -141,14 +127,7 @@ class BasicAuthenticationListenerTest extends TestCase
|
||||
$this->createMock(AuthenticationEntryPointInterface::class)
|
||||
);
|
||||
|
||||
$event = $this->createMock(RequestEvent::class);
|
||||
$event
|
||||
->expects($this->any())
|
||||
->method('getRequest')
|
||||
->willReturn($request)
|
||||
;
|
||||
|
||||
$listener($event);
|
||||
$listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST));
|
||||
}
|
||||
|
||||
public function testHandleWithASimilarAuthenticatedToken()
|
||||
@ -177,14 +156,7 @@ class BasicAuthenticationListenerTest extends TestCase
|
||||
$this->createMock(AuthenticationEntryPointInterface::class)
|
||||
);
|
||||
|
||||
$event = $this->createMock(RequestEvent::class);
|
||||
$event
|
||||
->expects($this->any())
|
||||
->method('getRequest')
|
||||
->willReturn($request)
|
||||
;
|
||||
|
||||
$listener($event);
|
||||
$listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST));
|
||||
}
|
||||
|
||||
public function testItRequiresProviderKey()
|
||||
@ -236,18 +208,10 @@ class BasicAuthenticationListenerTest extends TestCase
|
||||
$authenticationEntryPoint
|
||||
);
|
||||
|
||||
$event = $this->createMock(RequestEvent::class);
|
||||
$event
|
||||
->expects($this->any())
|
||||
->method('getRequest')
|
||||
->willReturn($request)
|
||||
;
|
||||
$event
|
||||
->expects($this->once())
|
||||
->method('setResponse')
|
||||
->with($this->equalTo($response))
|
||||
;
|
||||
$event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST);
|
||||
|
||||
$listener($event);
|
||||
|
||||
$this->assertSame($response, $event->getResponse());
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Event\RequestEvent;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\Security\Http\AccessMapInterface;
|
||||
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
|
||||
use Symfony\Component\Security\Http\Firewall\ChannelListener;
|
||||
@ -44,19 +45,12 @@ class ChannelListenerTest extends TestCase
|
||||
->method('start')
|
||||
;
|
||||
|
||||
$event = $this->createMock(RequestEvent::class);
|
||||
$event
|
||||
->expects($this->any())
|
||||
->method('getRequest')
|
||||
->willReturn($request)
|
||||
;
|
||||
$event
|
||||
->expects($this->never())
|
||||
->method('setResponse')
|
||||
;
|
||||
$event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST);
|
||||
|
||||
$listener = new ChannelListener($accessMap, $entryPoint);
|
||||
$listener($event);
|
||||
|
||||
$this->assertNull($event->getResponse());
|
||||
}
|
||||
|
||||
public function testHandleWithSecuredRequestAndHttpsChannel()
|
||||
@ -82,19 +76,12 @@ class ChannelListenerTest extends TestCase
|
||||
->method('start')
|
||||
;
|
||||
|
||||
$event = $this->createMock(RequestEvent::class);
|
||||
$event
|
||||
->expects($this->any())
|
||||
->method('getRequest')
|
||||
->willReturn($request)
|
||||
;
|
||||
$event
|
||||
->expects($this->never())
|
||||
->method('setResponse')
|
||||
;
|
||||
$event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST);
|
||||
|
||||
$listener = new ChannelListener($accessMap, $entryPoint);
|
||||
$listener($event);
|
||||
|
||||
$this->assertNull($event->getResponse());
|
||||
}
|
||||
|
||||
public function testHandleWithNotSecuredRequestAndHttpsChannel()
|
||||
@ -124,20 +111,12 @@ class ChannelListenerTest extends TestCase
|
||||
->willReturn($response)
|
||||
;
|
||||
|
||||
$event = $this->createMock(RequestEvent::class);
|
||||
$event
|
||||
->expects($this->any())
|
||||
->method('getRequest')
|
||||
->willReturn($request)
|
||||
;
|
||||
$event
|
||||
->expects($this->once())
|
||||
->method('setResponse')
|
||||
->with($this->equalTo($response))
|
||||
;
|
||||
$event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST);
|
||||
|
||||
$listener = new ChannelListener($accessMap, $entryPoint);
|
||||
$listener($event);
|
||||
|
||||
$this->assertSame($response, $event->getResponse());
|
||||
}
|
||||
|
||||
public function testHandleWithSecuredRequestAndHttpChannel()
|
||||
@ -167,19 +146,11 @@ class ChannelListenerTest extends TestCase
|
||||
->willReturn($response)
|
||||
;
|
||||
|
||||
$event = $this->createMock(RequestEvent::class);
|
||||
$event
|
||||
->expects($this->any())
|
||||
->method('getRequest')
|
||||
->willReturn($request)
|
||||
;
|
||||
$event
|
||||
->expects($this->once())
|
||||
->method('setResponse')
|
||||
->with($this->equalTo($response))
|
||||
;
|
||||
$event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST);
|
||||
|
||||
$listener = new ChannelListener($accessMap, $entryPoint);
|
||||
$listener($event);
|
||||
|
||||
$this->assertSame($response, $event->getResponse());
|
||||
}
|
||||
}
|
||||
|
@ -146,13 +146,9 @@ class ContextListenerTest extends TestCase
|
||||
public function testInvalidTokenInSession($token)
|
||||
{
|
||||
$tokenStorage = $this->createMock(TokenStorageInterface::class);
|
||||
$event = $this->createMock(RequestEvent::class);
|
||||
$request = $this->createMock(Request::class);
|
||||
$session = $this->createMock(SessionInterface::class);
|
||||
|
||||
$event->expects($this->any())
|
||||
->method('getRequest')
|
||||
->willReturn($request);
|
||||
$request->expects($this->any())
|
||||
->method('hasPreviousSession')
|
||||
->willReturn(true);
|
||||
@ -168,7 +164,7 @@ class ContextListenerTest extends TestCase
|
||||
->with(null);
|
||||
|
||||
$listener = new ContextListener($tokenStorage, [], 'key123');
|
||||
$listener($event);
|
||||
$listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST));
|
||||
}
|
||||
|
||||
public function provideInvalidToken()
|
||||
@ -186,22 +182,13 @@ class ContextListenerTest extends TestCase
|
||||
{
|
||||
$tokenStorage = $this->createMock(TokenStorageInterface::class);
|
||||
$dispatcher = $this->createMock(EventDispatcherInterface::class);
|
||||
$event = $this->createMock(RequestEvent::class);
|
||||
|
||||
$listener = new ContextListener($tokenStorage, [], 'key123', null, $dispatcher);
|
||||
|
||||
$event->expects($this->any())
|
||||
->method('isMasterRequest')
|
||||
->willReturn(true);
|
||||
$event->expects($this->any())
|
||||
->method('getRequest')
|
||||
->willReturn($this->createMock(Request::class));
|
||||
|
||||
$dispatcher->expects($this->once())
|
||||
->method('addListener')
|
||||
->with(KernelEvents::RESPONSE, [$listener, 'onKernelResponse']);
|
||||
|
||||
$listener($event);
|
||||
$listener(new RequestEvent($this->createMock(HttpKernelInterface::class), new Request(), HttpKernelInterface::MASTER_REQUEST));
|
||||
}
|
||||
|
||||
public function testOnKernelResponseListenerRemovesItself()
|
||||
@ -234,14 +221,11 @@ class ContextListenerTest extends TestCase
|
||||
$request = $this->createMock(Request::class);
|
||||
$request->expects($this->any())->method('hasPreviousSession')->willReturn(false);
|
||||
|
||||
$event = $this->createMock(RequestEvent::class);
|
||||
$event->expects($this->any())->method('getRequest')->willReturn($request);
|
||||
|
||||
$tokenStorage = $this->createMock(TokenStorageInterface::class);
|
||||
$tokenStorage->expects($this->once())->method('setToken')->with(null);
|
||||
|
||||
$listener = new ContextListener($tokenStorage, [], 'key123');
|
||||
$listener($event);
|
||||
$listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST));
|
||||
}
|
||||
|
||||
public function testIfTokenIsDeauthenticated()
|
||||
|
@ -15,6 +15,7 @@ use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Event\RequestEvent;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Symfony\Component\Security\Core\Exception\LogoutException;
|
||||
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
|
||||
@ -30,10 +31,8 @@ class LogoutListenerTest extends TestCase
|
||||
{
|
||||
[$listener, , $httpUtils, $options] = $this->getListener();
|
||||
|
||||
[$event, $request] = $this->getGetResponseEvent();
|
||||
|
||||
$event->expects($this->never())
|
||||
->method('setResponse');
|
||||
$request = new Request();
|
||||
$event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST);
|
||||
|
||||
$httpUtils->expects($this->once())
|
||||
->method('checkRequestPath')
|
||||
@ -41,6 +40,8 @@ class LogoutListenerTest extends TestCase
|
||||
->willReturn(false);
|
||||
|
||||
$listener($event);
|
||||
|
||||
$this->assertNull($event->getResponse());
|
||||
}
|
||||
|
||||
public function testHandleMatchedPathWithSuccessHandlerAndCsrfValidation()
|
||||
@ -50,7 +51,8 @@ class LogoutListenerTest extends TestCase
|
||||
|
||||
[$listener, $tokenStorage, $httpUtils, $options] = $this->getListener($successHandler, $tokenManager);
|
||||
|
||||
[$event, $request] = $this->getGetResponseEvent();
|
||||
$request = new Request();
|
||||
$event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST);
|
||||
|
||||
$request->query->set('_csrf_token', 'token');
|
||||
|
||||
@ -81,13 +83,11 @@ class LogoutListenerTest extends TestCase
|
||||
->method('setToken')
|
||||
->with(null);
|
||||
|
||||
$event->expects($this->once())
|
||||
->method('setResponse')
|
||||
->with($response);
|
||||
|
||||
$listener->addHandler($handler);
|
||||
|
||||
$listener($event);
|
||||
|
||||
$this->assertSame($response, $event->getResponse());
|
||||
}
|
||||
|
||||
public function testHandleMatchedPathWithoutSuccessHandlerAndCsrfValidation()
|
||||
@ -96,7 +96,8 @@ class LogoutListenerTest extends TestCase
|
||||
|
||||
[$listener, $tokenStorage, $httpUtils, $options] = $this->getListener($successHandler);
|
||||
|
||||
[$event, $request] = $this->getGetResponseEvent();
|
||||
$request = new Request();
|
||||
$event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST);
|
||||
|
||||
$httpUtils->expects($this->once())
|
||||
->method('checkRequestPath')
|
||||
@ -121,13 +122,11 @@ class LogoutListenerTest extends TestCase
|
||||
->method('setToken')
|
||||
->with(null);
|
||||
|
||||
$event->expects($this->once())
|
||||
->method('setResponse')
|
||||
->with($response);
|
||||
|
||||
$listener->addHandler($handler);
|
||||
|
||||
$listener($event);
|
||||
|
||||
$this->assertSame($response, $event->getResponse());
|
||||
}
|
||||
|
||||
public function testSuccessHandlerReturnsNonResponse()
|
||||
@ -137,7 +136,8 @@ class LogoutListenerTest extends TestCase
|
||||
|
||||
[$listener, , $httpUtils, $options] = $this->getListener($successHandler);
|
||||
|
||||
[$event, $request] = $this->getGetResponseEvent();
|
||||
$request = new Request();
|
||||
$event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST);
|
||||
|
||||
$httpUtils->expects($this->once())
|
||||
->method('checkRequestPath')
|
||||
@ -159,8 +159,7 @@ class LogoutListenerTest extends TestCase
|
||||
|
||||
[$listener, , $httpUtils, $options] = $this->getListener(null, $tokenManager);
|
||||
|
||||
[$event, $request] = $this->getGetResponseEvent();
|
||||
|
||||
$request = new Request();
|
||||
$request->query->set('_csrf_token', 'token');
|
||||
|
||||
$httpUtils->expects($this->once())
|
||||
@ -172,7 +171,7 @@ class LogoutListenerTest extends TestCase
|
||||
->method('isTokenValid')
|
||||
->willReturn(false);
|
||||
|
||||
$listener($event);
|
||||
$listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST));
|
||||
}
|
||||
|
||||
private function getTokenManager()
|
||||
@ -185,17 +184,6 @@ class LogoutListenerTest extends TestCase
|
||||
return $this->createMock(TokenStorageInterface::class);
|
||||
}
|
||||
|
||||
private function getGetResponseEvent()
|
||||
{
|
||||
$event = $this->createMock(RequestEvent::class);
|
||||
|
||||
$event->expects($this->any())
|
||||
->method('getRequest')
|
||||
->willReturn($request = new Request());
|
||||
|
||||
return [$event, $request];
|
||||
}
|
||||
|
||||
private function getHandler()
|
||||
{
|
||||
return $this->createMock(LogoutHandlerInterface::class);
|
||||
|
@ -16,7 +16,6 @@ use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
||||
use Symfony\Component\HttpKernel\Event\RequestEvent;
|
||||
use Symfony\Component\HttpKernel\Event\ResponseEvent;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
@ -363,11 +362,6 @@ class RememberMeListenerTest extends TestCase
|
||||
return $event;
|
||||
}
|
||||
|
||||
protected function getResponseEvent(): ResponseEvent
|
||||
{
|
||||
return $this->createMock(ResponseEvent::class);
|
||||
}
|
||||
|
||||
protected function getListener($withDispatcher = false, $catchExceptions = true, $withSessionStrategy = false)
|
||||
{
|
||||
$listener = new RememberMeListener(
|
||||
|
@ -16,6 +16,7 @@ use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Event\RequestEvent;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
||||
@ -110,12 +111,7 @@ class SimplePreAuthenticationListenerTest extends TestCase
|
||||
|
||||
$this->request = new Request([], [], [], [], [], []);
|
||||
|
||||
$this->event = $this->createMock(RequestEvent::class);
|
||||
$this->event
|
||||
->expects($this->any())
|
||||
->method('getRequest')
|
||||
->willReturn($this->request)
|
||||
;
|
||||
$this->event = new RequestEvent($this->createMock(HttpKernelInterface::class), $this->request, HttpKernelInterface::MASTER_REQUEST);
|
||||
|
||||
$this->logger = $this->createMock(LoggerInterface::class);
|
||||
$this->tokenStorage = $this->createMock(TokenStorageInterface::class);
|
||||
|
@ -78,14 +78,7 @@ class UsernamePasswordFormAuthenticationListenerTest extends TestCase
|
||||
['require_previous_session' => false]
|
||||
);
|
||||
|
||||
$event = $this->createMock(RequestEvent::class);
|
||||
$event
|
||||
->expects($this->any())
|
||||
->method('getRequest')
|
||||
->willReturn($request)
|
||||
;
|
||||
|
||||
$listener($event);
|
||||
$listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user