Skip to content
This repository has been archived by the owner on Mar 20, 2024. It is now read-only.

Specify session name to get #321

Open
kochen opened this issue Apr 19, 2018 · 19 comments
Open

Specify session name to get #321

kochen opened this issue Apr 19, 2018 · 19 comments

Comments

@kochen
Copy link

kochen commented Apr 19, 2018

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.

@kochen
Copy link
Author

kochen commented Apr 19, 2018

For reference: FriendsOfBehat/SymfonyExtension#30

@kochen
Copy link
Author

kochen commented Apr 23, 2018

Same issue with Behat/Symfony2Extension

@loic425
Copy link

loic425 commented Jun 29, 2018

@everzet @stof any news about this error ? I've got same error on sf4.1

@kochen
Copy link
Author

kochen commented Jul 26, 2018

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.

@stof
Copy link
Member

stof commented Jul 26, 2018

Please provide a reproducing case

@kochen
Copy link
Author

kochen commented Jul 26, 2018

@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...

@stof
Copy link
Member

stof commented Jul 26, 2018

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.

@kochen
Copy link
Author

kochen commented Jul 26, 2018

sure, but the problem is that neither prepareDefaultMinkSession nor setDefaultSessionName are being called at all (regardless of the "right timing")

@stof
Copy link
Member

stof commented Jul 26, 2018

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)

@loic425
Copy link

loic425 commented Jul 27, 2018

@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...

@kochen
Copy link
Author

kochen commented Oct 17, 2018

@stof @loic425 took a while but here it is: https://github.com/kochen/behat-mink-session

@kochen
Copy link
Author

kochen commented Oct 18, 2018

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

@loic425
Copy link

loic425 commented Oct 18, 2018

@kochen @stof
I've same problem here on this pull-request with travis log here

@loic425
Copy link

loic425 commented Oct 19, 2018

@stof In SessionListener, prepareDefaultMinkSession is not called. I have this problem only when I remove symfony/symfony dependency.

@kochen
Copy link
Author

kochen commented Oct 20, 2018

@stof In SessionListener, prepareDefaultMinkSession is not called. I have this problem only when I remove symfony/symfony dependency.

Yes, I mentioned that here: #321 (comment)
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...

@loic425
Copy link

loic425 commented Dec 6, 2018

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
Monofony/SymfonyStarter#74

@loic425
Copy link

loic425 commented Dec 6, 2018

@stof You can close this issue.

@kochen
Copy link
Author

kochen commented Dec 6, 2018

@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.

@loic425
Copy link

loic425 commented Dec 6, 2018

@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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants