diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index df5ea06..8f52052 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,6 +11,7 @@ jobs: name: "PHPUnit: MW ${{ matrix.mw }}, PHP ${{ matrix.php }} (TYPE ${{ matrix.type }})" strategy: + fail-fast: false matrix: include: - mw: 'REL1_39' @@ -37,6 +38,10 @@ jobs: php: 8.3 type: normal experimental: true + - mw: 'REL1_46' + php: 8.4 + type: normal + experimental: true - mw: 'master' php: 8.4 type: normal @@ -68,7 +73,7 @@ jobs: - name: Cache MediaWiki id: cache-mediawiki - uses: actions/cache@v4 + uses: actions/cache@v5 with: path: | mediawiki @@ -77,12 +82,12 @@ jobs: key: mw_${{ matrix.mw }}-php${{ matrix.php }} - name: Cache Composer cache - uses: actions/cache@v4 + uses: actions/cache@v5 with: path: ~/.composer/cache key: composer-php${{ matrix.php }} - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: path: EarlyCopy @@ -91,7 +96,7 @@ jobs: working-directory: ~ run: bash EarlyCopy/.github/workflows/installWiki.sh ${{ matrix.mw }} BootstrapComponents - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: path: mediawiki/extensions/BootstrapComponents @@ -103,12 +108,34 @@ jobs: run: bash EarlyCopy/.github/workflows/uploadImages.sh - if: env.TYPE != 'coverage' - name: Run PHPUnit w/o coverage - run: php tests/phpunit/phpunit.php -c extensions/BootstrapComponents/ --testsuite bootstrap-components-unit + name: Run PHPUnit + run: | + if [ -f tests/phpunit/phpunit.php ]; then + php tests/phpunit/phpunit.php -c extensions/BootstrapComponents/ --testsuite bootstrap-components-unit + else + # MW 1.46 and later + if [ ! -f phpunit.xml.template ]; then + wget -q -O phpunit.xml.template "https://raw.githubusercontent.com/wikimedia/mediawiki/${{ matrix.mw }}/phpunit.xml.template" + fi + composer phpunit:config + # Temporary integration-test workaround; see master issue #98. + MEDIAWIKI_HAS_INTEGRATION_TESTS=1 vendor/bin/phpunit -c phpunit.xml extensions/BootstrapComponents/tests/phpunit/Unit + fi - if: env.TYPE == 'coverage' - name: Run PHPUnit w/ coverage - run: php tests/phpunit/phpunit.php -c extensions/BootstrapComponents/ --testsuite bootstrap-components-unit --coverage-clover coverage.clover + name: Run PHPUnit (coverage) + run: | + if [ -f tests/phpunit/phpunit.php ]; then + php tests/phpunit/phpunit.php -c extensions/BootstrapComponents/ --testsuite bootstrap-components-unit --coverage-clover coverage.clover + else + # MW 1.46 and later + if [ ! -f phpunit.xml.template ]; then + wget -q -O phpunit.xml.template "https://raw.githubusercontent.com/wikimedia/mediawiki/${{ matrix.mw }}/phpunit.xml.template" + fi + composer phpunit:config + # Temporary integration-test workaround; see master issue #98. + MEDIAWIKI_HAS_INTEGRATION_TESTS=1 vendor/bin/phpunit -c phpunit.xml extensions/BootstrapComponents/tests/phpunit/Unit --coverage-clover coverage.clover + fi - if: env.TYPE == 'coverage' name: upload coverage report diff --git a/tests/phpunit/Integration/JSONScript/BootstrapComponentsJsonTestCaseScriptRunnerTest.php b/tests/phpunit/Integration/JSONScript/BootstrapComponentsJSONScriptTestCaseRunnerTest.php similarity index 100% rename from tests/phpunit/Integration/JSONScript/BootstrapComponentsJsonTestCaseScriptRunnerTest.php rename to tests/phpunit/Integration/JSONScript/BootstrapComponentsJSONScriptTestCaseRunnerTest.php diff --git a/tests/phpunit/Integration/JSONScript/readmeContentsBuilder.php b/tests/phpunit/Integration/JSONScript/ReadmeContentsBuilder.php similarity index 100% rename from tests/phpunit/Integration/JSONScript/readmeContentsBuilder.php rename to tests/phpunit/Integration/JSONScript/ReadmeContentsBuilder.php diff --git a/tests/phpunit/Unit/BootstrapComponentServiceTest.php b/tests/phpunit/Unit/BootstrapComponentsServiceTest.php similarity index 98% rename from tests/phpunit/Unit/BootstrapComponentServiceTest.php rename to tests/phpunit/Unit/BootstrapComponentsServiceTest.php index 2c1d8e8..6c6beb4 100644 --- a/tests/phpunit/Unit/BootstrapComponentServiceTest.php +++ b/tests/phpunit/Unit/BootstrapComponentsServiceTest.php @@ -70,7 +70,6 @@ public function testPrivateCanDetectSkinInUse() { $reflection = new ReflectionClass( BootstrapComponentsService::class ); $method = $reflection->getMethod( 'detectSkinInUse' ); - $method->setAccessible( true ); // this is default $this->assertEquals( diff --git a/tests/phpunit/Unit/CarouselGalleryTest.php b/tests/phpunit/Unit/CarouselGalleryTest.php index be566f6..85c6b41 100644 --- a/tests/phpunit/Unit/CarouselGalleryTest.php +++ b/tests/phpunit/Unit/CarouselGalleryTest.php @@ -53,7 +53,9 @@ public function testToHtml( $imageList, $additionalAttributes, $expectedOutput ) ->getMock(); $instance->mParser->expects( $this->any() ) ->method( 'recursiveTagParse' ) - ->will( $this->returnArgument( 0 ) ); + ->will( $this->returnCallback( function ( $text ) { + return (string)$text; + } ) ); foreach ( $imageList as $imageData ) { $instance->add( Title::newFromText( $imageData[0] ), $imageData[1], $imageData[2], $imageData[3], $imageData[4] ); diff --git a/tests/phpunit/Unit/ComponentsTestBase.php b/tests/phpunit/Unit/ComponentsTestBase.php index c7ef2ab..14357e4 100644 --- a/tests/phpunit/Unit/ComponentsTestBase.php +++ b/tests/phpunit/Unit/ComponentsTestBase.php @@ -61,10 +61,14 @@ public function setUp(): void { $this->parser = $this->createMock( Parser::class ); $this->parser->expects( $this->any() ) ->method( 'recursiveTagParse' ) - ->will( $this->returnArgument( 0 ) ); + ->will( $this->returnCallback( function ( $text ) { + return (string)$text; + } ) ); $this->parser->expects( $this->any() ) ->method( 'recursiveTagParseFully' ) - ->will( $this->returnArgument( 0 ) ); + ->will( $this->returnCallback( function ( $text ) { + return (string)$text; + } ) ); $this->parserOutputHelper = $this->createMock( ParserOutputHelper::class ); $this->parserOutputHelper->expects( $this->any() ) ->method( 'renderErrorMessage' ) diff --git a/tests/phpunit/Unit/LuaLibraryTestBase.php b/tests/phpunit/Unit/LuaLibraryTestBase.php index 971548b..d66139a 100644 --- a/tests/phpunit/Unit/LuaLibraryTestBase.php +++ b/tests/phpunit/Unit/LuaLibraryTestBase.php @@ -3,7 +3,7 @@ namespace MediaWiki\Extension\BootstrapComponents\Tests\Unit; use MediaWiki\Extension\BootstrapComponents\LuaLibrary; -use \Scribunto_LuaEngineTestBase; +use MediaWiki\Extension\Scribunto\Tests\Engines\LuaCommon\LuaEngineTestBase; /** * @ingroup Test @@ -15,13 +15,17 @@ * @since 1.1 * @author Tobias Oetterer */ -abstract class LuaLibraryTestBase extends Scribunto_LuaEngineTestBase +abstract class LuaLibraryTestBase extends LuaEngineTestBase { /** * @var LuaLibrary */ private $luaLibrary; + protected function getEngineName(): string { + return 'LuaStandalone'; + } + /** * @throws \MWException */ diff --git a/tests/phpunit/Unit/ParserOutputHelperTest.php b/tests/phpunit/Unit/ParserOutputHelperTest.php index 5fda1a2..0f5df01 100644 --- a/tests/phpunit/Unit/ParserOutputHelperTest.php +++ b/tests/phpunit/Unit/ParserOutputHelperTest.php @@ -59,7 +59,7 @@ public function testCanAddErrorTrackingCategory() { $parser = $this->createMock( 'Parser' ); $parser->expects( $this->once() ) ->method( 'getOutput' ) - ->willReturn( false ); + ->willReturn( new ParserOutput( 'ParserOutputMockText' ) ); $instance = new ParserOutputHelper( $parser ); @@ -71,7 +71,7 @@ public function testCanAddTrackingCategory() { $parser = $this->createMock( 'Parser' ); $parser->expects( $this->once() ) ->method( 'getOutput' ) - ->willReturn( false ); + ->willReturn( new ParserOutput( 'ParserOutputMockText' ) ); $instance = new ParserOutputHelper( $parser ); diff --git a/tests/phpunit/Unit/ServiceWiringTest.php b/tests/phpunit/Unit/ServiceWiringTest.php index 0a0675f..f812c9f 100644 --- a/tests/phpunit/Unit/ServiceWiringTest.php +++ b/tests/phpunit/Unit/ServiceWiringTest.php @@ -22,6 +22,9 @@ class ServiceWiringTest extends TestCase { + /** + * @covers \MediaWiki\Extension\BootstrapComponents\BootstrapComponentsService + */ public function testCanConstructBootstrapComponentsService() { $this->assertInstanceOf( BootstrapComponentsService::class, @@ -29,6 +32,9 @@ public function testCanConstructBootstrapComponentsService() { ); } + /** + * @covers \MediaWiki\Extension\BootstrapComponents\ComponentLibrary + */ public function testCanConstructComponentLibrary() { $this->assertInstanceOf( ComponentLibrary::class, @@ -36,6 +42,9 @@ public function testCanConstructComponentLibrary() { ); } + /** + * @covers \MediaWiki\Extension\BootstrapComponents\NestingController + */ public function testCanConstructNestingController() { $this->assertInstanceOf( NestingController::class,