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
Test fixtures can set up DI config #7434
Conversation
77a022d
to
fa55ac8
Compare
@@ -153,6 +153,9 @@ TestingEnvironment.prototype.setupFixture = function (fixtureClass, done) { | |||
self.reload(); | |||
self.addPluginOnCmdLineToTestEnv(); | |||
|
|||
self.fixtureClass = fixtureClass; | |||
self.save(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could be done in Fixture.php around line 240, this would allow for using the DI this way in system/integration tests too.
👍 next step would be to allow this method to be use in IntegrationTestCase/SystemTestCase (and maybe unit tests, not sure how though). |
In unit tests (and maybe integration tests) I tend to build the environment in the test (i.e. create the container with the config) because there are no separate PHP processes involved. In system tests it could indeed be interesting! |
Integration tests sometimes use fixtures, so they might need to override DI. Not sure though... |
OK! Anyway that will be the same thing as for system test so no problem for that. |
Cool :) |
Could you add documentation (even small) about using DI in Screenshot tests in this file: http://developer.piwik.org/guides/tests-ui#manipulating-the-test-environment ? Besides missing doc, looks good to me! |
Documentation added: http://developer.piwik.org/guides/tests-ui#manipulating-the-test-environment |
Question: I didn't merge the pull request myself, but it got merged and it says I merged it. Is it because i merged the other PR in #7429 and it automatically merged this one (somehow) ? I don't get this |
Looks good! |
@mattab yes when the other PR was merged the commit here was too. I didn't think of that but that's actually simpler than merging the PRs in the correct order, good to know for next time ;) |
In order to add tests for #7429 I added a way to provide DI configuration in test fixtures. This DI config is then applied to Piwik while running during the UI tests (like the "test environment" variables that allow to edit the INI config). That's really cool because then we can override any config/service to mock it.
Here is an example where I replace a service with a mock:
To provide DI config, a fixture has to implement
provideContainerConfig()
and return an array of config.#7429 is based on this PR so it should be merged for 2.12 (and before #7429).