diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 888a327..83ccb5a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,15 +24,15 @@ jobs: - mw: 'REL1_40' php: 8.1 type: normal - experimental: true + experimental: false - mw: 'REL1_41' php: 8.1 type: normal - experimental: true + experimental: false - mw: 'REL1_42' php: 8.2 type: normal - experimental: true + experimental: false - mw: 'master' php: 8.3 type: normal diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 545ca25..702616c 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -12,15 +12,6 @@ stopOnIncomplete="false" stopOnSkipped="false" verbose="true"> - - - - true - 10 - - - tests/phpunit/Unit diff --git a/src/Hooks/DefaultHooksHandler.php b/src/Hooks/DefaultHooksHandler.php deleted file mode 100644 index 673afdb..0000000 --- a/src/Hooks/DefaultHooksHandler.php +++ /dev/null @@ -1,78 +0,0 @@ -addAllBootstrapModules(); - return true; - } - - /** - * Hook: ParserAfterParse - * - * Called from Parser::parse() just after the call to Parser::internalParse() returns. - * - * @see https://www.mediawiki.org/wiki/Manual:Hooks/ParserAfterParse - * - * @param Parser $parser - * @param string $text - * @param StripState $stripState - * @return bool - */ - public function onParserAfterParse( $parser, &$text, $stripState ): bool - { - $parser->getOutput()->addModuleStyles( ['ext.bootstrapComponents.bootstrap.fix'] ); - $parser->getOutput()->addModuleStyles( ['ext.bootstrap.styles'] ); - $parser->getOutput()->addModules( ['ext.bootstrap.scripts'] ); - return true; - } -} diff --git a/src/Hooks/OutputPageParserOutput.php b/src/Hooks/OutputPageParserOutput.php index f6e6fb1..64dae49 100644 --- a/src/Hooks/OutputPageParserOutput.php +++ b/src/Hooks/OutputPageParserOutput.php @@ -28,13 +28,13 @@ use MediaWiki\Extension\BootstrapComponents\BootstrapComponents; use MediaWiki\Extension\BootstrapComponents\BootstrapComponentsService; -use OutputPage; -use ParserOutput; /* - * TODO: When dropping support for 1.39, use these: + * TODO switch to these, wehen we drop support for mw < 1.40 use MediaWiki\Output\OutputPage; use MediaWiki\Parser\ParserOutput; -*/ + */ +use \OutputPage; +use \ParserOutput; /** * Class OutputPageParserOutput @@ -115,7 +115,7 @@ protected function getContentForLaterInjection( ParserOutput $parserOutput ): st $deferredContent = $parserOutput ->getExtensionData(BootstrapComponents::EXTENSION_DATA_DEFERRED_CONTENT_KEY ); - if (empty($deferredContent) || !is_array($deferredContent)) { + if ( empty( $deferredContent ) || !is_array( $deferredContent ) ) { return ''; } diff --git a/src/HooksHandler.php b/src/HooksHandler.php index 6ead633..2413d32 100644 --- a/src/HooksHandler.php +++ b/src/HooksHandler.php @@ -14,7 +14,9 @@ use MediaWiki\Hook\ParserFirstCallInitHook; use MediaWiki\Hook\SetupAfterCacheHook; use MediaWiki\MediaWikiServices; -use MediaWiki\Parser\Parser; +use \Parser; +// TODO switch to then when dropping support for mw < 1.40 +// use MediaWiki\Parser\Parser; use SMW\Utils\File; use StripState; @@ -97,6 +99,8 @@ public static function onScribuntoExternalLibraries( $engine, array &$extraLibra * * @see https://www.mediawiki.org/wiki/Manual:Hooks/GalleryGetModes * + * @codeCoverageIgnore trivial + * * @param array $modeArray * @return bool */ @@ -121,7 +125,7 @@ public function onGalleryGetModes( &$modeArray ): bool * * @codeCoverageIgnore trivial * - * @param \DummyLinker $linker + * @param $linker, always null (was \DummyLinker $linker) * @param \Title $title * @param File|\LocalFile $file * @param array $frameParams @@ -175,6 +179,20 @@ public function onInternalParseBeforeLinks( $parser, &$text, $stripState ): bool return true; } + + /** + * Hook: OutputPageParserOutput + * + * Called after parse, before the HTML is added to the output. + * + * @see https://www.mediawiki.org/wiki/Manual:Hooks/OutputPageParserOutput + * + * @codeCoverageIgnore trivial + * + * @param \OutputPage $outputPage + * @param \ParserOutput $parserOutput + * @return void + */ public function onOutputPageParserOutput( $outputPage, $parserOutput ): void { // @todo check, if we need to omit execution on actions edit, submit, or history // $action = $outputPage->parserOptions()->getUser()->getRequest()->getVal( "action" ); diff --git a/tests/phpunit/ExecutionTimeTestListener.php b/tests/phpunit/ExecutionTimeTestListener.php deleted file mode 100644 index 58fa0fc..0000000 --- a/tests/phpunit/ExecutionTimeTestListener.php +++ /dev/null @@ -1,105 +0,0 @@ -isEnabledToListen = $isEnabledToListen; - $this->executionTimeThresholdInSeconds = $executionTimeThresholdInSeconds; - } - - /** - * @see PHPUnit_Framework_TestListener::startTest - */ - public function startTest( PHPUnit_Framework_Test $test ): void { - } - - /** - * @see PHPUnit_Framework_TestListener::endTest - */ - public function endTest( PHPUnit_Framework_Test $test, float $length ): void { - if ( $this->isEnabledToListen && ($length > $this->executionTimeThresholdInSeconds) ) { - $this->testCollector[$test->getName()] = round( $length, 3 ); - } - } - - /** - * @see PHPUnit_Framework_TestListener::addError - */ - public function addError( PHPUnit_Framework_Test $test, Throwable $e, float $time ): void { - } - - /** - * @see PHPUnit_Framework_TestListener::addFailure - */ - public function addFailure( PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, float $time ): void { - } - - /** - * @see PHPUnit_Framework_TestListener::addError - */ - public function addIncompleteTest( PHPUnit_Framework_Test $test, Throwable $e, float $time ): void { - } - - /** - * @see PHPUnit_Framework_TestListener::addRiskyTest - * @since 4.0.0 - */ - public function addRiskyTest( PHPUnit_Framework_Test $test, Throwable $e, float $time ): void { - } - - /** - * @see PHPUnit_Framework_TestListener::addSkippedTest - */ - public function addSkippedTest( PHPUnit_Framework_Test $test, Throwable $e, float $time ): void { - } - - /** - * @see PHPUnit_Framework_TestListener::addWarning - * @since 6.0.0 - */ - public function addWarning( PHPUnit_Framework_Test $test, PHPUnit_Framework_Warning $e, float $time ): void { - } - - /** - * @see PHPUnit_Framework_TestListener::startTestSuite - */ - public function startTestSuite( PHPUnit_Framework_TestSuite $suite ): void { - } - - /** - * @see PHPUnit_Framework_TestListener::endTestSuite - */ - public function endTestSuite( PHPUnit_Framework_TestSuite $suite ): void { - foreach ( $this->testCollector as $name => $length ) { - print ("\n" . $suite->getName() . " {$name} ran for {$length} seconds" . "\n"); - unset( $this->testCollector[$name] ); - } - } - -} diff --git a/tests/phpunit/Unit/ImageModalTest.php b/tests/phpunit/Unit/ImageModalTest.php index 7a6d49c..a4ef194 100644 --- a/tests/phpunit/Unit/ImageModalTest.php +++ b/tests/phpunit/Unit/ImageModalTest.php @@ -2,7 +2,6 @@ namespace MediaWiki\Extension\BootstrapComponents\Tests\Unit; -use DummyLinker; use File; use LocalFile; use MediaWiki\Extension\BootstrapComponents\BootstrapComponentsService; @@ -437,7 +436,7 @@ private function createImageModalWithMocks( $dummyLinker = null, $title = null, $file = null, $nestingController = null, $bootstrapService = null, $parserOutputHelper = null ) { - $dummyLinker = $dummyLinker ?? $this->createMock( DummyLinker::class ); + $dummyLinker = null; $title = $title ?? $this->createMock( Title::class ); $file = $file ?? $this->createMock( LocalFile::class ); $nestingController = $nestingController ?? $this->createMock( NestingController::class );