<p dir="auto">After updating to 2.6.5 we got the error in our tests:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Acme/Bundle/TestBundle/Tests/Controller/Foo/BarControllerTest::testSomeAction
LogicException: Cannot set session ID after the session has started.

vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php:134
vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Session.php:199
vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/TestSessionListener.php:45
vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php:61
vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:164
vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:53
vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php:167
vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php:112
vendor/jmikola/wildcard-event-dispatcher/src/Jmikola/WildcardEventDispatcher/WildcardEventDispatcher.php:36
vendor/event-band/symfony-adapter/src/EventBand/Adapter/Symfony/BandEventDispatcher.php:57
vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:126
vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:66
vendor/symfony/symfony/src/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php:64
vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:186
vendor/acme/core-bundle/Acme/Bundle/CoreBundle/Component/Phpunit/WebTestCase.php:328
src/Acme/Bundle/TestBundle/Tests/Controller/Foo/BarControllerTest.php:170"><pre class="notranslate"><code class="notranslate">Acme/Bundle/TestBundle/Tests/Controller/Foo/BarControllerTest::testSomeAction
LogicException: Cannot set session ID after the session has started.

vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php:134
vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Session.php:199
vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/TestSessionListener.php:45
vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php:61
vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:164
vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:53
vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php:167
vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php:112
vendor/jmikola/wildcard-event-dispatcher/src/Jmikola/WildcardEventDispatcher/WildcardEventDispatcher.php:36
vendor/event-band/symfony-adapter/src/EventBand/Adapter/Symfony/BandEventDispatcher.php:57
vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:126
vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:66
vendor/symfony/symfony/src/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php:64
vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:186
vendor/acme/core-bundle/Acme/Bundle/CoreBundle/Component/Phpunit/WebTestCase.php:328
src/Acme/Bundle/TestBundle/Tests/Controller/Foo/BarControllerTest.php:170
</code></pre></div>
<p dir="auto">On 2.6.4 everything is ok</p>
<p dir="auto">Hi there,</p>
<p dir="auto">the exception is thrown by this line:<br>
<a href="https://github.com/symfony/symfony/blob/2.5/src/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php#L134">https://github.com/symfony/symfony/blob/2.5/src/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php#L134</a></p>
<p dir="auto">My setup works completely fine within a valid PHP environment (without <code class="notranslate">TestSessionListener</code>) - data getting stored in the session before the <code class="notranslate">TestSessionListener::onKernelRequest</code> has been executed (using <code class="notranslate">MockFileSessionStorage</code>).</p>
<p dir="auto">What's the intention of this exception? I can't get my head around it. The <code class="notranslate">TestSessionListener</code> is explicitly doing this (<code class="notranslate">setId</code>) and if there is another object accessing the session before the <code class="notranslate">TestSessionListener</code> sets the id, an id is automatically generated. The listener is not correctly mimicking the session creation of PHP and this exception makes it (for some parts) unusable.</p>
<p dir="auto">If there is no actual use on this exception, it may be removed, no?</p>