Page MenuHomePhabricator

Make PropertyLabelResolverTest a proper unit test
Closed, ResolvedPublic

Description

The WikibaseClient.PropertyLabelResolver service wiring uses the ObjectCache::getInstance( $cacheType ) function with a variable $cacheType. If no such instance is set yet, then ObjectCache will try to access MediaWiki globals and the default service container to create the instance. This means that the unit test for that service wiring actually can’t run without MediaWiki being set up.

Because the cache type is variable, this won’t be solved by T243233. Given that the ObjectCache::$instances array is public, maybe we can just set a mock cache in the test case setup, so that getInstance() will return it without trying to create an instance?

The alternative would be some kind of ObjectCacheFactory service, I guess (with a non-static getInstance() or similar method, so that we can inject a mock version into the service wiring).