MinkExtension
MinkExtension copied to clipboard
Specify session name to get
When using in combination with Behat/MinkExtension
and setting the Symfony cache
:
Behat\MinkExtension:
sessions:
default:
symfony: ~
you get:
Specify session name to get
setting other sessions like goutte
(and its corresponding driver) results in the same issue.
For reference: https://github.com/FriendsOfBehat/SymfonyExtension/issues/30
Same issue with Behat/Symfony2Extension
@everzet @stof any news about this error ? I've got same error on sf4.1
Managed to narrow it down to prepareDefaultMinkSession (namely setDefaultSessionName
) not being called and therefor default session
not being set, so when calling getSession($name=null)
it won't find any default session.
Please provide a reproducing case
@stof
<service id="mink.default_session" class="Behat\Mink\Session" lazy="true" public="false">
<factory service="__behat__.mink" method="getSession" />
</service>
Behat\MinkExtension:
base_url: "http://localhost:8080/"
default_session: symfony
sessions:
symfony:
symfony: ~
as mentioned above, this happens with every session driver...
well, if you create your own service getting the session, this service might get instantiated too early compared to the time where we configure the default session for this scneario. Thus, it does not really make sense, as the default session can change at any scenario.
sure, but the problem is that neither prepareDefaultMinkSession
nor setDefaultSessionName
are being called at all (regardless of the "right timing")
Well, please provide a reproducing case (and the code you gave above is not a reproducing case, as I have no idea where this XML is meant to go and where the __behat__.mink
service is coming from)
@kochen You can create a small project on github to expose that. If you don't have enough time I probably can do that... but later...
@stof @loic425 took a while but here it is: https://github.com/kochen/behat-mink-session
I've added travis-ci
builds so it's easy to see the error: https://travis-ci.org/kochen/behat-mink-session/jobs/443045087#L485
@kochen @stof I've same problem here on this pull-request with travis log here
@stof In SessionListener, prepareDefaultMinkSession is not called. I have this problem only when I remove symfony/symfony dependency.
@stof In SessionListener, prepareDefaultMinkSession is not called. I have this problem only when I remove symfony/symfony dependency.
Yes, I mentioned that here: https://github.com/Behat/MinkExtension/issues/321#issuecomment-408077976
but it gives a good starting point, if it does work when symfony/symfony
is required.
Now we need to figure out what is actually making that call and how can we ensure it is also being called without that (huge) package...
I found it! This is not due to mink extension.
@kochen you just have to add symfony/proxy-manager-bridge to handle lazy option. https://symfony.com/doc/current/service_container/lazy_services.html https://github.com/Monofony/SymfonyStarter/pull/74
@stof You can close this issue.
@loic425 this indeed seems to solve the issue, but I wouldn't close the issue it just yet. @stof I think we need to document/suggest/guide users of the packages about this.
@kochen This is not a common case. This is due to the way Sylius did with its "mink.default_session" service.
<service id="mink.default_session" class="Behat\Mink\Session" lazy="true" public="false">
<factory service="__behat__.mink" method="getSession" />
</service>
But this package is already on Sylius.