This problem interferes with development and is a nuisance which makes it harder to write php changes.
RequestContext::getMain() causes a side effect - it creates a static instance of RequestContext inside RequestContext class. When unit tests operates on RequestContext it modifies the cached global instance which may cause bad behaviour.
As an example some of the phpunit tests in MobileFrontend fail when run in isolation. Here's an attempt to fix one of them. We also cannot create a mock RequestContext and pass it to SkinMinerva.
There are at least two ways of fixing it:
- proper solution: do not use RequestContext::getMain() inside unit tests - as a result we will have to refactor SkinMinerva::__construct() to not call SkinMinerva::getTitle() which calls RequestContext::getMain()
- quick hack - each unittests which calls RequestContext::getMain() should have defined tearDown() method that calls RequestContest::resetMain()