3 use MediaWiki\MediaWikiServices
;
4 use PHPUnit\Framework\TestCase
;
6 abstract class MediaWikiUnitTestCase
extends TestCase
{
7 use MediaWikiCoversValidator
;
8 use PHPUnit4And6Compat
;
10 /** @var MediaWikiServices $mwServicesBackup */
11 private $mwServicesBackup;
14 * Replace global MediaWiki service locator with a clone that has the given overrides applied
15 * @param callable[] $overrides map of service names to instantiators
18 protected function overrideMwServices( array $overrides ) {
19 $services = clone MediaWikiServices
::getInstance();
21 foreach ( $overrides as $serviceName => $factory ) {
22 $services->disableService( $serviceName );
23 $services->redefineService( $serviceName, $factory );
26 $this->mwServicesBackup
= MediaWikiServices
::forceGlobalInstance( $services );
29 protected function tearDown() {
32 if ( $this->mwServicesBackup
) {
33 MediaWikiServices
::forceGlobalInstance( $this->mwServicesBackup
);