Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 35 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand Down Expand Up @@ -68,7 +73,7 @@ jobs:

- name: Cache MediaWiki
id: cache-mediawiki
uses: actions/cache@v4
uses: actions/cache@v5
with:
path: |
mediawiki
Expand All @@ -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

Expand All @@ -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

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ public function testPrivateCanDetectSkinInUse() {

$reflection = new ReflectionClass( BootstrapComponentsService::class );
$method = $reflection->getMethod( 'detectSkinInUse' );
$method->setAccessible( true );

// this is default
$this->assertEquals(
Expand Down
4 changes: 3 additions & 1 deletion tests/phpunit/Unit/CarouselGalleryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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] );
Expand Down
8 changes: 6 additions & 2 deletions tests/phpunit/Unit/ComponentsTestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' )
Expand Down
8 changes: 6 additions & 2 deletions tests/phpunit/Unit/LuaLibraryTestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
*/
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/Unit/ParserOutputHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand All @@ -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 );

Expand Down
9 changes: 9 additions & 0 deletions tests/phpunit/Unit/ServiceWiringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,29 @@
class ServiceWiringTest extends TestCase {


/**
* @covers \MediaWiki\Extension\BootstrapComponents\BootstrapComponentsService
*/
public function testCanConstructBootstrapComponentsService() {
$this->assertInstanceOf(
BootstrapComponentsService::class,
MediaWikiServices::getInstance()->getService('BootstrapComponentsService')
);
}

/**
* @covers \MediaWiki\Extension\BootstrapComponents\ComponentLibrary
*/
public function testCanConstructComponentLibrary() {
$this->assertInstanceOf(
ComponentLibrary::class,
MediaWikiServices::getInstance()->getService('BootstrapComponents.ComponentLibrary')
);
}

/**
* @covers \MediaWiki\Extension\BootstrapComponents\NestingController
*/
public function testCanConstructNestingController() {
$this->assertInstanceOf(
NestingController::class,
Expand Down
Loading