Closed
Description
Symfony version(s) affected: 5.1.2
Description
App\Tests\Controller\SecurityControllerTest::testLogout()
TypeError: Argument 3 passed to Symfony\Component\Security\Http\RememberMe\AbstractRememberMeServices::logout() must implement interface Symfony\Component\Security\Core\Authentication\Token\TokenInterface, null given, called in xx\vendor\symfony\security-http\EventListener\RememberMeLogoutListener.php on line 47
How to reproduce
I'm working on simple symfony crud website from a fresh symfony5.0. I build it from "Create your own framework guide from symfony site".
This worked up to now.
Today I updated to https://symfony.com/doc/current/security/experimental_authenticators.html
Then I had this problem only while testing. But run on browser its fine good - no error.
Possible Solution
Currently I don't know
Additional context
Error thrown by test:
App\Tests\Controller\SecurityControllerTest::testLogout()
TypeError: Argument 3 passed to Symfony\Component\Security\Http\RememberMe\AbstractRememberMeServices::logout() must implement interface Symfony\Component\Security\Core\Authentication\Token\TokenInterface, null given, called in E:\WORK\xx\vendor\symfony\security-http\EventListener\RememberMeLogoutListener.php on line 47
E:\WORK\xx\vendor\symfony\security-http\RememberMe\AbstractRememberMeServices.php:161
E:\WORK\xx\vendor\symfony\security-http\EventListener\RememberMeLogoutListener.php:47
E:\WORK\xx\vendor\symfony\event-dispatcher\EventDispatcher.php:270
E:\WORK\xx\vendor\symfony\event-dispatcher\EventDispatcher.php:230
E:\WORK\xx\vendor\symfony\event-dispatcher\EventDispatcher.php:59
E:\WORK\xx\vendor\symfony\security-http\Firewall\LogoutListener.php:122
E:\WORK\xx\vendor\symfony\security-bundle\Debug\WrappedLazyListener.php:48
E:\WORK\xx\vendor\symfony\security-http\Firewall\AbstractListener.php:27
E:\WORK\xx\vendor\symfony\security-bundle\Debug\TraceableFirewallListener.php:62
E:\WORK\xx\vendor\symfony\security-http\Firewall.php:84
E:\WORK\xx\vendor\symfony\event-dispatcher\Debug\WrappedListener.php:117
E:\WORK\xx\vendor\symfony\event-dispatcher\EventDispatcher.php:230
E:\WORK\xx\vendor\symfony\event-dispatcher\EventDispatcher.php:59
E:\WORK\xx\vendor\symfony\event-dispatcher\Debug\TraceableEventDispatcher.php:151
E:\WORK\xx\vendor\symfony\http-kernel\HttpKernel.php:133
E:\WORK\xx\vendor\symfony\http-kernel\HttpKernel.php:79
E:\WORK\xx\vendor\symfony\http-kernel\Kernel.php:196
E:\WORK\xx\vendor\symfony\http-kernel\HttpKernelBrowser.php:63
E:\WORK\xx\vendor\symfony\framework-bundle\KernelBrowser.php:159
E:\WORK\xx\vendor\symfony\browser-kit\AbstractBrowser.php:384
E:\WORK\xx\tests\Controller\SecurityControllerTest.php:40
My test file code:
public function testLogout() {
$this->client->request('GET', '/security/logout');
$this->assertSame(Response::HTTP_FOUND, $this->client->getResponse()->getStatusCode());
$url = self::$container->get('router')->generate('app_home', array(), false); // FALSE RETURNS FULL URL
$this->assertTrue($this->client->getResponse()->isRedirect($url));
$this->client->followRedirect();
$this->assertSame(Response::HTTP_OK, $this->client->getResponse()->getStatusCode());
$this->assertPageTitleContains('Welcome | ' . $this->getWSTitle());
}