Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Symfony] Make grabService use the special test service container if available #5706

Merged
merged 1 commit into from
Oct 10, 2019

Conversation

burned42
Copy link
Contributor

@burned42 burned42 commented Oct 1, 2019

As @ThomasLandauer reported via #5073 quite some time ago, grabService seems to be somewhat broken for newer Symfony versions (>= 4.1 ?).

With Symfony 4.1 a special service container was added that can be accessed via test.service_container for testing purposes which also provides access to private services:
https://symfony.com/doc/current/testing.html#accessing-the-container

I also added a test to the symfony-demo project at Codeception/symfony-demo@master...burned42:add_service_container_test and if this PR will get accepted then I'd also open a PR for that branch.

I tried to let the CI run with these tests with:

So to me it seems like the issue is solved with these changes. Maybe someone more familiar with the Symfony module can also take a look at this :)

grabService seems to be somewhat broken for newer Symfony versions (> 4.1 ?) and with Symfony 4.1 a special container can be accessed via `test.service_container` for testing purposes which also provides access to private services:

https://symfony.com/doc/current/testing.html#accessing-the-container
@burned42 burned42 changed the title [Symfony] Make grabService use the special test service container [Symfony] Make grabService use the special test service container if available Oct 1, 2019
Copy link
Member

@Naktibalda Naktibalda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, but I am not familiar with Symfony,
I'm afraid that we have no Symfony experts to review it.

@ThomasLandauer
Copy link
Member

If you tell me how to get this commit into my project (composer.json?), I will double check if it's working.

@burned42
Copy link
Contributor Author

burned42 commented Oct 9, 2019

@ThomasLandauer to use the version from my branch add this to your composer.json

    "repositories": [
        { "type": "vcs", "url": "https://github.com/burned42/Codeception" }
    ]

And change the line in require-dev from
"codeception/codeception": "3.1",
to
"codeception/codeception": "dev-fix_grabService_symfony4 as 3.1",

FYI: For me composer hit the API rate limiting from github and provided me with a link to get a token. After generating and entering this token it installed the version from my branch into my project.

@Naktibalda
Copy link
Member

Does it work?

@ThomasLandauer
Copy link
Member

Sorry guys for being so late! Since burned42:fix_grabService_symfony4 is gone now, I just updated to Codeception 3.1.2.

It works for me in both Symfony 4.3 and 3.4 :-)

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

Successfully merging this pull request may close these issues.

3 participants