Repository navigation
Symfony 6.0 functional test: 'There is currently no session available' #191
Copy link
Copy link
Closed
Description
I am having a problem with Sessions on a Symfony 7 application (updated from 5.4) that i was able to replicate on (symfony-module-tests). Before the update the tests were running fine now i am getting "[Symfony\Component\HttpFoundation\Exception\SessionNotFoundException] There is currently no session available."
//tests/Functional/SecurityCest.php
final class SecurityCest
{
........
public function seeAuthentication(FunctionalTester $I, ModuleContainer $moduleContainer)
{
$user = $I->grabEntityFromRepository(User::class, [
'email' => 'john_doe@gmail.com'
]);
$I->amLoggedInAs($user);
$I->amOnPage('/dashboard');
$I->seeAuthentication();
$request = new Request();
$em = $moduleContainer->getModule('Doctrine')->_getEntityManager();
$controller = $I->grabService(SomeCustomController::class);
$controller->testAddForm($em, $request);
}
.......
//src/Controller/SomeCustomController.php
<?php
declare(strict_types=1);
namespace App\Controller;
use App\Entity\User;
use App\Form\RegistrationFormType;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
final class SomeCustomController extends AbstractController
{
public function testAddForm(EntityManagerInterface $entityManager, Request $request)
{
$user = $this->getUser();
$someUser = new User();
$form = $this->createForm(RegistrationFormType::class, $someUser);
$form->handleRequest($request);
return $this->render('registration/register.html.twig', [
'registrationForm' => $form->createView(),
]);
}
}
When running
vendor/bin/codecept run Functional SecurityCest:seeAuthentication -vvv
i get
Codeception PHP Testing Framework v5.1.2 https://stand-with-ukraine.pp.ua
[Seed] 1567467201
App\Tests.Functional Tests (2) -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Modules: Asserts, Symfony, Doctrine
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SecurityCest: Dont see authentication
Signature: App\Tests\Functional\SecurityCest:dontSeeAuthentication
Test: tests/Functional/SecurityCest.php:dontSeeAuthentication
Scenario --
[Symfony] Can't set persistent service doctrine.orm.default_entity_manager: The "doctrine.orm.default_entity_manager" service is already initialized, you cannot replace it.
[Database] Transaction started
I am on page "/dashboard"
[Request Headers] []
[info] Matched route "dashboard".
[debug] Checking for authenticator support.
[debug] Checking support on authenticator.
[debug] Authenticator does not support the request.
[debug] Checking support on authenticator.
[debug] Authenticator does not support the request.
[debug] Notified event "debug.security.authorization.vote" to listener "Symfony\Bundle\SecurityBundle\EventListener\VoteListener::onVoterVote".
[debug] Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\DebugHandlersListener::configure".
[debug] Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\ValidateRequestListener::onKernelRequest".
[debug] Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\SessionListener::onKernelRequest".
[debug] Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\LocaleListener::setDefaultLocale".
[debug] Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelRequest".
[debug] Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\LocaleListener::onKernelRequest".
[debug] Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\LocaleAwareListener::onKernelRequest".
[debug] Notified event "kernel.request" to listener "Symfony\Bundle\SecurityBundle\Debug\TraceableFirewallListener::configureLogoutUrlGenerator".
[debug] Notified event "kernel.request" to listener "Symfony\Bundle\SecurityBundle\Debug\TraceableFirewallListener::onKernelRequest".
[debug] Access denied, the user is not fully authenticated; redirecting to authentication entry point.
[debug] Calling Authentication entry point.
[debug] Notified event "kernel.exception" to listener "Symfony\Component\Security\Http\Firewall\ExceptionListener::onKernelException".
[debug] Listener "Symfony\Component\Security\Http\Firewall\ExceptionListener::onKernelException" stopped propagation of the event "kernel.exception".
[debug] Listener "Symfony\Component\HttpKernel\EventListener\ErrorListener::logKernelException" was not called for event "kernel.exception".
[debug] Listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelException" was not called for event "kernel.exception".
[debug] Listener "Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelException" was not called for event "kernel.exception".
[debug] Listener "Symfony\Component\HttpKernel\EventListener\ErrorListener::onKernelException" was not called for event "kernel.exception".
[debug] Notified event "kernel.response" to listener "Symfony\Component\Security\Http\Firewall\ContextListener::onKernelResponse".
[debug] Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\ResponseListener::onKernelResponse".
[debug] Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\DataCollector\RequestDataCollector::onKernelResponse".
[debug] Notified event "kernel.response" to listener "Symfony\Component\Security\Http\RememberMe\ResponseListener::onKernelResponse".
[debug] Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\CacheAttributeListener::onKernelResponse".
[debug] Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelResponse".
[debug] Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\ErrorListener::removeCspHeader".
[debug] Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\DisallowRobotsIndexingListener::onResponse".
[debug] Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\SessionListener::onKernelResponse".
[debug] Notified event "kernel.finish_request" to listener "Symfony\Component\HttpKernel\EventListener\LocaleListener::onKernelFinishRequest".
[debug] Notified event "kernel.finish_request" to listener "Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelFinishRequest".
[debug] Notified event "kernel.finish_request" to listener "Symfony\Bundle\SecurityBundle\Debug\TraceableFirewallListener::onKernelFinishRequest".
[debug] Notified event "kernel.finish_request" to listener "Symfony\Component\HttpKernel\EventListener\LocaleAwareListener::onKernelFinishRequest".
[debug] Notified event "kernel.terminate" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelTerminate".
[Page] /dashboard
[Response] 302
[Request Cookies] []
[Response Headers] {"cache-control":["max-age=0, must-revalidate, private"],"date":["Tue, 23 Apr 2024 07:45:17 GMT"],"location":["/login"],"content-type":["text/html; charset=UTF-8"],"x-debug-token":["de8862"],"x-robots-tag":["noindex"],"expires":["Tue, 23 Apr 2024 07:45:17 GMT"],"set-cookie":["sf_redirect=%7B%22token%22%3A%22de8862%22%2C%22route%22%3A%22dashboard%22%2C%22method%22%3A%22GET%22%2C%22controller%22%3A%22App%5C%5CController%5C%5CDashboardController%22%2C%22status_code%22%3A302%2C%22status_text%22%3A%22Found%22%7D; path=/; httponly; samesite=lax","MOCKSESSID=fdd6537c2dcfd35c8fc5688c15526f8815a5b1c9c69cac17a87567d9f20e0fca; path=/; httponly; samesite=lax"]}
[User] Anonymous
[Emails] 0 sent
[Time] 34.96 ms
[Redirecting to] /login
[Symfony] Can't set persistent service doctrine.orm.default_entity_manager: The "doctrine.orm.default_entity_manager" service is already initialized, you cannot replace it.
[info] Matched route "app_login".
[debug] Checking for authenticator support.
[debug] Checking support on authenticator.
[debug] Authenticator does not support the request.
[debug] Checking support on authenticator.
[debug] Authenticator does not support the request.
[debug] Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\DebugHandlersListener::configure".
[debug] Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\ValidateRequestListener::onKernelRequest".
[debug] Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\SessionListener::onKernelRequest".
[debug] Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\LocaleListener::setDefaultLocale".
[debug] Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelRequest".
[debug] Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\LocaleListener::onKernelRequest".
[debug] Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\LocaleAwareListener::onKernelRequest".
[debug] Notified event "kernel.request" to listener "Symfony\Bundle\SecurityBundle\Debug\TraceableFirewallListener::configureLogoutUrlGenerator".
[debug] Notified event "kernel.request" to listener "Symfony\Bundle\SecurityBundle\Debug\TraceableFirewallListener::onKernelRequest".
[debug] Notified event "kernel.controller" to listener "Symfony\Bundle\FrameworkBundle\DataCollector\RouterDataCollector::onKernelController".
[debug] Notified event "kernel.controller" to listener "Symfony\Component\HttpKernel\DataCollector\RequestDataCollector::onKernelController".
[debug] Notified event "kernel.controller_arguments" to listener "Symfony\Component\Security\Http\EventListener\IsGrantedAttributeListener::onKernelControllerArguments".
[debug] Notified event "kernel.controller_arguments" to listener "Symfony\Component\HttpKernel\EventListener\CacheAttributeListener::onKernelControllerArguments".
[debug] Notified event "kernel.controller_arguments" to listener "Symfony\Component\HttpKernel\EventListener\ErrorListener::onControllerArguments".
[debug] Notified event "kernel.response" to listener "Symfony\Component\Security\Http\Firewall\ContextListener::onKernelResponse".
[debug] Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\ResponseListener::onKernelResponse".
[debug] Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\DataCollector\RequestDataCollector::onKernelResponse".
[debug] Notified event "kernel.response" to listener "Symfony\Component\Security\Http\RememberMe\ResponseListener::onKernelResponse".
[debug] Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\CacheAttributeListener::onKernelResponse".
[debug] Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelResponse".
[debug] Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\ErrorListener::removeCspHeader".
[debug] Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\DisallowRobotsIndexingListener::onResponse".
[debug] Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\SessionListener::onKernelResponse".
[debug] Notified event "kernel.finish_request" to listener "Symfony\Component\HttpKernel\EventListener\LocaleListener::onKernelFinishRequest".
[debug] Notified event "kernel.finish_request" to listener "Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelFinishRequest".
[debug] Notified event "kernel.finish_request" to listener "Symfony\Bundle\SecurityBundle\Debug\TraceableFirewallListener::onKernelFinishRequest".
[debug] Notified event "kernel.finish_request" to listener "Symfony\Component\HttpKernel\EventListener\LocaleAwareListener::onKernelFinishRequest".
[debug] Notified event "kernel.terminate" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelTerminate".
[Page] /login
[Response] 200
[Request Cookies] {"sf_redirect":"{"token":"de8862","route":"dashboard","method":"GET","controller":"App\\Controller\\DashboardController","status_code":302,"status_text":"Found"}","MOCKSESSID":"fdd6537c2dcfd35c8fc5688c15526f8815a5b1c9c69cac17a87567d9f20e0fca"}
[Response Headers] {"cache-control":["max-age=0, must-revalidate, private"],"date":["Tue, 23 Apr 2024 07:45:17 GMT"],"content-type":["text/html; charset=UTF-8"],"x-debug-token":["b9f86b"],"x-robots-tag":["noindex"],"expires":["Tue, 23 Apr 2024 07:45:17 GMT"],"set-cookie":["sf_redirect=deleted; expires=Mon, 24 Apr 2023 07:45:16 GMT; Max-Age=0; path=/; httponly"]}
[User] Anonymous
[Emails] 0 sent
[Time] 15.00 ms
I don't see authentication
[debug] Notified event "debug.security.authorization.vote" to listener "Symfony\Bundle\SecurityBundle\EventListener\VoteListener::onVoterVote".
PASSED
[Database] Transaction cancelled; all changes reverted.
SecurityCest: See authentication
Signature: App\Tests\Functional\SecurityCest:seeAuthentication
Test: tests/Functional/SecurityCest.php:seeAuthentication
Scenario --
[Symfony] Can't set persistent service doctrine.orm.default_entity_manager: The "doctrine.orm.default_entity_manager" service is already initialized, you cannot replace it.
[Database] Transaction started
I grab entity from repository "App\Entity\User",{"email":"john_doe@gmail.com"}
SELECT s FROM App\Entity\User s WHERE s.email = ?0
I am logged in as "App\\Entity\\User"
I am on page "/dashboard"
[Request Headers] []
[info] Matched route "dashboard".
[debug] Checking for authenticator support.
[debug] Checking support on authenticator.
[debug] Authenticator does not support the request.
[debug] Checking support on authenticator.
[debug] Authenticator does not support the request.
[debug] Read existing security token from the session.
[debug] User was reloaded from a user provider.
[debug] Notified event "debug.security.authorization.vote" to listener "Symfony\Bundle\SecurityBundle\EventListener\VoteListener::onVoterVote".
[debug] Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\DebugHandlersListener::configure".
[debug] Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\ValidateRequestListener::onKernelRequest".
[debug] Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\SessionListener::onKernelRequest".
[debug] Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\LocaleListener::setDefaultLocale".
[debug] Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelRequest".
[debug] Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\LocaleListener::onKernelRequest".
[debug] Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\LocaleAwareListener::onKernelRequest".
[debug] Notified event "kernel.request" to listener "Symfony\Bundle\SecurityBundle\Debug\TraceableFirewallListener::configureLogoutUrlGenerator".
[debug] Notified event "kernel.request" to listener "Symfony\Bundle\SecurityBundle\Debug\TraceableFirewallListener::onKernelRequest".
[debug] Notified event "kernel.controller" to listener "Symfony\Bundle\FrameworkBundle\DataCollector\RouterDataCollector::onKernelController".
[debug] Notified event "kernel.controller" to listener "Symfony\Component\HttpKernel\DataCollector\RequestDataCollector::onKernelController".
[debug] Notified event "kernel.controller_arguments" to listener "Symfony\Component\Security\Http\EventListener\IsGrantedAttributeListener::onKernelControllerArguments".
[debug] Notified event "kernel.controller_arguments" to listener "Symfony\Component\HttpKernel\EventListener\CacheAttributeListener::onKernelControllerArguments".
[debug] Notified event "kernel.controller_arguments" to listener "Symfony\Component\HttpKernel\EventListener\ErrorListener::onControllerArguments".
[debug] Stored the security token in the session.
[debug] Notified event "kernel.response" to listener "Symfony\Component\Security\Http\Firewall\ContextListener::onKernelResponse".
[debug] Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\ResponseListener::onKernelResponse".
[debug] Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\DataCollector\RequestDataCollector::onKernelResponse".
[debug] Notified event "kernel.response" to listener "Symfony\Component\Security\Http\RememberMe\ResponseListener::onKernelResponse".
[debug] Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\CacheAttributeListener::onKernelResponse".
[debug] Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelResponse".
[debug] Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\ErrorListener::removeCspHeader".
[debug] Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\DisallowRobotsIndexingListener::onResponse".
[debug] Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\SessionListener::onKernelResponse".
[debug] Notified event "kernel.finish_request" to listener "Symfony\Component\HttpKernel\EventListener\LocaleListener::onKernelFinishRequest".
[debug] Notified event "kernel.finish_request" to listener "Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelFinishRequest".
[debug] Notified event "kernel.finish_request" to listener "Symfony\Bundle\SecurityBundle\Debug\TraceableFirewallListener::onKernelFinishRequest".
[debug] Notified event "kernel.finish_request" to listener "Symfony\Component\HttpKernel\EventListener\LocaleAwareListener::onKernelFinishRequest".
[debug] Notified event "kernel.terminate" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelTerminate".
[Page] /dashboard
[Response] 200
[Request Cookies] {"MOCKSESSID":"f9801ac6a25cf2232a386de0062d96ba999f21d593a9f1e4120cbb9bd7cca9e9"}
[Response Headers] {"cache-control":["max-age=0, must-revalidate, private"],"date":["Tue, 23 Apr 2024 07:45:17 GMT"],"content-type":["text/html; charset=UTF-8"],"x-debug-token":["5a7b2d"],"x-robots-tag":["noindex"],"expires":["Tue, 23 Apr 2024 07:45:17 GMT"]}
[User] john_doe@gmail.com [ROLE_CUSTOMER,ROLE_USER]
[Emails] 0 sent
[Time] 27.59 ms
I see authentication
[debug] Notified event "debug.security.authorization.vote" to listener "Symfony\Bundle\SecurityBundle\EventListener\VoteListener::onVoterVote".
I grab service "App\Controller\SomeCustomController"
ERROR
[Database] Transaction cancelled; all changes reverted.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Time: 00:00.266, Memory: 36.50 MB
There was 1 error:
1) SecurityCest: See authentication
Test tests/Functional/SecurityCest.php:seeAuthentication
[Symfony\Component\HttpFoundation\Exception\SessionNotFoundException] There is currently no session available.
Scenario Steps:
5. $I->grabService("App\Controller\SomeCustomController") at tests/Functional/SecurityCest.php:44
4. $I->seeAuthentication() at tests/Functional/SecurityCest.php:39
3. $I->amOnPage("/dashboard") at tests/Functional/SecurityCest.php:38
2. $I->amLoggedInAs("App\\Entity\\User") at tests/Functional/SecurityCest.php:37
1. $I->grabEntityFromRepository("App\Entity\User",{"email":"john_doe@gmail.com"}) at tests/Functional/SecurityCest.php:34
/Users/tudortibu/Sites/symfony-module-tests/vendor/symfony/http-foundation/RequestStack.php:105
/Users/tudortibu/Sites/symfony-module-tests/vendor/symfony/security-csrf/TokenStorage/SessionTokenStorage.php:104
/Users/tudortibu/Sites/symfony-module-tests/vendor/symfony/security-csrf/TokenStorage/SessionTokenStorage.php:71
/Users/tudortibu/Sites/symfony-module-tests/vendor/symfony/security-csrf/CsrfTokenManager.php:69
/Users/tudortibu/Sites/symfony-module-tests/vendor/symfony/form/Extension/Csrf/Type/FormTypeCsrfExtension.php:78
/Users/tudortibu/Sites/symfony-module-tests/vendor/symfony/form/ResolvedFormType.php:125
/Users/tudortibu/Sites/symfony-module-tests/vendor/symfony/form/Extension/DataCollector/Proxy/ResolvedTypeDataCollectorProxy.php:86
/Users/tudortibu/Sites/symfony-module-tests/vendor/symfony/form/ResolvedFormType.php:119
/Users/tudortibu/Sites/symfony-module-tests/vendor/symfony/form/Extension/DataCollector/Proxy/ResolvedTypeDataCollectorProxy.php:86
/Users/tudortibu/Sites/symfony-module-tests/vendor/symfony/form/Form.php:904
/Users/tudortibu/Sites/symfony-module-tests/src/Controller/SomeCustomController.php:25
/Users/tudortibu/Sites/symfony-module-tests/tests/Functional/SecurityCest.php:45
/Users/tudortibu/Sites/symfony-module-tests/vendor/codeception/codeception/src/Codeception/Lib/Di.php:130
/Users/tudortibu/Sites/symfony-module-tests/vendor/codeception/codeception/src/Codeception/Test/Cest.php:184
/Users/tudortibu/Sites/symfony-module-tests/vendor/codeception/codeception/src/Codeception/Test/Cest.php:200
/Users/tudortibu/Sites/symfony-module-tests/vendor/codeception/codeception/src/Codeception/Test/Cest.php:129
/Users/tudortibu/Sites/symfony-module-tests/vendor/codeception/codeception/src/Codeception/Test/Test.php:168
/Users/tudortibu/Sites/symfony-module-tests/vendor/codeception/codeception/src/Codeception/Suite.php:130
/Users/tudortibu/Sites/symfony-module-tests/vendor/codeception/codeception/src/Codeception/SuiteManager.php:151
/Users/tudortibu/Sites/symfony-module-tests/vendor/codeception/codeception/src/Codeception/Codecept.php:260
/Users/tudortibu/Sites/symfony-module-tests/vendor/codeception/codeception/src/Codeception/Codecept.php:216
/Users/tudortibu/Sites/symfony-module-tests/vendor/codeception/codeception/src/Codeception/Command/Run.php:435
/Users/tudortibu/Sites/symfony-module-tests/vendor/symfony/console/Command/Command.php:279
/Users/tudortibu/Sites/symfony-module-tests/vendor/symfony/console/Application.php:1031
/Users/tudortibu/Sites/symfony-module-tests/vendor/symfony/console/Application.php:318
/Users/tudortibu/Sites/symfony-module-tests/vendor/symfony/console/Application.php:169
/Users/tudortibu/Sites/symfony-module-tests/vendor/codeception/codeception/src/Codeception/Application.php:112
/Users/tudortibu/Sites/symfony-module-tests/vendor/codeception/codeception/app.php:45
/Users/tudortibu/Sites/symfony-module-tests/vendor/codeception/codeception/app.php:46
/Users/tudortibu/Sites/symfony-module-tests/vendor/codeception/codeception/codecept:7
/Users/tudortibu/Sites/symfony-module-tests/vendor/bin/codecept:119
Artifacts:
Html: /Users/tudortibu/Sites/symfony-module-tests/tests/_output/App.Tests.Functional.SecurityCest.seeAuthentication.fail.html
Response: /Users/tudortibu/Sites/symfony-module-tests/tests/_output/App.Tests.Functional.SecurityCest.seeAuthentication.fail.html
ERRORS!
Tests: 2, Assertions: 2, Errors: 1.
You can test this behaviour here: https://github.com/TibuTudor/symfony-module-tests/. Thanks!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
TavoNiievez commentedon Apr 24, 2024
I'm not sure what you are trying to achieve with this code:
TavoNiievez commentedon Apr 24, 2024
Just to be clear, your problem has nothing to do with authentication, even if you wrote the code there, right?
Can you explain why you think this is a Codeception or module-symfony issue rather than a behavioral change in Symfony itself?
TibuTudor commentedon Apr 24, 2024
Hey @TavoNiievez , thank you for your response. I'm trying to call the testAddForm method which is also a route for the web admin interface, which eventually renders a form. I posted a minimal version of that method because in the real app there are additional parameters and logic. But forget my code. This example from symfony-module-test is throwing the same error.

I want to test if after the login the admin is able to access and submit this form like in the example below:
When running the test with
vendor/bin/codecept run Functional SecurityCest:seeAuthentication -vvvI get the same errorTavoNiievez commentedon Apr 24, 2024
I see.
This behavior is not specific to Symfony 7 either. It corresponds to a deprecation in SF 5.4, and it fails since SF 6.0.
Unfortunately, there is not much to do here from our side, the recommended solutions for this (See symfony/symfony#46961) involve creating a csrf token and attaching it to some dummy request to get it to do what before.
We cannot integrate this workaround into the Codeception code. Also some attempts to integrate similar solutions into Symfony's own code have not gotten attention so far.
[-]Codeception functional test on Symfony 7 'There is currently no session available'[/-][+]Symfony 6.0 functional test: 'There is currently no session available'[/+]