mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-12 01:16:19 +00:00
Test ServiceWiring.php
Test ServiceWiring.php using tests copied from CentralAuth. Because phpunit does not support marking a file as covered, the ServiceWiring file is ignored for code coverage as the tests fully cover the file. Change-Id: I7da8d74fec84a5aa9c77bc0678ad8f55b550893a
This commit is contained in:
parent
cfdeadfdb8
commit
68ae9555f1
|
@ -4,6 +4,11 @@ namespace MediaWiki\Extension\DiscussionTools;
|
|||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
// PHP unit does not understand code coverage for this file
|
||||
// as the @covers annotation cannot cover a specific file
|
||||
// This is fully tested in ServiceWiringTest.php
|
||||
// @codeCoverageIgnoreStart
|
||||
|
||||
return [
|
||||
'DiscussionTools.CommentParser' => static function ( MediaWikiServices $services ): CommentParser {
|
||||
return new CommentParser(
|
||||
|
@ -48,3 +53,5 @@ return [
|
|||
);
|
||||
},
|
||||
];
|
||||
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
|
33
tests/phpunit/ServiceWiringTest.php
Normal file
33
tests/phpunit/ServiceWiringTest.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Copy of CentralAuth's CentralAuthServiceWiringTest.php
|
||||
* used to test the ServiceWiring.php file.
|
||||
*/
|
||||
|
||||
namespace MediaWiki\Extension\DiscussionTools\Tests;
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
/**
|
||||
* Tests ServiceWiring.php
|
||||
*
|
||||
* @coversNothing PHPUnit does not support covering annotations for files
|
||||
* @group DiscussionTools
|
||||
*/
|
||||
class ServiceWiringTest extends IntegrationTestCase {
|
||||
/**
|
||||
* @dataProvider provideService
|
||||
*/
|
||||
public function testService( string $name ) {
|
||||
MediaWikiServices::getInstance()->get( $name );
|
||||
$this->addToAssertionCount( 1 );
|
||||
}
|
||||
|
||||
public function provideService() {
|
||||
$wiring = require __DIR__ . '/../../includes/ServiceWiring.php';
|
||||
foreach ( $wiring as $name => $_ ) {
|
||||
yield $name => [ $name ];
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue