mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-24 14:13:54 +00:00
Merge "Adjust code coverage"
This commit is contained in:
commit
a16cca0ecb
|
@ -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