I am not very happy about this but we came to the case where it might be useful to explicitly uninstall some hook(s) for out unit tests.
You might want to checkout MediaWikiTestCase::uninstallHook
https://gerrit.wikimedia.org/r/#/c/99349/
I am not happy about blurring differences between unit and integration testing, but breaking core with extensions and vice versa is sometimes useful.
//Saper
Hey,
I am not very happy about this but we came to the case
where it might be useful to explicitly uninstall some hook(s) for out unit tests.
You might want to checkout MediaWikiTestCase:: uninstallHook
https://gerrit.wikimedia.org/r/#/c/99349/
I am not happy about blurring differences between unit and integration testing, but breaking core with extensions and vice versa is sometimes useful.
If you have a test that is impacted by the hook system, it is not a real unit test. Making real unit tests for most MediaWiki code is easier said then done, though this is caused by the code, not the testing framework. To quote Misko Hervey, "the secret in testing is writing testable code". I recommend trying to minimize not needed binding in both production code and tests. For instance deriving from MediaWikiTestCase should not be needed often. Bad test code is as much a liability as bad production code.
Cheers
-- Jeroen De Dauw http://www.bn2vs.com Don't panic. Don't be evil. ~=[,,_,,]:3 --
Le 05/12/13 14:49, Marcin Cieslak a écrit :
I am not very happy about this but we came to the case where it might be useful to explicitly uninstall some hook(s) for out unit tests.
You might want to checkout MediaWikiTestCase::uninstallHook
https://gerrit.wikimedia.org/r/#/c/99349/
I am not happy about blurring differences between unit and integration testing, but breaking core with extensions and vice versa is sometimes useful.
For the context, that is about testing the MediaWiki core method MWTimestamp::getHumanTimestamp(). Given a timestamp it returns something that look more appealing to human.
There is a GetHumanTimestamp() that let you override the method behaviour which is used by the cldr extension.
Hence, when running the MediaWiki core tests without any extension the test pass but as soon as cldr is registered the behavior change and the tests fails as expected.
What I would do instead is insert in the core test a feature that detects something has been registered for GetHumanTimestamp hook and skip the test entirely with a message like:
"some extension registered GetHumanTimestamp hook altering the behaviour of MWTimestamp::getHumanTimestamp(). Skipping test."
No need to hack the global imho.
(copy pasting above on Gerrit change).
Yes, I needed to turn off visual editor because it was altering the section header 'edit' text which was causing parser tests to fail. I fixed it like this: https://gerrit.wikimedia.org/r/84436 --scott
wikitech-l@lists.wikimedia.org