Merge "Remove usages of RequestContext::getStats()"
[lhc/web/wiklou.git] / tests / phpunit / MediaWikiTestCase.php
index 564c0ff..bc9f97c 100644 (file)
@@ -1,9 +1,11 @@
 <?php
+
 use MediaWiki\Logger\LegacySpi;
 use MediaWiki\Logger\LoggerFactory;
 use MediaWiki\Logger\MonologSpi;
 use MediaWiki\MediaWikiServices;
 use Psr\Log\LoggerInterface;
+use Wikimedia\TestingAccessWrapper;
 
 /**
  * @since 1.18
@@ -1298,6 +1300,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
         */
        public function __call( $func, $args ) {
                static $compatibility = [
+                       'createMock' => 'createMock2',
                ];
 
                if ( isset( $compatibility[$func] ) ) {
@@ -1307,6 +1310,23 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
                }
        }
 
+       /**
+        * 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 ) );
        }