diff --git a/composer.json b/composer.json index 70677558c75..5c77c405341 100644 --- a/composer.json +++ b/composer.json @@ -60,7 +60,6 @@ "zordius/lightncandy": "0.23" }, "require-dev": { - "cache/integration-tests": "0.16.0", "composer/spdx-licenses": "1.5.1", "doctrine/dbal": "2.9.3", "giorgiosironi/eris": "^0.10.0", @@ -73,14 +72,15 @@ "nikic/php-parser": "4.2.4", "seld/jsonlint": "1.7.1", "nmred/kafka-php": "0.1.5", - "phpunit/phpunit": "^6.5.14", + "phpunit/phpunit": "^7.5.13", "psy/psysh": "0.9.9", "wikimedia/avro": "1.9.0", "wikimedia/testing-access-wrapper": "~1.0", "wmde/hamcrest-html-matchers": "^0.1.0", "mediawiki/mediawiki-phan-config": "0.8.0", "symfony/yaml": "~3.4 | 4.3.4", - "johnkary/phpunit-speedtrap": "^1.0 | ^2.0" + "johnkary/phpunit-speedtrap": "^3.1", + "phpunit/php-invoker": "^2.0" }, "replace": { "symfony/polyfill-ctype": "1.99", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 1a05e81e001..906c5ecfd9d 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -15,7 +15,7 @@ timeoutForLargeTests="60" beStrictAboutTestsThatDoNotTestAnything="true" beStrictAboutOutputDuringTests="true" - beStrictAboutTestSize="true" + enforceTimeLimit="true" verbose="false"> diff --git a/tests/phpunit/MediaWikiLoggerPHPUnitTestListener.php b/tests/phpunit/MediaWikiLoggerPHPUnitTestListener.php index b19c8ac596b..97e77595c0b 100644 --- a/tests/phpunit/MediaWikiLoggerPHPUnitTestListener.php +++ b/tests/phpunit/MediaWikiLoggerPHPUnitTestListener.php @@ -34,19 +34,19 @@ class MediaWikiLoggerPHPUnitTestListener implements TestListener { LoggerFactory::registerProvider( $this->spi ); } - public function addRiskyTest( Test $test, Exception $e, $time ) : void { + public function addRiskyTest( Test $test, Throwable $e, $time ) : void { $this->augmentTestWithLogs( $test ); } - public function addIncompleteTest( Test $test, Exception $e, $time ) : void { + public function addIncompleteTest( Test $test, Throwable $e, $time ) : void { $this->augmentTestWithLogs( $test ); } - public function addSkippedTest( Test $test, Exception $e, $time ) : void { + public function addSkippedTest( Test $test, Throwable $e, $time ) : void { $this->augmentTestWithLogs( $test ); } - public function addError( Test $test, Exception $e, $time ) : void { + public function addError( Test $test, Throwable $e, $time ) : void { $this->augmentTestWithLogs( $test ); } diff --git a/tests/phpunit/MediaWikiPHPUnitTestListener.php b/tests/phpunit/MediaWikiPHPUnitTestListener.php index 27c13751ea2..445f6a6f802 100644 --- a/tests/phpunit/MediaWikiPHPUnitTestListener.php +++ b/tests/phpunit/MediaWikiPHPUnitTestListener.php @@ -29,7 +29,7 @@ class MediaWikiPHPUnitTestListener implements TestListener { return $name; } - protected function getErrorName( Exception $exception ) : string { + protected function getErrorName( Throwable $exception ) : string { $name = get_class( $exception ); $name = "[$name] " . $exception->getMessage(); @@ -40,10 +40,10 @@ class MediaWikiPHPUnitTestListener implements TestListener { * An error occurred. * * @param Test $test - * @param Exception $e + * @param Throwable $e * @param float $time */ - public function addError( Test $test, Exception $e, $time ) : void { + public function addError( Test $test, Throwable $e, float $time ) : void { wfDebugLog( $this->logChannel, 'ERROR in ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e ) @@ -57,7 +57,7 @@ class MediaWikiPHPUnitTestListener implements TestListener { * @param AssertionFailedError $e * @param float $time */ - public function addFailure( Test $test, AssertionFailedError $e, $time ) : void { + public function addFailure( Test $test, AssertionFailedError $e, float $time ) : void { wfDebugLog( $this->logChannel, 'FAILURE in ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e ) @@ -68,13 +68,13 @@ class MediaWikiPHPUnitTestListener implements TestListener { * Incomplete test. * * @param Test $test - * @param Exception $e + * @param Throwable $t * @param float $time */ - public function addIncompleteTest( Test $test, Exception $e, $time ) : void { + public function addIncompleteTest( Test $test, Throwable $t, float $time ) : void { wfDebugLog( $this->logChannel, - 'Incomplete test ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e ) + 'Incomplete test ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $t ) ); } @@ -82,13 +82,13 @@ class MediaWikiPHPUnitTestListener implements TestListener { * Skipped test. * * @param Test $test - * @param Exception $e + * @param Throwable $t * @param float $time */ - public function addSkippedTest( Test $test, Exception $e, $time ) : void { + public function addSkippedTest( Test $test, Throwable $t, float $time ) : void { wfDebugLog( $this->logChannel, - 'Skipped test ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e ) + 'Skipped test ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $t ) ); } @@ -126,7 +126,7 @@ class MediaWikiPHPUnitTestListener implements TestListener { * @param Test $test * @param float $time */ - public function endTest( Test $test, $time ) : void { + public function endTest( Test $test, float $time ) : void { Hooks::run( 'MediaWikiPHPUnitTest::endTest', [ $test, $time ] ); wfDebugLog( $this->logChannel, 'End test ' . $this->getTestName( $test ) ); } diff --git a/tests/phpunit/includes/user/PasswordResetTest.php b/tests/phpunit/includes/user/PasswordResetTest.php index d7a327181ed..4589be1e603 100644 --- a/tests/phpunit/includes/user/PasswordResetTest.php +++ b/tests/phpunit/includes/user/PasswordResetTest.php @@ -43,7 +43,7 @@ class PasswordResetTest extends MediaWikiTestCase { ->with( $user, 'editmyprivateinfo' ) ->willReturn( $canEditPrivate ); - $loadBalancer = $this->getMockBuilder( ILoadBalancer::class )->getMock(); + $loadBalancer = $this->createMock( ILoadBalancer::class ); $passwordReset = new PasswordReset( $config, @@ -239,8 +239,7 @@ class PasswordResetTest extends MediaWikiTestCase { 'SpecialPasswordResetOnSubmit' => [], ] ); - $loadBalancer = $this->getMockBuilder( ILoadBalancer::class ) - ->getMock(); + $loadBalancer = $this->createMock( ILoadBalancer::class ); $users = $this->makeUsers(); diff --git a/tests/phpunit/structure/AutoLoaderStructureTest.php b/tests/phpunit/structure/AutoLoaderStructureTest.php index c20be5720e4..f9b3158a9bc 100644 --- a/tests/phpunit/structure/AutoLoaderStructureTest.php +++ b/tests/phpunit/structure/AutoLoaderStructureTest.php @@ -1,5 +1,7 @@ getFilesAsArray( $dir, [ '.php' ] ); + return ( new Facade() )->getFilesAsArray( $dir, [ '.php' ] ); } /** diff --git a/tests/phpunit/structure/StructureTest.php b/tests/phpunit/structure/StructureTest.php index 412ee991f9e..e20b13c7ed5 100644 --- a/tests/phpunit/structure/StructureTest.php +++ b/tests/phpunit/structure/StructureTest.php @@ -1,4 +1,7 @@ getFilesAsArray( $dir, [ '.php' ] ); + return ( new Facade() )->getFilesAsArray( $dir, [ '.php' ] ); } } diff --git a/tests/phpunit/suite.xml b/tests/phpunit/suite.xml index d7d3c6130b3..f5319961749 100644 --- a/tests/phpunit/suite.xml +++ b/tests/phpunit/suite.xml @@ -15,7 +15,7 @@ timeoutForLargeTests="60" beStrictAboutTestsThatDoNotTestAnything="true" beStrictAboutOutputDuringTests="true" - beStrictAboutTestSize="true" + enforceTimeLimit="true" verbose="false"> diff --git a/tests/phpunit/suites/ExtensionsTestSuite.php b/tests/phpunit/suites/ExtensionsTestSuite.php index 11dfd5ea40f..31a74a9b6ea 100644 --- a/tests/phpunit/suites/ExtensionsTestSuite.php +++ b/tests/phpunit/suites/ExtensionsTestSuite.php @@ -1,6 +1,7 @@ getFilesAsArray( $path, $suffixes ); $this->addTestFiles( $matchingFiles ); } elseif ( file_exists( $path ) ) {