Provide PHPUnit 4 and 6 compatibility layer
[lhc/web/wiklou.git] / tests / phpunit / MediaWikiTestCase.php
index fe8c917..13d09ab 100644 (file)
@@ -14,9 +14,10 @@ use Wikimedia\TestingAccessWrapper;
 /**
  * @since 1.18
  */
-abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
+abstract class MediaWikiTestCase extends PHPUnit\Framework\TestCase {
 
        use MediaWikiCoversValidator;
+       use PHPUnit4And6Compat;
 
        /**
         * The service locator created by prepareServices(). This service locator will
@@ -267,7 +268,6 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
                                CACHE_MEMCACHED => $hashCache,
                                'apc' => $hashCache,
                                'apcu' => $hashCache,
-                               'xcache' => $hashCache,
                                'wincache' => $hashCache,
                        ] + $baseConfig->get( 'ObjectCaches' );
 
@@ -1080,6 +1080,8 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
                        }
                }
 
+               SiteStatsInit::doPlaceholderInit();
+
                User::resetIdByNameCache();
 
                // Make sysop user
@@ -1474,44 +1476,6 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
                }
        }
 
-       /**
-        * @since 1.18
-        *
-        * @param string $func
-        * @param array $args
-        *
-        * @return mixed
-        * @throws MWException
-        */
-       public function __call( $func, $args ) {
-               static $compatibility = [
-                       'createMock' => 'createMock2',
-               ];
-
-               if ( isset( $compatibility[$func] ) ) {
-                       return call_user_func_array( [ $this, $compatibility[$func] ], $args );
-               } else {
-                       throw new MWException( "Called non-existent $func method on " . static::class );
-               }
-       }
-
-       /**
-        * Return a test double for the specified class.
-        *
-        * @param string $originalClassName
-        * @return PHPUnit_Framework_MockObject_MockObject
-        * @throws Exception
-        */
-       private function createMock2( $originalClassName ) {
-               return $this->getMockBuilder( $originalClassName )
-                       ->disableOriginalConstructor()
-                       ->disableOriginalClone()
-                       ->disableArgumentCloning()
-                       // New in phpunit-mock-objects 3.2 (phpunit 5.4.0)
-                       // ->disallowMockingUnknownTypes()
-                       ->getMock();
-       }
-
        private static function unprefixTable( &$tableName, $ind, $prefix ) {
                $tableName = substr( $tableName, strlen( $prefix ) );
        }
@@ -1596,9 +1560,9 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
         * @param string $function
         */
        public function hideDeprecated( $function ) {
-               MediaWiki\suppressWarnings();
+               Wikimedia\suppressWarnings();
                wfDeprecated( $function );
-               MediaWiki\restoreWarnings();
+               Wikimedia\restoreWarnings();
        }
 
        /**
@@ -1892,9 +1856,9 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
 
                # This check may also protect against code injection in
                # case of broken installations.
-               MediaWiki\suppressWarnings();
+               Wikimedia\suppressWarnings();
                $haveDiff3 = $wgDiff3 && file_exists( $wgDiff3 );
-               MediaWiki\restoreWarnings();
+               Wikimedia\restoreWarnings();
 
                if ( !$haveDiff3 ) {
                        $this->markTestSkipped( "Skip test, since diff3 is not configured" );