Skip to content

Commit 948c0a2

Browse files
committed
fix unit tests
1 parent f62caa1 commit 948c0a2

File tree

5 files changed

+37
-30
lines changed

5 files changed

+37
-30
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,34 @@ jobs:
1616
- mw: 'REL1_35'
1717
php: 7.4
1818
type: normal
19+
experimental: false
1920
- mw: 'REL1_37'
2021
php: 7.4
2122
type: normal
23+
experimental: false
2224
- mw: 'REL1_38'
2325
php: 7.4
2426
type: normal
27+
experimental: false
2528
- mw: 'REL1_39'
2629
php: 7.4
2730
type: coverage
31+
experimental: false
2832
- mw: 'REL1_39'
2933
php: 8.1
3034
type: normal
35+
experimental: false
3136
- mw: 'master'
3237
php: 7.4
3338
type: normal
39+
experimental: true
3440
- mw: 'master'
3541
php: 8.1
3642
type: normal
43+
experimental: true
3744

3845
runs-on: ubuntu-latest
46+
continue-on-error: ${{ matrix.experimental }}
3947

4048
defaults:
4149
run:

tests/autoloader.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
? getenv( 'MW_INSTALL_PATH' )
2020
: __DIR__ . '/../../..';
2121

22-
if ( is_readable( $path = __DIR__ . '/../vendor/autoload.php' ) ) {
23-
$autoloadType = "Extension vendor autoloader";
24-
} elseif ( is_readable( $path = $basePath . '/vendor/autoload.php' ) ) {
22+
if ( is_readable( $path = $basePath . '/vendor/autoload.php' ) ) {
2523
$autoloadType = "MediaWiki vendor autoloader";
24+
} elseif ( is_readable( $path = __DIR__ . '/../vendor/autoload.php' ) ) {
25+
$autoloadType = "Extension vendor autoloader";
2626
} else {
2727
die( 'To run the test suite it is required that packages are installed using Composer.' );
2828
}
@@ -36,11 +36,12 @@
3636
/**
3737
* getting the autoloader and registering test classes
3838
*/
39+
/** @var \Composer\Autoload\ClassLoader $autoloader */
3940
$autoloader = require $path;
4041

41-
$autoloader->addPsr4( 'BootstrapComponents\\Tests\\Unit\\', __DIR__ . '/phpunit/Unit' );
42-
$autoloader->addPsr4( 'BootstrapComponents\\Tests\\Integration\\',
43-
__DIR__ . '/phpunit/Integration' );
44-
42+
#$autoloader->addPsr4( 'BootstrapComponents\\Tests\\Unit\\', __DIR__ . '/phpunit/Unit' );
43+
#$autoloader->addPsr4( 'BootstrapComponents\\Tests\\Integration\\', __DIR__ . '/phpunit/Integration' );
44+
$autoloader->addPsr4( 'BootstrapComponents\\Tests\\', __DIR__ . '/phpunit' );
45+
@include_once __DIR__ . '/phpunit/Unit/ComponentsTestBase.php';
4546

4647
return $autoloader;

tests/phpunit/Unit/HookRegistryTest.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -321,19 +321,20 @@ public function testHookOutputPageParserOutput() {
321321
$this->stringContains( 'bsc_deferredContent' )
322322
)
323323
->willReturnOnConsecutiveCalls( [], [ 'call2' ] );
324-
$parserOutput->expects( $this->exactly( 2 ) )
325-
->method( 'getText' )
326-
->will( $this->returnCallback( function() use ( &$content ) {
327-
return $content;
328-
} ) );
329-
$parserOutput->expects( $this->exactly( 2 ) )
330-
->method( 'setText' )
331-
->will( $this->returnCallback( function( $injection ) use ( &$content ) {
332-
$content = $injection;
333-
} ) );
334324
$outputPage = $this->getMockBuilder( 'OutputPage' )
335325
->disableOriginalConstructor()
336326
->getMock();
327+
$outputPage->expects( $this->once() )
328+
->method( 'addHTML' )
329+
->will( $this->returnCallback( function( $injection ) use ( &$content ) {
330+
$content .= $injection;
331+
} ) );
332+
$outputPage->expects( $this->exactly( 2 ) )
333+
->method( 'addModules' )
334+
->with(
335+
$this->equalTo( [ 'ext.bootstrapComponents.vector-fix' ] )
336+
);
337+
337338

338339
/** @noinspection PhpParamsInspection */
339340
$parserOutputHelper = new ParserOutputHelper( $parser );

tests/phpunit/Unit/Hooks/OutputPageParserOutputTest.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,20 @@ public function testHookOutputPageParserOutput() {
5151
$outputPage = $this->getMockBuilder( 'OutputPage' )
5252
->disableOriginalConstructor()
5353
->getMock();
54+
$outputPage->expects( $this->once() )
55+
->method( 'addHTML' )
56+
->will( $this->returnCallback( function( $injection ) use ( &$content ) {
57+
$content .= $injection;
58+
} ) );
59+
$outputPage->expects( $this->once() )
60+
->method( 'addModules' )
61+
->with(
62+
$this->equalTo( [ 'ext.bootstrapComponents.vector-fix' ] )
63+
);
5464

5565
$observerParserOutput = $this->getMockBuilder(ParserOutput::class )
5666
->disableOriginalConstructor()
57-
# ->setMethods( [ 'getText', 'setText', 'getExtensionData' ] )
5867
->getMock();
59-
$observerParserOutput->expects( $this->exactly( 1 ) )
60-
->method( 'getText' )
61-
->will( $this->returnCallback( function() use ( &$content ) {
62-
return $content;
63-
} ) );
64-
$observerParserOutput->expects( $this->exactly( 1 ) )
65-
->method( 'setText' )
66-
->will( $this->returnCallback( function( $injection ) use ( &$content ) {
67-
$content = $injection;
68-
} ) );
6968
$observerParserOutput->expects( $this->exactly( 1 ) )
7069
->method( 'getExtensionData' )
7170
->with(

tests/phpunit/Unit/ParserOutputHelperTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,6 @@ public function testCanLoadBootstrapModules() {
150150
$parserOutput->expects( $this->once() )
151151
->method( 'setExtensionData' )
152152
->with( $this->equalTo( 'bsc_load_modules' ), $this->equalTo( true ) );
153-
$parserOutput->expects( $this->once() )
154-
->method( 'addModules' );
155153
$parser = $this->getMockBuilder( 'Parser' )
156154
->disableOriginalConstructor()
157155
->getMock();

0 commit comments

Comments
 (0)