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

Injection Inception, Change #2: Adding Config to DI #7957

Merged
merged 9 commits into from May 26, 2015
Merged

Conversation

diosmosis
Copy link
Member

This PR adds the Config singleton to DI (removing the use of the singleton). Additional changes include:

  • The EnvironmentManipulator internal concept. Simplified from the previous monolithic PR. Allows TestingEnvironment to inject a GlobalSettingsProvider in all Environment instances, and is only a reasonably hacky solution. (Previous solution in commit of the last PR was three static members for config file locations.)
  • Config::setTestEnvironment() is moved to TestConfig. Other plugins that use the method will have to be modified (I think only LoginLdap).
  • The testing environment logic that is executed in a hook to Config.createConfigSingleton was moved to TestConfig.
  • The Config.createConfigSIngleton event was removed. Only reason to have it was for doing TestingEnvironment setup, and now that that's in TestCOnfig, the event is not needed.

Note: tests won't pass, I need to fix them and include the changes in the correct commits.

@diosmosis diosmosis added c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself. Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review. Needs Review PRs that need a code review labels May 21, 2015
@diosmosis diosmosis added this to the 2.14.0 milestone May 21, 2015
@@ -14,4 +14,5 @@
'Piwik\Translation\Translator' => DI\object()
->constructorParameter('directories', array()),

'Piwik\Config' => DI\object('Piwik\Tests\Framework\Mock\TestConfig')
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a trailing ,? 😉

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@mnapoli
Copy link
Contributor

mnapoli commented May 22, 2015

By the way super easy to review by commit (especially since all commits but one are really simple to understand) 👍

diosmosis added 4 commits May 22, 2015 13:34
…ment.php to the TestConfig class. Since this logic is meant to be executed directly after a Config instance is created, and is only used when TestConfig is used, we can do this.
…in Config.php. Also removed the $initialized property, which is only used to lazily post the test event.
…anging some non-pro plugins when merged (LoginLdap only I think).
@diosmosis diosmosis force-pushed the test_env_di_3 branch 2 times, most recently from 44b8285 to ccf9c12 Compare May 23, 2015 00:17
@diosmosis
Copy link
Member Author

Finished up the PR, build is passing except for one system test. No idea why it's failing, when I tried to debug it went away. Seems to be random.

@diosmosis diosmosis removed the Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review. label May 23, 2015
@diosmosis diosmosis self-assigned this May 23, 2015
@mattab
Copy link
Member

mattab commented May 24, 2015

No idea why it's failing, when I tried to debug it went away. Seems to be random.

I notice there are some failures that are not random eg. <b>Fatal error</b>: Declaration of Piwik\\Tests\\Framework\\TestingEnvironment\\MakeGlobalSettingsWithFile::makeGlobalSettingsProvider() must be compatible with Piwik\\Application\\EnvironmentManipulator::makeGlobalSettingsProvider() in <b>/home/travis/build/piwik/piwik/tests/PHPUnit/Framework/TestingEnvironment/MakeGlobalSettingsWithFile.php</b> on line <b>15</b><br />

For the random build issue, can you create an issue? (everyone in the team will know that this test result could randomly fail)

diosmosis added 5 commits May 24, 2015 15:22
…rough DI config. Replaced the singleton GlobalSettingsProvider hack w/ the concept of an EnvironmentManipulator (internal to Piwik, not to be used anywhere but TestingEnvironment.php).
…vironmentManipulators, don't use custom config files in AssetManagerTest. This includes using custom logic for testing if a plugin is core (since we can't change global.ini.php contents).
…w, and setting config must be done after environment is created.
…ing fails because the environment has not been created yet. Fixes EnvironmentValidationTest. Includes new exception thrown when StaticContainer cannot find an existing container.
diosmosis added a commit that referenced this pull request May 26, 2015
Adding Config instance to DI and move all Config related test setup code from Config.php and TestingEnvironment.php to TestConfig class. Introduced completely internal EnvironmentManipulator concept so tests can change paths of local/global/common INI config file.
@diosmosis diosmosis merged commit 05eec30 into master May 26, 2015
@diosmosis diosmosis deleted the test_env_di_3 branch May 26, 2015 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself. Needs Review PRs that need a code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants