drupalextension
drupalextension copied to clipboard
$this->session is not initialized
I don't know what I am doing in a wrong way, but every scenario fails with a logged-in user. It seems to me some kind of session cleanup does not work after a scenario.
Feature: Foo
@api @javascript
Scenario: Bar
Given I am logged in as a user with the "Administrator" role
And I am at "/"
Gives the following output:
1 scenario (1 passed) 2 steps (2 passed)
And
[PHP Fatal error: Uncaught Error: Call to a member function get() on null in /.../docroot/core/lib/Drupal/Core/Session/SessionHandler.php:76 Stack trace: #_0 /.../docroot/core/lib/Drupal/Core/Session/WriteSafeSessionHandler.php(89): Drupal\Core\Session\SessionHandler->write('ZkFil2yE1y26ROS...', '_sf2_meta|a:4:{...') #_1 /.../vendor/symfony/http-foundation/Session/Storage/Proxy/SessionHandlerProxy.php(67): Drupal\Core\Session\WriteSafeSessionHandler->write('ZkFil2yE1y26ROS...', '_sf2_meta|a:4:{...') #_2 [internal function]: Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy->write('ZkFil2yE1y26ROS...', '_sf2_meta|a:4:{...') #_3 [internal function]: session_write_close() #_4 {main} thrown in /.../docroot/core/lib/Drupal/Core/Session/SessionHandler.php on line 76]
- drupal/core-recommended 9.0.9
- drupal/drupal-extension 4.1.0
This sounds familiar. Do you perhaps have a @BeforeScenario
or @BeforeSuite
hook in one of your context classes that is trying to access the session?
Please check if you have any of those. They should not have any calls to $this->getSession()
since these hooks fire before the session is initialized.
Thanks. I will check it again, but I already reduced the classes in the "default.suites.default.contexts" array to te minimum. Maybe they are in the wrong order or something. It doesn't matter how many feature or scenario I run, this exception is keep coming after the suite.