Merge "lockmanager: disable internal QuorumLockManager methods that should never...
[lhc/web/wiklou.git] / tests / phpunit / MediaWikiUnitTestCase.php
index 9ecc043..1065c2f 100644 (file)
@@ -1,36 +1,34 @@
 <?php
+/**
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup Testing
+ */
 
-use MediaWiki\MediaWikiServices;
 use PHPUnit\Framework\TestCase;
 
+/**
+ * Base class for unit tests.
+ *
+ * Extend this class if you are testing classes which use dependency injection and do not access
+ * global functions, variables, services or a storage backend.
+ */
 abstract class MediaWikiUnitTestCase extends TestCase {
-       use MediaWikiCoversValidator;
        use PHPUnit4And6Compat;
+       use MediaWikiCoversValidator;
 
-       /** @var MediaWikiServices $mwServicesBackup */
-       private $mwServicesBackup;
-
-       /**
-        * Replace global MediaWiki service locator with a clone that has the given overrides applied
-        * @param callable[] $overrides map of service names to instantiators
-        * @throws MWException
-        */
-       protected function overrideMwServices( array $overrides ) {
-               $services = clone MediaWikiServices::getInstance();
-
-               foreach ( $overrides as $serviceName => $factory ) {
-                       $services->disableService( $serviceName );
-                       $services->redefineService( $serviceName, $factory );
-               }
-
-               $this->mwServicesBackup = MediaWikiServices::forceGlobalInstance( $services );
-       }
-
-       protected function tearDown() {
-               parent::tearDown();
-
-               if ( $this->mwServicesBackup ) {
-                       MediaWikiServices::forceGlobalInstance( $this->mwServicesBackup );
-               }
-       }
 }