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

Config::getFromLocalConfig + tests #7639

Merged
merged 10 commits into from Apr 13, 2015
Merged

Config::getFromLocalConfig + tests #7639

merged 10 commits into from Apr 13, 2015

Conversation

ThaDafinser
Copy link
Contributor

Follow up from #7318

$globalFile = PIWIK_INCLUDE_PATH . '/tests/resources/Config/global.ini.php';
$commonFile = PIWIK_INCLUDE_PATH . '/tests/resources/Config/common.config.ini.php';

$config = Config::getInstance();
Copy link
Member

Choose a reason for hiding this comment

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

The singleton instance shouldn't be used in unit tests; create a new instance instead, ie, new Config(...). setTestEnvironment shouldn't be used for these tests as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@diosmosis why are those are used in the other tests? https://github.com/ThaDafinser/piwik/blob/patch-3/tests/PHPUnit/Unit/ConfigTest.php#L52-L54

i updated the tests :-)

Copy link
Member

Choose a reason for hiding this comment

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

why are those are used in the other tests?

Legacy code :) I've actually removed them in a branch I'm working on.

@mattab mattab added the Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review. label Apr 8, 2015
@mattab mattab added this to the Short term milestone Apr 8, 2015
@mattab mattab added Task Indicates an issue is neither a feature nor a bug and it's purely a "technical" change. c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself. labels Apr 8, 2015
@ThaDafinser
Copy link
Contributor Author

@diosmosis @mattab now it's green and the unitTest is changed
https://travis-ci.org/piwik/piwik/jobs/57630928

@mattab mattab modified the milestones: Piwik 2.13.0, Short term Apr 8, 2015
@mattab mattab added Needs Review PRs that need a code review and removed Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review. labels Apr 8, 2015
$config->reload();

$configCategory = $config->getFromCommonConfig('Category');
$this->assertEquals('valueCommon', $configCategory['key2']);
Copy link
Member

Choose a reason for hiding this comment

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

Can you test against the whole section instead of just 'key2'? Ie, array('key2' => ..., 'key3' => ...). Same for the other two tests. After that, I'll merge.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@diosmosis i added the test.

But as u can see in the previous commit, this test would fail...we should fix that with next config update.

        $this->assertEquals('${@piwik(crash))}', $configCategory['key3']);

https://travis-ci.org/piwik/piwik/jobs/58226014

Copy link
Member

Choose a reason for hiding this comment

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

Dollar signs are supposed to be HTML encoded in config files, this fixes a bug/"feature" in parse_ini_file().

Can you make it test against an array? ie $this->assertEquals(array('key2' => ..., 'key3' => ...), $configCategory);? This will test that the section only has the expected keys, in addition to testing the values of those keys.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I see what you mean about the test failure; I'll look into it, it may be a bug.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@diosmosis i will provide a test against an array, but next time i wont....
Please dont provide information about what you want piece by piece...tell it me one time what you all need or want in the PR to be updated.

The problem is following:
Both (you and me) need to get back everytime again on the PR which needs a lot of unnecessary time and like to complete things

//edit: sry that i'm so directy, but for such a small PR 3 times back is to much

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@diosmosis about the failure with the HTML this need to be checked in another PR, since this was not introduced here.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry for the back & forth. I don't mind making the tiny changes myself, but I thought it might be rude to do so for someone else's PR. I also don't mind directness, it tends to speed things up.

Re the test failure: I meant I will fix the issue in master before merging this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 for me its not rude (since OS is all about collaboration), but some people may be offended you are right.

@ThaDafinser
Copy link
Contributor Author

@diosmosis test is now against the array as well
ThaDafinser@bf0587e
https://travis-ci.org/piwik/piwik/jobs/58251435

diosmosis added a commit that referenced this pull request Apr 13, 2015
Add Config::getFromLocalConfig method to get config section from local config w/o default values from global/common config added + tests.
@diosmosis diosmosis merged commit 7e31bcb into matomo-org:master Apr 13, 2015
diosmosis pushed a commit that referenced this pull request Apr 14, 2015
@ThaDafinser
Copy link
Contributor Author

Thanks for merge

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 Task Indicates an issue is neither a feature nor a bug and it's purely a "technical" change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants