mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-23 13:46:48 +00:00
Adjust code coverage
-Exclude methods and classes that cannot be meaningfully covered -Add a simple test for AbuseFilterServices -Exclude ServiceWiring because there's no way to tell PHPUnit it's covered Change-Id: I4c67b0d3fea68c7a3b3cbe01b5608f87e1b492db
This commit is contained in:
parent
eab1f13696
commit
3f7fff56e8
|
@ -4,6 +4,9 @@ namespace MediaWiki\Extension\AbuseFilter\Filter;
|
|||
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class FilterNotFoundException extends RuntimeException {
|
||||
/**
|
||||
* @param int $filter
|
||||
|
|
|
@ -4,6 +4,9 @@ namespace MediaWiki\Extension\AbuseFilter\Filter;
|
|||
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class FilterVersionNotFoundException extends RuntimeException {
|
||||
/**
|
||||
* @param int $version
|
||||
|
|
|
@ -225,6 +225,7 @@ class FilterProfiler {
|
|||
* @param int $totalFilters
|
||||
* @param int $totalConditions
|
||||
* @param float $runtime
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function recordRuntimeProfilingResult( int $totalFilters, int $totalConditions, float $runtime ) : void {
|
||||
$keyPrefix = 'abusefilter.runtime-profile.' . $this->localWikiID . '.';
|
||||
|
|
|
@ -4,6 +4,9 @@ namespace MediaWiki\Extension\AbuseFilter;
|
|||
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class InvalidImportDataException extends InvalidArgumentException {
|
||||
/**
|
||||
* @param string $data That is not valid
|
||||
|
|
|
@ -19,6 +19,10 @@ use MediaWiki\Extension\AbuseFilter\Parser\ParserFactory;
|
|||
use MediaWiki\Logger\LoggerFactory;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
// This file is actually covered by AbuseFilterServicesTest, but it's not possible to specify a path
|
||||
// in @covers annotations (https://github.com/sebastianbergmann/phpunit/issues/3794)
|
||||
// @codeCoverageIgnoreStart
|
||||
|
||||
return [
|
||||
KeywordsManager::SERVICE_NAME => function ( MediaWikiServices $services ): KeywordsManager {
|
||||
return new KeywordsManager(
|
||||
|
@ -125,3 +129,5 @@ return [
|
|||
);
|
||||
},
|
||||
];
|
||||
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
|
33
tests/phpunit/AbuseFilterServicesTest.php
Normal file
33
tests/phpunit/AbuseFilterServicesTest.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
use MediaWiki\Extension\AbuseFilter\AbuseFilterServices;
|
||||
|
||||
/**
|
||||
* @group Test
|
||||
* @group AbuseFilter
|
||||
*/
|
||||
class AbuseFilterServicesTest extends MediaWikiIntegrationTestCase {
|
||||
/**
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\AbuseFilterServices
|
||||
* @param string $getter
|
||||
* @dataProvider provideGetters
|
||||
*/
|
||||
public function testServiceGetters( string $getter ) {
|
||||
// Methods are typehinted, so no need to assert
|
||||
AbuseFilterServices::$getter();
|
||||
$this->addToAssertionCount( 1 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideGetters() : Generator {
|
||||
$clazz = new ReflectionClass( AbuseFilterServices::class );
|
||||
foreach ( $clazz->getMethods( ReflectionMethod::IS_PUBLIC ) as $method ) {
|
||||
$name = $method->getName();
|
||||
if ( strpos( $name, 'get' ) === 0 ) {
|
||||
yield $name => [ $name ];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue