[13:04:50] I am trying to understand why test in https://gerrit.wikimedia.org/r/c/mediawiki/extensions/MathSearch/+/1141022 fail. I am wondering if something changed so that MediaWikiServices::getInstance()->get( $serviceName ) returns now null in a MediaWikiIntegrationTestCase [13:12:09] MediaWikiServices is not particularly different in integration tests and normal operation [13:12:41] it will return null if and only if the factory method for the service returns null [13:15:55] tgr_: thank you do you have an idea what might be wrong when looking at https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Math/+/1140532/7/src/Math.php#56 maybe I just overlooked something stupid [13:22:03] some other test mocks MediaWikiServices and it bleeds over? [13:23:01] that's a good idea [13:24:57] don't see anything like that in MathSearch, though [13:25:24] in math https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Math/+/1140532/7/tests/phpunit/unit/WikiTexVC/MathServiceContainerTrait.php#38 (however, it sets config) maybe someting similar is done in core [13:25:27] and MediaWikiIntegrationTestCase should be resetting it anyway [13:26:13] right, that's not the main services container but Math's custom copy which does not get reset [13:26:52] still not sure why you'd end up with null, rather than the mock [13:27:24] I guess the mock's behavior is not well-defined outside its own test? [13:28:12] so anyway if you really want your own static container, it should be reset in tearDown for each test that modifies it [13:36:00] yeah that's the best we could come up now. Maybe we still don't fully understand the framework and abuse the ContainerInterface in an unintend way, but that's hard to figure out. So I'll add tearDown methods and check if that solves the problem [13:36:02] thank you [13:36:40] the mocking is not itself the problem [13:37:04] but static properties aren't automatically restored between tests [13:38:20] all tests run in the same PHP process (well, there's some parallelization, but many tests run in the same process); if you make a change to a static property, a global etc, the next test will see that [13:39:21] and in this case you set Math::$serviceContainer to a mock object and mock objects usually return null to all function calls [13:40:04] my question is why core services don't need the static property? How does core mock the test services instead [13:40:19] and you tell the mock object to return something else on a get() call, but I'm guessing mock specifications are bound to the TestCase and disappear at the end of the test, while the mock object itself will still exist [13:40:56] MediaWikiIntegrationTestCase resets a bunch of state between tests, including the MediaWikiServices object [13:41:29] see MediaWikiIntegrationTestCase::restoreMwServices() [13:41:51] ok [13:42:04] well, installMockMwServices() is probably the more informative method [13:43:06] btw in an integration test you can just use $this->setService to add a service override for the duration of the test [13:43:26] and a unit test probably shouldn't have anything to do with services [13:45:54] yes, but we are not there yet;-) [13:46:42] you can always just turn it into an integration test until it's lean enough, it's just a parent class change [13:46:56] and then this kind of thing gets automatically managed for you [13:48:14] to me integration test seem to be much slower [14:04:54] The ones which use the DB (are in the @Database group) are slow, because they make a new copy of the DB before each test. [14:05:43] The ones which don't aren't much slower I think.