mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-23 13:46:48 +00:00
tests: Widen @covers
tags in phpunit tests
Follows-up I5a5420df13893386. > We lose useful coverage and waste valuable time on keeping tags > accurate through refactors (or worse, forget to do so). > > Tracking tiny per-method details wastes time in realizing (and > fixing) when people inevitably don't keep them in sync, and time > lost in finding uncovered code to write tests to realize it was > already covered but "not yet claimed". > > Given all used methods are de-facto and liberally claimed, and > that we keep the coverage limited to the subject class, this > maintains the spirit and intent. PHPUnit offers a more precise > tool when you need it (i.e. when testing legacy monster classes), > but for well-written code, the class-wide tag suffices. Ref https://gerrit.wikimedia.org/r/q/owner:Krinkle+is:merged+message:Widen Change-Id: If7304d8b5b43ab8a051fbcecced331a787bab960
This commit is contained in:
parent
d654cdf804
commit
4743f9d267
|
@ -47,9 +47,7 @@ use Wikimedia\Timestamp\ConvertibleTimestamp;
|
|||
*
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\FilterRunner
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Hooks\Handlers\FilteredActionsHandler
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\VariableGenerator\RunVariableGenerator::getDeleteVars
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\VariableGenerator\RunVariableGenerator::getMoveVars
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\VariableGenerator\RunVariableGenerator::getUploadVars
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\VariableGenerator\RunVariableGenerator
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\AbuseFilterPreAuthenticationProvider
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\ChangeTags\ChangeTagger
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\BlockAutopromoteStore
|
||||
|
|
|
@ -11,8 +11,7 @@ use MediaWiki\User\UserIdentityValue;
|
|||
|
||||
/**
|
||||
* @group Database
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Consequences\Consequence\Degroup
|
||||
* @covers ::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Consequences\Consequence\Degroup
|
||||
* @todo Make this a unit test once ManualLogEntry is servicified (T253717) and DI is possible for User::newSystemUser
|
||||
*/
|
||||
class DegroupTest extends MediaWikiIntegrationTestCase {
|
||||
|
@ -31,9 +30,6 @@ class DegroupTest extends MediaWikiIntegrationTestCase {
|
|||
return AbuseFilterServices::getFilterUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::execute
|
||||
*/
|
||||
public function testExecute() {
|
||||
$user = new UserIdentityValue( 1, 'Degrouped user' );
|
||||
$params = $this->provideGetMessageParameters( $user )->current()[0];
|
||||
|
@ -57,9 +53,6 @@ class DegroupTest extends MediaWikiIntegrationTestCase {
|
|||
$this->assertTrue( $degroup->execute() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::execute
|
||||
*/
|
||||
public function testExecute_noGroups() {
|
||||
$params = $this->provideGetMessageParameters()->current()[0];
|
||||
$userGroupManager = $this->createMock( UserGroupManager::class );
|
||||
|
@ -79,9 +72,6 @@ class DegroupTest extends MediaWikiIntegrationTestCase {
|
|||
$this->assertFalse( $degroup->execute() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::execute
|
||||
*/
|
||||
public function testExecute_variableNotSet() {
|
||||
$user = new UserIdentityValue( 1, 'Degrouped user' );
|
||||
$params = $this->provideGetMessageParameters( $user )->current()[0];
|
||||
|
@ -108,9 +98,6 @@ class DegroupTest extends MediaWikiIntegrationTestCase {
|
|||
$this->assertTrue( $degroup->execute() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::execute
|
||||
*/
|
||||
public function testExecute_anonymous() {
|
||||
$user = new UserIdentityValue( 0, 'Anonymous user' );
|
||||
$params = $this->provideGetMessageParameters( $user )->current()[0];
|
||||
|
@ -130,9 +117,6 @@ class DegroupTest extends MediaWikiIntegrationTestCase {
|
|||
$this->assertFalse( $degroup->execute() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::execute
|
||||
*/
|
||||
public function testExecute_temp() {
|
||||
$user = new UserIdentityValue( 10, '*12345' );
|
||||
$params = $this->provideGetMessageParameters( $user )->current()[0];
|
||||
|
@ -164,7 +148,6 @@ class DegroupTest extends MediaWikiIntegrationTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers ::revert
|
||||
* @dataProvider provideRevert
|
||||
*/
|
||||
public function testRevert( bool $success, array $hadGroups, array $hasGroups = [] ) {
|
||||
|
@ -197,7 +180,6 @@ class DegroupTest extends MediaWikiIntegrationTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers ::getMessage
|
||||
* @dataProvider provideGetMessageParameters
|
||||
*/
|
||||
public function testGetMessage( Parameters $params ) {
|
||||
|
|
|
@ -11,7 +11,7 @@ use MediaWiki\User\UserIdentityValue;
|
|||
* @group Test
|
||||
* @group AbuseFilter
|
||||
* @group Database
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Variables\LazyVariableComputer
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Variables\LazyVariableComputer
|
||||
* @todo Move to LazyVariableComputerTest
|
||||
*/
|
||||
class LazyVariableComputerDBTest extends MediaWikiIntegrationTestCase {
|
||||
|
@ -48,10 +48,6 @@ class LazyVariableComputerDBTest extends MediaWikiIntegrationTestCase {
|
|||
return $contributors;
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::compute
|
||||
* @covers ::getLastPageAuthors
|
||||
*/
|
||||
public function testRecentContributors() {
|
||||
$varName = "page_recent_contributors";
|
||||
$title = Title::makeTitle( NS_MAIN, "Page to test $varName" );
|
||||
|
|
|
@ -15,7 +15,7 @@ use MediaWiki\Utils\MWTimestamp;
|
|||
* @group AbuseFilter
|
||||
* @group AbuseFilterGeneric
|
||||
* @group Database
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\VariableGenerator\RCVariableGenerator
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\VariableGenerator\RCVariableGenerator
|
||||
* @todo Make this a unit test?
|
||||
*/
|
||||
class RCVariableGeneratorTest extends MediaWikiIntegrationTestCase {
|
||||
|
@ -206,10 +206,6 @@ class RCVariableGeneratorTest extends MediaWikiIntegrationTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers ::addEditVars
|
||||
* @covers ::addDerivedEditVars
|
||||
* @covers ::addEditVarsForRow
|
||||
* @covers ::addGenericVars
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Variables\LazyVariableComputer
|
||||
*/
|
||||
public function testAddEditVarsForRow() {
|
||||
|
|
|
@ -5,14 +5,11 @@ use MediaWiki\User\UserGroupManager;
|
|||
|
||||
/**
|
||||
* @group Database
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Hooks\Handlers\SchemaChangesHandler
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Hooks\Handlers\SchemaChangesHandler
|
||||
* @todo Make this a unit test once User::newSystemUser is moved to a service
|
||||
*/
|
||||
class SchemaChangesHandlerTest extends MediaWikiIntegrationTestCase {
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
*/
|
||||
public function testConstruct() {
|
||||
$this->assertInstanceOf(
|
||||
SchemaChangesHandler::class,
|
||||
|
@ -23,9 +20,6 @@ class SchemaChangesHandlerTest extends MediaWikiIntegrationTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::createAbuseFilterUser
|
||||
*/
|
||||
public function testCreateAbuseFilterUser_invalidUserName() {
|
||||
$noRowUpdater = $this->createMock( DatabaseUpdater::class );
|
||||
$noRowUpdater->method( 'updateRowExists' )->willReturn( false );
|
||||
|
@ -35,9 +29,6 @@ class SchemaChangesHandlerTest extends MediaWikiIntegrationTestCase {
|
|||
$this->assertFalse( $handler->createAbuseFilterUser( $noRowUpdater ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::createAbuseFilterUser
|
||||
*/
|
||||
public function testCreateAbuseFilterUser_alreadyCreated() {
|
||||
$rowExistsUpdater = $this->createMock( DatabaseUpdater::class );
|
||||
$rowExistsUpdater->method( 'updateRowExists' )->willReturn( true );
|
||||
|
@ -47,9 +38,6 @@ class SchemaChangesHandlerTest extends MediaWikiIntegrationTestCase {
|
|||
$this->assertFalse( $handler->createAbuseFilterUser( $rowExistsUpdater ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::createAbuseFilterUser
|
||||
*/
|
||||
public function testCreateAbuseFilterUser_success() {
|
||||
$noRowUpdater = $this->createMock( DatabaseUpdater::class );
|
||||
$noRowUpdater->method( 'updateRowExists' )->willReturn( false );
|
||||
|
|
|
@ -12,17 +12,13 @@ use MediaWiki\Extension\AbuseFilter\Parser\RuleCheckerStatus;
|
|||
use MediaWiki\Tests\Unit\Permissions\MockAuthorityTrait;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Api\CheckMatch
|
||||
* @covers ::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Api\CheckMatch
|
||||
* @group medium
|
||||
*/
|
||||
class CheckMatchTest extends ApiTestCase {
|
||||
use AbuseFilterApiTestTrait;
|
||||
use MockAuthorityTrait;
|
||||
|
||||
/**
|
||||
* @covers ::execute
|
||||
*/
|
||||
public function testExecute_noPermissions() {
|
||||
$this->expectApiErrorCode( 'permissiondenied' );
|
||||
|
||||
|
@ -44,7 +40,6 @@ class CheckMatchTest extends ApiTestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider provideExecuteOk
|
||||
* @covers ::execute
|
||||
*/
|
||||
public function testExecute_Ok( bool $expected ) {
|
||||
$filter = 'sampleFilter';
|
||||
|
@ -77,9 +72,6 @@ class CheckMatchTest extends ApiTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::execute
|
||||
*/
|
||||
public function testExecute_error() {
|
||||
$this->expectApiErrorCode( 'badsyntax' );
|
||||
$filter = 'sampleFilter';
|
||||
|
|
|
@ -11,17 +11,13 @@ use MediaWiki\Extension\AbuseFilter\Parser\RuleCheckerFactory;
|
|||
use MediaWiki\Tests\Unit\Permissions\MockAuthorityTrait;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Api\CheckSyntax
|
||||
* @covers ::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Api\CheckSyntax
|
||||
* @group medium
|
||||
*/
|
||||
class CheckSyntaxTest extends ApiTestCase {
|
||||
use AbuseFilterApiTestTrait;
|
||||
use MockAuthorityTrait;
|
||||
|
||||
/**
|
||||
* @covers ::execute
|
||||
*/
|
||||
public function testExecute_noPermissions() {
|
||||
$this->expectApiErrorCode( 'permissiondenied' );
|
||||
|
||||
|
@ -33,9 +29,6 @@ class CheckSyntaxTest extends ApiTestCase {
|
|||
], null, null, $this->mockRegisteredNullAuthority() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::execute
|
||||
*/
|
||||
public function testExecute_Ok() {
|
||||
$input = 'sampleFilter';
|
||||
$status = new ParserStatus( null, [], 1 );
|
||||
|
@ -57,9 +50,6 @@ class CheckSyntaxTest extends ApiTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::execute
|
||||
*/
|
||||
public function testExecute_OkAndWarnings() {
|
||||
$input = 'sampleFilter';
|
||||
$warnings = [
|
||||
|
@ -99,9 +89,6 @@ class CheckSyntaxTest extends ApiTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::execute
|
||||
*/
|
||||
public function testExecute_error() {
|
||||
$input = 'sampleFilter';
|
||||
$exception = new UserVisibleException( 'error-id', 4, [] );
|
||||
|
|
|
@ -10,17 +10,13 @@ use MediaWiki\Extension\AbuseFilter\Parser\RuleCheckerFactory;
|
|||
use MediaWiki\Tests\Unit\Permissions\MockAuthorityTrait;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Api\EvalExpression
|
||||
* @covers ::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Api\EvalExpression
|
||||
* @group medium
|
||||
*/
|
||||
class EvalExpressionTest extends ApiTestCase {
|
||||
use AbuseFilterApiTestTrait;
|
||||
use MockAuthorityTrait;
|
||||
|
||||
/**
|
||||
* @covers ::execute
|
||||
*/
|
||||
public function testExecute_noPermissions() {
|
||||
$this->expectApiErrorCode( 'permissiondenied' );
|
||||
|
||||
|
@ -32,10 +28,6 @@ class EvalExpressionTest extends ApiTestCase {
|
|||
], null, null, $this->mockRegisteredNullAuthority() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::execute
|
||||
* @covers ::evaluateExpression
|
||||
*/
|
||||
public function testExecute_error() {
|
||||
$this->expectApiErrorCode( 'abusefilter-tools-syntax-error' );
|
||||
$expression = 'sampleExpression';
|
||||
|
@ -51,10 +43,6 @@ class EvalExpressionTest extends ApiTestCase {
|
|||
] );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::execute
|
||||
* @covers ::evaluateExpression
|
||||
*/
|
||||
public function testExecute_Ok() {
|
||||
$expression = 'sampleExpression';
|
||||
$status = new ParserStatus( null, [], 1 );
|
||||
|
@ -83,10 +71,6 @@ class EvalExpressionTest extends ApiTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::execute
|
||||
* @covers ::evaluateExpression
|
||||
*/
|
||||
public function testExecute_OkAndPrettyPrint() {
|
||||
$expression = 'sampleExpression';
|
||||
$status = new ParserStatus( null, [], 1 );
|
||||
|
|
|
@ -5,16 +5,13 @@ namespace MediaWiki\Extension\AbuseFilter\Tests\Integration\Api;
|
|||
use ApiTestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Api\QueryAbuseLog
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Api\QueryAbuseLog
|
||||
* @group medium
|
||||
* @group Database
|
||||
* @todo Extend this
|
||||
*/
|
||||
class QueryAbuseLogTest extends ApiTestCase {
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
*/
|
||||
public function testConstruct() {
|
||||
$this->doApiRequest( [
|
||||
'action' => 'query',
|
||||
|
|
|
@ -10,17 +10,13 @@ use MediaWiki\Tests\Unit\Permissions\MockAuthorityTrait;
|
|||
use MediaWiki\User\UserIdentityValue;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Api\UnblockAutopromote
|
||||
* @covers ::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Api\UnblockAutopromote
|
||||
* @group medium
|
||||
* @group Database
|
||||
*/
|
||||
class UnblockAutopromoteTest extends ApiTestCase {
|
||||
use MockAuthorityTrait;
|
||||
|
||||
/**
|
||||
* @covers ::execute
|
||||
*/
|
||||
public function testExecute_noPermissions() {
|
||||
$this->expectApiErrorCode( 'permissiondenied' );
|
||||
|
||||
|
@ -34,9 +30,6 @@ class UnblockAutopromoteTest extends ApiTestCase {
|
|||
], null, $this->mockRegisteredAuthorityWithoutPermissions( [ 'abusefilter-modify' ] ), 'csrf' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::execute
|
||||
*/
|
||||
public function testExecute_invalidUser() {
|
||||
$invalid = 'invalid#username';
|
||||
$this->expectApiErrorCode( 'baduser' );
|
||||
|
@ -51,9 +44,6 @@ class UnblockAutopromoteTest extends ApiTestCase {
|
|||
], null, $this->mockRegisteredNullAuthority(), 'csrf' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::execute
|
||||
*/
|
||||
public function testExecute_blocked() {
|
||||
$this->expectApiErrorCode( 'blocked' );
|
||||
|
||||
|
@ -77,9 +67,6 @@ class UnblockAutopromoteTest extends ApiTestCase {
|
|||
], null, $blockedUser, 'csrf' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::execute
|
||||
*/
|
||||
public function testExecute_nothingToDo() {
|
||||
$target = 'User';
|
||||
$user = $this->mockRegisteredUltimateAuthority();
|
||||
|
@ -97,9 +84,6 @@ class UnblockAutopromoteTest extends ApiTestCase {
|
|||
], null, $user, 'csrf' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::execute
|
||||
*/
|
||||
public function testExecute_success() {
|
||||
$target = 'User';
|
||||
$user = $this->mockRegisteredUltimateAuthority();
|
||||
|
|
|
@ -17,7 +17,7 @@ class ChangeTagValidatorTest extends MediaWikiIntegrationTestCase {
|
|||
* @todo When the above is possible, use mocks to test canAddTagsAccompanyingChange and canCreateTag
|
||||
* @param string $tag The tag to validate
|
||||
* @param string|null $expectedError
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\ChangeTags\ChangeTagValidator::validateTag
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\ChangeTags\ChangeTagValidator
|
||||
* @dataProvider provideTags
|
||||
*/
|
||||
public function testValidateTag( string $tag, ?string $expectedError ) {
|
||||
|
|
|
@ -12,7 +12,7 @@ use MediaWikiIntegrationTestCase;
|
|||
|
||||
/**
|
||||
* @group Database
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\EchoNotifier
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\EchoNotifier
|
||||
*/
|
||||
class EchoNotifierTest extends MediaWikiIntegrationTestCase {
|
||||
|
||||
|
@ -44,10 +44,6 @@ class EchoNotifierTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider provideDataForEvent
|
||||
* @covers ::__construct
|
||||
* @covers ::getDataForEvent
|
||||
* @covers ::getFilterObject
|
||||
* @covers ::getTitleForFilter
|
||||
*/
|
||||
public function testGetDataForEvent( bool $loaded, int $filter, int $userID ) {
|
||||
$expectedThrottledActions = [];
|
||||
|
@ -70,9 +66,6 @@ class EchoNotifierTest extends MediaWikiIntegrationTestCase {
|
|||
$this->assertSame( [ 'user' => $userID, 'throttled-actions' => $expectedThrottledActions ], $extra );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::notifyForFilter
|
||||
*/
|
||||
public function testNotifyForFilter() {
|
||||
$this->markTestSkippedIfExtensionNotLoaded( 'Echo' );
|
||||
// Use a real user, or Echo will throw an exception.
|
||||
|
@ -85,9 +78,6 @@ class EchoNotifierTest extends MediaWikiIntegrationTestCase {
|
|||
$this->assertInstanceOf( Event::class, $notifier->notifyForFilter( 1 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::notifyForFilter
|
||||
*/
|
||||
public function testNotifyForFilter_EchoNotLoaded() {
|
||||
$lookup = $this->createMock( FilterLookup::class );
|
||||
$lookup->expects( $this->never() )->method( $this->anything() );
|
||||
|
|
|
@ -26,8 +26,7 @@ use Psr\Log\NullLogger;
|
|||
/**
|
||||
* @group Test
|
||||
* @group AbuseFilter
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\FilterRunner
|
||||
* @covers ::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\FilterRunner
|
||||
*/
|
||||
class FilterRunnerTest extends MediaWikiIntegrationTestCase {
|
||||
/**
|
||||
|
@ -82,9 +81,6 @@ class FilterRunnerTest extends MediaWikiIntegrationTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
*/
|
||||
public function testConstructor_invalidGroup() {
|
||||
$invalidGroup = 'invalid-group';
|
||||
$this->expectException( InvalidArgumentException::class );
|
||||
|
@ -92,19 +88,12 @@ class FilterRunnerTest extends MediaWikiIntegrationTestCase {
|
|||
$this->getRunner( null, null, new VariableHolder(), $invalidGroup );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
*/
|
||||
public function testConstructor_noAction() {
|
||||
$this->expectException( InvalidArgumentException::class );
|
||||
$this->expectExceptionMessage( 'variable is not set' );
|
||||
$this->getRunner( null, null, new VariableHolder() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::run
|
||||
* @covers ::checkAllFilters
|
||||
*/
|
||||
public function testConditionsLimit() {
|
||||
$cache = $this->createMock( EditStashCache::class );
|
||||
$cache->method( 'seek' )->willReturn( [
|
||||
|
|
|
@ -13,15 +13,13 @@ use MediaWikiIntegrationTestCase;
|
|||
* @group Test
|
||||
* @group AbuseFilter
|
||||
* @group Database
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\FilterValidator
|
||||
* @covers ::__construct()
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\FilterValidator
|
||||
*/
|
||||
class FilterValidatorTest extends MediaWikiIntegrationTestCase {
|
||||
/**
|
||||
* @todo Make this a unit test once static methods in ChangeTags are moved to a service
|
||||
* @param string[] $tags
|
||||
* @param string|null $expected
|
||||
* @covers ::checkAllTags
|
||||
* @dataProvider provideAllTags
|
||||
*/
|
||||
public function testCheckAllTags( array $tags, ?string $expected ) {
|
||||
|
|
|
@ -22,7 +22,7 @@ use NullStatsdDataFactory;
|
|||
use RequestContext;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Hooks\Handlers\FilteredActionsHandler
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Hooks\Handlers\FilteredActionsHandler
|
||||
* @group Database
|
||||
*/
|
||||
class FilteredActionsHandlerTest extends \MediaWikiIntegrationTestCase {
|
||||
|
@ -31,7 +31,6 @@ class FilteredActionsHandlerTest extends \MediaWikiIntegrationTestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider provideOnEditFilterMergedContent
|
||||
* @covers ::onEditFilterMergedContent
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\BlockedDomainFilter
|
||||
*/
|
||||
public function testOnEditFilterMergedContent( $urlsAdded, $expected ) {
|
||||
|
|
|
@ -9,8 +9,7 @@ use MediaWiki\User\UserIdentityValue;
|
|||
use MediaWikiIntegrationTestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Hooks\Handlers\CheckUserHandler
|
||||
* @covers ::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Hooks\Handlers\CheckUserHandler
|
||||
*/
|
||||
class CheckUserHandlerTest extends MediaWikiIntegrationTestCase {
|
||||
|
||||
|
@ -69,7 +68,6 @@ class CheckUserHandlerTest extends MediaWikiIntegrationTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers ::onCheckUserInsertChangesRow
|
||||
* @dataProvider provideDataForCheckUserInsertHooks
|
||||
*/
|
||||
public function testOnCheckUserInsertChangesRow( $user, $shouldChange ) {
|
||||
|
@ -82,7 +80,6 @@ class CheckUserHandlerTest extends MediaWikiIntegrationTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers ::onCheckUserInsertPrivateEventRow
|
||||
* @dataProvider provideDataForCheckUserInsertHooks
|
||||
*/
|
||||
public function testOnCheckUserInsertPrivateEventRow( $user, $shouldChange ) {
|
||||
|
@ -95,7 +92,6 @@ class CheckUserHandlerTest extends MediaWikiIntegrationTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers ::onCheckUserInsertLogEventRow
|
||||
* @dataProvider provideDataForCheckUserInsertHooks
|
||||
*/
|
||||
public function testOnCheckUserInsertLogEventRow( $user, $shouldChange ) {
|
||||
|
|
|
@ -17,24 +17,22 @@ use MediaWiki\MediaWikiServices;
|
|||
use SpecialPageTestBase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Special\SpecialAbuseFilter
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Special\SpecialAbuseFilter
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Special\AbuseFilterSpecialPage
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\View\AbuseFilterView
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\View\AbuseFilterViewDiff
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\View\AbuseFilterViewEdit
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\View\AbuseFilterViewExamine
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\View\AbuseFilterViewHistory
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\View\AbuseFilterViewImport
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\View\AbuseFilterViewList
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\View\AbuseFilterViewRevert
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\View\AbuseFilterViewTestBatch
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\View\AbuseFilterViewTools
|
||||
*/
|
||||
class SpecialAbuseFilterTest extends SpecialPageTestBase {
|
||||
|
||||
/**
|
||||
* @covers ::instantiateView
|
||||
* @covers ::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Special\AbuseFilterSpecialPage::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\View\AbuseFilterView::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\View\AbuseFilterViewDiff::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\View\AbuseFilterViewEdit::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\View\AbuseFilterViewExamine::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\View\AbuseFilterViewHistory::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\View\AbuseFilterViewImport::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\View\AbuseFilterViewList::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\View\AbuseFilterViewRevert::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\View\AbuseFilterViewTestBatch::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\View\AbuseFilterViewTools::__construct
|
||||
* @dataProvider provideInstantiateView
|
||||
*/
|
||||
public function testInstantiateView( string $viewClass, array $params = [] ) {
|
||||
|
|
|
@ -15,7 +15,7 @@ use MediaWikiIntegrationTestCase;
|
|||
use stdClass;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Special\SpecialAbuseLog
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Special\SpecialAbuseLog
|
||||
*/
|
||||
class SpecialAbuseLogTest extends MediaWikiIntegrationTestCase {
|
||||
/**
|
||||
|
@ -25,7 +25,6 @@ class SpecialAbuseLogTest extends MediaWikiIntegrationTestCase {
|
|||
* @param bool $canSeeSuppressed
|
||||
* @param string $expected
|
||||
* @dataProvider provideEntryAndVisibility
|
||||
* @covers ::getEntryVisibilityForUser
|
||||
*/
|
||||
public function testGetEntryVisibilityForUser(
|
||||
stdClass $row,
|
||||
|
|
|
@ -10,15 +10,10 @@ use Wikimedia\Rdbms\IDatabase;
|
|||
use Wikimedia\Rdbms\LBFactory;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Watcher\UpdateHitCountWatcher
|
||||
* @covers ::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Watcher\UpdateHitCountWatcher
|
||||
*/
|
||||
class UpdateHitCountWatcherTest extends MediaWikiIntegrationTestCase {
|
||||
|
||||
/**
|
||||
* @covers ::run
|
||||
* @covers ::updateHitCounts
|
||||
*/
|
||||
public function testRun() {
|
||||
$localFilters = [ 1, 2, 3 ];
|
||||
$globalFilters = [ 4, 5, 6 ];
|
||||
|
|
|
@ -11,7 +11,7 @@ use MediaWiki\Tests\Unit\Permissions\MockAuthorityTrait;
|
|||
use MediaWikiUnitTestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\AbuseFilterPermissionManager
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\AbuseFilterPermissionManager
|
||||
*/
|
||||
class AbuseFilterPermissionManagerTest extends MediaWikiUnitTestCase {
|
||||
use MockAuthorityTrait;
|
||||
|
@ -39,7 +39,6 @@ class AbuseFilterPermissionManagerTest extends MediaWikiUnitTestCase {
|
|||
* @param ?DatabaseBlock $block
|
||||
* @param array $rights
|
||||
* @param bool $expected
|
||||
* @covers ::canEdit
|
||||
* @dataProvider provideCanEdit
|
||||
*/
|
||||
public function testCanEdit( ?DatabaseBlock $block, array $rights, bool $expected ) {
|
||||
|
@ -64,7 +63,6 @@ class AbuseFilterPermissionManagerTest extends MediaWikiUnitTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers ::canEditGlobal
|
||||
* @dataProvider provideCanEditGlobal
|
||||
*/
|
||||
public function testCanEditGlobal( array $rights, bool $expected ) {
|
||||
|
@ -103,7 +101,6 @@ class AbuseFilterPermissionManagerTest extends MediaWikiUnitTestCase {
|
|||
* @param ?DatabaseBlock $block
|
||||
* @param array $rights
|
||||
* @param bool $expected
|
||||
* @covers ::canEditFilter
|
||||
* @dataProvider provideCanEditFilter
|
||||
*/
|
||||
public function testCanEditFilter(
|
||||
|
@ -135,7 +132,6 @@ class AbuseFilterPermissionManagerTest extends MediaWikiUnitTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers ::canViewPrivateFilters
|
||||
* @dataProvider provideCanViewPrivateFilters
|
||||
*/
|
||||
public function testCanViewPrivateFilters( array $rights, bool $expected ) {
|
||||
|
@ -156,7 +152,6 @@ class AbuseFilterPermissionManagerTest extends MediaWikiUnitTestCase {
|
|||
/**
|
||||
* @param array $rights
|
||||
* @param bool $expected
|
||||
* @covers ::canViewPrivateFiltersLogs
|
||||
* @dataProvider provideCanViewPrivateFiltersLogs
|
||||
*/
|
||||
public function testCanViewPrivateFiltersLogs( array $rights, bool $expected ) {
|
||||
|
@ -182,7 +177,6 @@ class AbuseFilterPermissionManagerTest extends MediaWikiUnitTestCase {
|
|||
* @param bool $filterHidden
|
||||
* @param array $rights
|
||||
* @param bool $expected
|
||||
* @covers ::canSeeLogDetailsForFilter
|
||||
* @dataProvider provideCanSeeLogDetailsForFilter
|
||||
*/
|
||||
public function testCanSeeLogDetailsForFilter( bool $filterHidden, array $rights, bool $expected ) {
|
||||
|
@ -201,7 +195,6 @@ class AbuseFilterPermissionManagerTest extends MediaWikiUnitTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers ::canEditFilterWithRestrictedActions
|
||||
* @dataProvider provideSimpleCases
|
||||
*/
|
||||
public function testCanEditFilterWithRestrictedActions( bool $allowed ) {
|
||||
|
@ -214,7 +207,6 @@ class AbuseFilterPermissionManagerTest extends MediaWikiUnitTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers ::canViewAbuseLog
|
||||
* @dataProvider provideSimpleCases
|
||||
*/
|
||||
public function testCanViewAbuseLog( bool $allowed ) {
|
||||
|
@ -227,7 +219,6 @@ class AbuseFilterPermissionManagerTest extends MediaWikiUnitTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers ::canHideAbuseLog
|
||||
* @dataProvider provideSimpleCases
|
||||
*/
|
||||
public function testCanHideAbuseLog( bool $allowed ) {
|
||||
|
@ -240,7 +231,6 @@ class AbuseFilterPermissionManagerTest extends MediaWikiUnitTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers ::canRevertFilterActions
|
||||
* @dataProvider provideSimpleCases
|
||||
*/
|
||||
public function testCanRevertFilterActions( bool $allowed ) {
|
||||
|
@ -253,7 +243,6 @@ class AbuseFilterPermissionManagerTest extends MediaWikiUnitTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers ::canSeeLogDetails
|
||||
* @dataProvider provideSimpleCases
|
||||
*/
|
||||
public function testCanSeeLogDetails( bool $allowed ) {
|
||||
|
@ -266,7 +255,6 @@ class AbuseFilterPermissionManagerTest extends MediaWikiUnitTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers ::canSeePrivateDetails
|
||||
* @dataProvider provideSimpleCases
|
||||
*/
|
||||
public function testCanSeePrivateDetails( bool $allowed ) {
|
||||
|
@ -279,7 +267,6 @@ class AbuseFilterPermissionManagerTest extends MediaWikiUnitTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers ::canSeeHiddenLogEntries
|
||||
* @dataProvider provideSimpleCases
|
||||
*/
|
||||
public function testCanSeeHiddenLogEntries( bool $allowed ) {
|
||||
|
@ -292,7 +279,6 @@ class AbuseFilterPermissionManagerTest extends MediaWikiUnitTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers ::canUseTestTools
|
||||
* @dataProvider provideSimpleCases
|
||||
*/
|
||||
public function testCanUseTestTools( bool $allowed ) {
|
||||
|
|
|
@ -18,15 +18,11 @@ use MediaWikiUnitTestCase;
|
|||
use Wikimedia\Rdbms\LBFactory;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\AbuseLoggerFactory
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\AbuseLoggerFactory
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\AbuseLogger
|
||||
*/
|
||||
class AbuseLoggerFactoryTest extends MediaWikiUnitTestCase {
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::newLogger
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\AbuseLogger::__construct
|
||||
*/
|
||||
public function testNewLogger() {
|
||||
$factory = new AbuseLoggerFactory(
|
||||
$this->createMock( CentralDBManager::class ),
|
||||
|
|
|
@ -11,17 +11,9 @@ use MediaWiki\User\UserIdentityValue;
|
|||
use MediaWikiUnitTestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\ActionSpecifier
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\ActionSpecifier
|
||||
*/
|
||||
class ActionSpecifierTest extends MediaWikiUnitTestCase {
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getAction
|
||||
* @covers ::getTitle
|
||||
* @covers ::getUser
|
||||
* @covers ::getIP
|
||||
* @covers ::getAccountName
|
||||
*/
|
||||
public function testGetters() {
|
||||
$action = 'edit';
|
||||
$title = new TitleValue( NS_MAIN, 'Foobar' );
|
||||
|
@ -36,9 +28,6 @@ class ActionSpecifierTest extends MediaWikiUnitTestCase {
|
|||
$this->assertSame( $accountname, $spec->getAccountName(), 'accountname' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
*/
|
||||
public function testInvalidAccountName() {
|
||||
$this->expectException( InvalidArgumentException::class );
|
||||
new ActionSpecifier(
|
||||
|
|
|
@ -11,8 +11,7 @@ use MediaWikiUnitTestCase;
|
|||
use Psr\Log\NullLogger;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\BlockAutopromoteStore
|
||||
* @covers ::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\BlockAutopromoteStore
|
||||
*/
|
||||
class BlockAutopromoteStoreTest extends MediaWikiUnitTestCase {
|
||||
|
||||
|
@ -24,18 +23,12 @@ class BlockAutopromoteStoreTest extends MediaWikiUnitTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::blockAutoPromote
|
||||
*/
|
||||
public function testBlockAutopromote_success() {
|
||||
$store = $this->getStore( new HashBagOStuff() );
|
||||
$target = new UserIdentityValue( 1, 'Blocked user' );
|
||||
$this->assertTrue( $store->blockAutoPromote( $target, '', 1 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::blockAutoPromote
|
||||
*/
|
||||
public function testBlockAutopromote_cannotSet() {
|
||||
$cache = $this->createMock( BagOStuff::class );
|
||||
$cache->expects( $this->once() )->method( 'set' )->willReturn( false );
|
||||
|
@ -45,9 +38,6 @@ class BlockAutopromoteStoreTest extends MediaWikiUnitTestCase {
|
|||
$this->assertFalse( $store->blockAutoPromote( $target, '', 1 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::unblockAutoPromote
|
||||
*/
|
||||
public function testUnblockAutopromote_success() {
|
||||
$cache = $this->createMock( BagOStuff::class );
|
||||
$cache->expects( $this->once() )->method( 'changeTTL' )->willReturn( true );
|
||||
|
@ -57,21 +47,12 @@ class BlockAutopromoteStoreTest extends MediaWikiUnitTestCase {
|
|||
$this->assertTrue( $store->unblockAutoPromote( $target, $target, '' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::unblockAutoPromote
|
||||
*/
|
||||
public function testUnblockAutopromote_notBlocked() {
|
||||
$store = $this->getStore( new HashBagOStuff() );
|
||||
$target = new UserIdentityValue( 1, 'Blocked user' );
|
||||
$this->assertFalse( $store->unblockAutoPromote( $target, $target, '' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::blockAutoPromote
|
||||
* @covers ::getAutoPromoteBlockStatus
|
||||
* @covers ::unblockAutopromote
|
||||
* @covers ::getAutoPromoteBlockKey
|
||||
*/
|
||||
public function testRoundTrip() {
|
||||
$cache = new HashBagOStuff();
|
||||
$store = $this->getStore( $cache );
|
||||
|
|
|
@ -12,12 +12,9 @@ use Wikimedia\Rdbms\LBFactory;
|
|||
/**
|
||||
* @group Test
|
||||
* @group AbuseFilter
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\CentralDBManager
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\CentralDBManager
|
||||
*/
|
||||
class CentralDBManagerTest extends MediaWikiUnitTestCase {
|
||||
/**
|
||||
* @covers ::__construct
|
||||
*/
|
||||
public function testConstruct() {
|
||||
$this->assertInstanceOf(
|
||||
CentralDBManager::class,
|
||||
|
@ -29,9 +26,6 @@ class CentralDBManagerTest extends MediaWikiUnitTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getConnection
|
||||
*/
|
||||
public function testGetConnection() {
|
||||
$expected = $this->createMock( DBConnRef::class );
|
||||
$lb = $this->createMock( ILoadBalancer::class );
|
||||
|
@ -42,9 +36,6 @@ class CentralDBManagerTest extends MediaWikiUnitTestCase {
|
|||
$this->assertSame( $expected, $dbManager->getConnection( DB_REPLICA ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getConnection
|
||||
*/
|
||||
public function testGetConnection_invalid() {
|
||||
$lbFactory = $this->createMock( LBFactory::class );
|
||||
$dbManager = new CentralDBManager( $lbFactory, null, true );
|
||||
|
@ -52,9 +43,6 @@ class CentralDBManagerTest extends MediaWikiUnitTestCase {
|
|||
$dbManager->getConnection( DB_REPLICA );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getCentralDBName
|
||||
*/
|
||||
public function testGetCentralDBName() {
|
||||
$expected = 'foobar';
|
||||
$lbFactory = $this->createMock( LBFactory::class );
|
||||
|
@ -62,9 +50,6 @@ class CentralDBManagerTest extends MediaWikiUnitTestCase {
|
|||
$this->assertSame( $expected, $dbManager->getCentralDBName() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getCentralDBName
|
||||
*/
|
||||
public function testGetCentralDBName_invalid() {
|
||||
$lbFactory = $this->createMock( LBFactory::class );
|
||||
$dbManager = new CentralDBManager( $lbFactory, null, true );
|
||||
|
@ -74,7 +59,6 @@ class CentralDBManagerTest extends MediaWikiUnitTestCase {
|
|||
|
||||
/**
|
||||
* @param bool $value
|
||||
* @covers ::filterIsCentral
|
||||
* @dataProvider provideIsCentral
|
||||
*/
|
||||
public function testFilterIsCentral( bool $value ) {
|
||||
|
|
|
@ -14,7 +14,7 @@ use RecentChange;
|
|||
/**
|
||||
* @group Test
|
||||
* @group AbuseFilter
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\ChangeTags\ChangeTagger
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\ChangeTags\ChangeTagger
|
||||
*/
|
||||
class ChangeTaggerTest extends MediaWikiUnitTestCase {
|
||||
/**
|
||||
|
@ -93,7 +93,6 @@ class ChangeTaggerTest extends MediaWikiUnitTestCase {
|
|||
/**
|
||||
* @param ActionSpecifier $specifier
|
||||
* @param RecentChange $rc
|
||||
* @covers ::bufferTagsToSetByAction
|
||||
* @dataProvider getActionData
|
||||
*/
|
||||
public function testTagsToSetWillNotContainDuplicates( ActionSpecifier $specifier, RecentChange $rc ) {
|
||||
|
@ -109,7 +108,6 @@ class ChangeTaggerTest extends MediaWikiUnitTestCase {
|
|||
/**
|
||||
* @param ActionSpecifier $specifier
|
||||
* @param RecentChange $rc
|
||||
* @covers ::clearBuffer
|
||||
* @dataProvider getActionData
|
||||
*/
|
||||
public function testClearBuffer( ActionSpecifier $specifier, RecentChange $rc ) {
|
||||
|
@ -123,7 +121,6 @@ class ChangeTaggerTest extends MediaWikiUnitTestCase {
|
|||
/**
|
||||
* @param ActionSpecifier $specifier
|
||||
* @param RecentChange $rc
|
||||
* @covers ::addConditionsLimitTag
|
||||
* @dataProvider getActionData
|
||||
*/
|
||||
public function testAddConditionsLimitTag( ActionSpecifier $specifier, RecentChange $rc ) {
|
||||
|
@ -136,12 +133,6 @@ class ChangeTaggerTest extends MediaWikiUnitTestCase {
|
|||
/**
|
||||
* @param ActionSpecifier $specifier
|
||||
* @param RecentChange $rc
|
||||
* @covers ::addTags
|
||||
* @covers ::getTagsForRecentChange
|
||||
* @covers ::getIDFromRecentChange
|
||||
* @covers ::getActionID
|
||||
* @covers ::getTagsForID
|
||||
* @covers ::bufferTagsToSetByAction
|
||||
* @dataProvider getActionData
|
||||
*/
|
||||
public function testAddGetTags( ActionSpecifier $specifier, RecentChange $rc ) {
|
||||
|
@ -155,9 +146,6 @@ class ChangeTaggerTest extends MediaWikiUnitTestCase {
|
|||
/**
|
||||
* @param ActionSpecifier $specifier
|
||||
* @param RecentChange $rc
|
||||
* @covers ::addTags
|
||||
* @covers ::getActionID
|
||||
* @covers ::bufferTagsToSetByAction
|
||||
* @dataProvider getActionData
|
||||
*/
|
||||
public function testAddTags_multiple( ActionSpecifier $specifier, RecentChange $rc ) {
|
||||
|
@ -173,10 +161,6 @@ class ChangeTaggerTest extends MediaWikiUnitTestCase {
|
|||
/**
|
||||
* @param ActionSpecifier $specifier
|
||||
* @param RecentChange $rc
|
||||
* @covers ::getTagsForRecentChange
|
||||
* @covers ::getIDFromRecentChange
|
||||
* @covers ::getActionID
|
||||
* @covers ::getTagsForID
|
||||
* @dataProvider getActionData
|
||||
*/
|
||||
public function testGetTags_clear( ActionSpecifier $specifier, RecentChange $rc ) {
|
||||
|
|
|
@ -12,8 +12,7 @@ use MediaWikiUnitTestCase;
|
|||
use MessageLocalizer;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Consequences\Consequence\BlockAutopromote
|
||||
* @covers ::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Consequences\Consequence\BlockAutopromote
|
||||
*/
|
||||
class BlockAutopromoteTest extends MediaWikiUnitTestCase {
|
||||
use ConsequenceGetMessageTestTrait;
|
||||
|
@ -26,9 +25,6 @@ class BlockAutopromoteTest extends MediaWikiUnitTestCase {
|
|||
return $ml;
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::execute
|
||||
*/
|
||||
public function testExecute_anonymous() {
|
||||
$user = new UserIdentityValue( 0, 'Anonymous user' );
|
||||
$params = $this->provideGetMessageParameters( $user )->current()[0];
|
||||
|
@ -47,7 +43,6 @@ class BlockAutopromoteTest extends MediaWikiUnitTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers ::execute
|
||||
* @dataProvider provideExecute
|
||||
*/
|
||||
public function testExecute( bool $success ) {
|
||||
|
@ -79,7 +74,6 @@ class BlockAutopromoteTest extends MediaWikiUnitTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers ::revert
|
||||
* @dataProvider provideExecute
|
||||
*/
|
||||
public function testRevert( bool $success ) {
|
||||
|
@ -103,7 +97,6 @@ class BlockAutopromoteTest extends MediaWikiUnitTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers ::getMessage
|
||||
* @dataProvider provideGetMessageParameters
|
||||
*/
|
||||
public function testGetMessage( Parameters $params ) {
|
||||
|
|
|
@ -18,7 +18,7 @@ use MessageLocalizer;
|
|||
use Psr\Log\NullLogger;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Consequences\Consequence\Block
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Consequences\Consequence\Block
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Consequences\Consequence\BlockingConsequence
|
||||
*/
|
||||
class BlockTest extends MediaWikiUnitTestCase {
|
||||
|
@ -59,8 +59,6 @@ class BlockTest extends MediaWikiUnitTestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider provideExecute
|
||||
* @covers ::__construct
|
||||
* @covers ::execute
|
||||
*/
|
||||
public function testExecute( UserIdentity $target, bool $result ) {
|
||||
$expiry = '1 day';
|
||||
|
@ -95,7 +93,6 @@ class BlockTest extends MediaWikiUnitTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers ::getMessage
|
||||
* @dataProvider provideGetMessageParameters
|
||||
*/
|
||||
public function testGetMessage( Parameters $params ) {
|
||||
|
@ -112,9 +109,6 @@ class BlockTest extends MediaWikiUnitTestCase {
|
|||
$this->doTestGetMessage( $block, $params, 'abusefilter-blocked-display' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::revert
|
||||
*/
|
||||
public function testRevert() {
|
||||
$params = $this->createMock( Parameters::class );
|
||||
$params->method( 'getUser' )->willReturn( new UserIdentityValue( 1, 'Foobar' ) );
|
||||
|
@ -141,9 +135,6 @@ class BlockTest extends MediaWikiUnitTestCase {
|
|||
$this->assertTrue( $block->revert( $this->createMock( UserIdentity::class ), '' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::revert
|
||||
*/
|
||||
public function testRevert_notBlocked() {
|
||||
$params = $this->createMock( Parameters::class );
|
||||
$params->method( 'getUser' )->willReturn( new UserIdentityValue( 1, 'Foobar' ) );
|
||||
|
@ -160,9 +151,6 @@ class BlockTest extends MediaWikiUnitTestCase {
|
|||
$this->assertFalse( $block->revert( $this->createMock( UserIdentity::class ), '' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::revert
|
||||
*/
|
||||
public function testRevert_notBlockedByAF() {
|
||||
$params = $this->createMock( Parameters::class );
|
||||
$params->method( 'getUser' )->willReturn( new UserIdentityValue( 1, 'Foobar' ) );
|
||||
|
@ -187,9 +175,6 @@ class BlockTest extends MediaWikiUnitTestCase {
|
|||
$this->assertFalse( $block->revert( $this->createMock( UserIdentity::class ), '' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::revert
|
||||
*/
|
||||
public function testRevert_couldNotUnblock() {
|
||||
$params = $this->createMock( Parameters::class );
|
||||
$params->method( 'getUser' )->willReturn( new UserIdentityValue( 1, 'Foobar' ) );
|
||||
|
|
|
@ -18,8 +18,8 @@ use Psr\Log\NullLogger;
|
|||
class BuiltinPrioritiesTest extends MediaWikiUnitTestCase {
|
||||
|
||||
/**
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Consequences\Consequence\Throttle::getSort
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Consequences\Consequence\Warn::getSort
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Consequences\Consequence\Throttle
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Consequences\Consequence\Warn
|
||||
*/
|
||||
public function testThrottleMoreImportantThanWarn() {
|
||||
$throttle = new Throttle(
|
||||
|
|
|
@ -8,22 +8,17 @@ use MediaWiki\Extension\AbuseFilter\Consequences\Parameters;
|
|||
use MediaWikiUnitTestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Consequences\Consequence\Disallow
|
||||
* @covers ::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Consequences\Consequence\Disallow
|
||||
*/
|
||||
class DisallowTest extends MediaWikiUnitTestCase {
|
||||
use ConsequenceGetMessageTestTrait;
|
||||
|
||||
/**
|
||||
* @covers ::execute
|
||||
*/
|
||||
public function testExecute() {
|
||||
$disallow = new Disallow( $this->createMock( Parameters::class ), '' );
|
||||
$this->assertTrue( $disallow->execute() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getMessage
|
||||
* @dataProvider provideGetMessageParameters
|
||||
*/
|
||||
public function testGetMessage( Parameters $params ) {
|
||||
|
|
|
@ -16,7 +16,7 @@ use MessageLocalizer;
|
|||
use Psr\Log\NullLogger;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Consequences\Consequence\RangeBlock
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Consequences\Consequence\RangeBlock
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Consequences\Consequence\BlockingConsequence
|
||||
*/
|
||||
class RangeBlockTest extends MediaWikiUnitTestCase {
|
||||
|
@ -83,8 +83,6 @@ class RangeBlockTest extends MediaWikiUnitTestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider provideExecute
|
||||
* @covers ::__construct
|
||||
* @covers ::execute
|
||||
*/
|
||||
public function testExecute(
|
||||
string $requestIP, array $rangeBlockSize, string $target, bool $result
|
||||
|
@ -126,7 +124,6 @@ class RangeBlockTest extends MediaWikiUnitTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers ::getMessage
|
||||
* @dataProvider provideGetMessageParameters
|
||||
*/
|
||||
public function testGetMessage( Parameters $params ) {
|
||||
|
|
|
@ -9,14 +9,10 @@ use MediaWiki\Extension\AbuseFilter\Consequences\Parameters;
|
|||
use MediaWikiUnitTestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Consequences\Consequence\Tag
|
||||
* @covers ::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Consequences\Consequence\Tag
|
||||
*/
|
||||
class TagTest extends MediaWikiUnitTestCase {
|
||||
|
||||
/**
|
||||
* @covers ::execute
|
||||
*/
|
||||
public function testExecute() {
|
||||
$tagsToAdd = [ 'tag1', 'tag2' ];
|
||||
$specifier = $this->createMock( ActionSpecifier::class );
|
||||
|
|
|
@ -23,8 +23,7 @@ use Psr\Log\NullLogger;
|
|||
use Wikimedia\TestingAccessWrapper;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Consequences\Consequence\Throttle
|
||||
* @covers ::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Consequences\Consequence\Throttle
|
||||
*/
|
||||
class ThrottleTest extends MediaWikiUnitTestCase {
|
||||
|
||||
|
@ -61,9 +60,6 @@ class ThrottleTest extends MediaWikiUnitTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::execute
|
||||
*/
|
||||
public function testExecute_notPrechecked() {
|
||||
$throttle = $this->getThrottle();
|
||||
$this->expectException( ConsequenceNotPrecheckedException::class );
|
||||
|
@ -90,10 +86,6 @@ class ThrottleTest extends MediaWikiUnitTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers ::shouldDisableOtherConsequences
|
||||
* @covers ::isThrottled
|
||||
* @covers ::throttleKey
|
||||
* @covers ::throttleIdentifier
|
||||
* @dataProvider provideThrottle
|
||||
*/
|
||||
public function testShouldDisableOtherConsequences( Throttle $throttle, bool $shouldDisable ) {
|
||||
|
@ -101,10 +93,6 @@ class ThrottleTest extends MediaWikiUnitTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers ::execute
|
||||
* @covers ::setThrottled
|
||||
* @covers ::throttleKey
|
||||
* @covers ::throttleIdentifier
|
||||
* @dataProvider provideThrottle
|
||||
*/
|
||||
public function testExecute( Throttle $throttle, bool $shouldDisable, MockObject $cache = null ) {
|
||||
|
@ -119,7 +107,6 @@ class ThrottleTest extends MediaWikiUnitTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers ::throttleIdentifier
|
||||
* @dataProvider provideThrottleDataForIdentifiers
|
||||
*/
|
||||
public function testThrottleIdentifier(
|
||||
|
|
|
@ -16,8 +16,7 @@ use PHPUnit\Framework\MockObject\MockObject;
|
|||
use Wikimedia\TestingAccessWrapper;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Consequences\Consequence\Warn
|
||||
* @covers ::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Consequences\Consequence\Warn
|
||||
*/
|
||||
class WarnTest extends MediaWikiUnitTestCase {
|
||||
use ConsequenceGetMessageTestTrait;
|
||||
|
@ -49,9 +48,6 @@ class WarnTest extends MediaWikiUnitTestCase {
|
|||
return [ $params, $warnWrap->getWarnKey() ];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::execute
|
||||
*/
|
||||
public function testExecute_notPrechecked() {
|
||||
$warn = $this->getWarn();
|
||||
$this->expectException( ConsequenceNotPrecheckedException::class );
|
||||
|
@ -81,9 +77,6 @@ class WarnTest extends MediaWikiUnitTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers ::shouldDisableOtherConsequences
|
||||
* @covers ::shouldBeWarned
|
||||
* @covers ::getWarnKey
|
||||
* @dataProvider provideWarnsAndSuccess
|
||||
*/
|
||||
public function testShouldDisableOtherConsequences( Warn $warn, bool $shouldDisable ) {
|
||||
|
@ -91,9 +84,6 @@ class WarnTest extends MediaWikiUnitTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers ::execute
|
||||
* @covers ::setWarn
|
||||
* @covers ::getWarnKey
|
||||
* @dataProvider provideWarnsAndSuccess
|
||||
*/
|
||||
public function testExecute( Warn $warn, bool $shouldDisable, MockObject $session ) {
|
||||
|
@ -105,7 +95,6 @@ class WarnTest extends MediaWikiUnitTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers ::getMessage
|
||||
* @dataProvider provideGetMessageParameters
|
||||
*/
|
||||
public function testGetMessage( Parameters $params ) {
|
||||
|
|
|
@ -17,14 +17,10 @@ use Psr\Log\NullLogger;
|
|||
/**
|
||||
* @group Test
|
||||
* @group AbuseFilter
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Consequences\ConsequencesExecutorFactory
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Consequences\ConsequencesExecutorFactory
|
||||
*/
|
||||
class ConsequencesExecutorFactoryTest extends MediaWikiUnitTestCase {
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::newExecutor
|
||||
*/
|
||||
public function testNewExecutor() {
|
||||
$factory = new ConsequencesExecutorFactory(
|
||||
$this->createMock( ConsequencesLookup::class ),
|
||||
|
|
|
@ -25,7 +25,7 @@ use Wikimedia\TestingAccessWrapper;
|
|||
/**
|
||||
* @group Test
|
||||
* @group AbuseFilter
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Consequences\ConsequencesExecutor
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Consequences\ConsequencesExecutor
|
||||
*/
|
||||
class ConsequencesExecutorTest extends MediaWikiUnitTestCase {
|
||||
/**
|
||||
|
@ -105,14 +105,6 @@ class ConsequencesExecutorTest extends MediaWikiUnitTestCase {
|
|||
* @param array $rawConsequences A raw, unfiltered list of consequences
|
||||
* @param array $expectedKeys
|
||||
*
|
||||
* @covers ::getActualConsequencesToExecute
|
||||
* @covers ::replaceLegacyParameters
|
||||
* @covers ::specializeParameters
|
||||
* @covers ::removeForbiddenConsequences
|
||||
* @covers ::replaceArraysWithConsequences
|
||||
* @covers ::applyConsequenceDisablers
|
||||
* @covers ::deduplicateConsequences
|
||||
* @covers ::removeRedundantConsequences
|
||||
* @dataProvider provideConsequences
|
||||
*/
|
||||
public function testGetActualConsequencesToExecute(
|
||||
|
|
|
@ -24,8 +24,7 @@ use Psr\Log\NullLogger;
|
|||
/**
|
||||
* @group Test
|
||||
* @group AbuseFilter
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Consequences\ConsequencesFactory
|
||||
* @covers ::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Consequences\ConsequencesFactory
|
||||
*/
|
||||
class ConsequencesFactoryTest extends MediaWikiUnitTestCase {
|
||||
|
||||
|
@ -60,65 +59,41 @@ class ConsequencesFactoryTest extends MediaWikiUnitTestCase {
|
|||
return $consequencesFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::newBlock
|
||||
*/
|
||||
public function testNewBlock() {
|
||||
$this->getFactory()->newBlock( $this->createMock( Parameters::class ), '', false );
|
||||
$this->addToAssertionCount( 1 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::newRangeBlock
|
||||
*/
|
||||
public function testNewRangeBlock() {
|
||||
$this->getFactory()->newRangeBlock( $this->createMock( Parameters::class ), '' );
|
||||
$this->addToAssertionCount( 1 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::newDegroup
|
||||
*/
|
||||
public function testNewDegroup() {
|
||||
$this->getFactory()->newDegroup( $this->createMock( Parameters::class ), new VariableHolder() );
|
||||
$this->addToAssertionCount( 1 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::newBlockAutopromote
|
||||
*/
|
||||
public function testNewBlockAutopromote() {
|
||||
$this->getFactory()->newBlockAutopromote( $this->createMock( Parameters::class ), 42 );
|
||||
$this->addToAssertionCount( 1 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::newThrottle
|
||||
*/
|
||||
public function testNewThrottle() {
|
||||
$this->getFactory()->newThrottle( $this->createMock( Parameters::class ), [] );
|
||||
$this->addToAssertionCount( 1 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::newWarn
|
||||
*/
|
||||
public function testNewWarn() {
|
||||
$this->getFactory()->newWarn( $this->createMock( Parameters::class ), '' );
|
||||
$this->addToAssertionCount( 1 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::newDisallow
|
||||
*/
|
||||
public function testNewDisallow() {
|
||||
$this->getFactory()->newDisallow( $this->createMock( Parameters::class ), '' );
|
||||
$this->addToAssertionCount( 1 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::newTag
|
||||
*/
|
||||
public function testNewTag() {
|
||||
$this->getFactory()->newTag( $this->createMock( Parameters::class ), [] );
|
||||
$this->addToAssertionCount( 1 );
|
||||
|
|
|
@ -12,13 +12,10 @@ use Wikimedia\Rdbms\LBFactory;
|
|||
/**
|
||||
* @group Test
|
||||
* @group AbuseFilter
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Consequences\ConsequencesLookup
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Consequences\ConsequencesLookup
|
||||
* @todo Write unit tests (non-trivial because the class is tied to a DB)
|
||||
*/
|
||||
class ConsequencesLookupTest extends MediaWikiUnitTestCase {
|
||||
/**
|
||||
* @covers ::__construct
|
||||
*/
|
||||
public function testConstructor() {
|
||||
$this->assertInstanceOf(
|
||||
ConsequencesLookup::class,
|
||||
|
|
|
@ -12,13 +12,10 @@ use RuntimeException;
|
|||
/**
|
||||
* @group Test
|
||||
* @group AbuseFilter
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Consequences\ConsequencesRegistry
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Consequences\ConsequencesRegistry
|
||||
*/
|
||||
class ConsequencesRegistryTest extends MediaWikiUnitTestCase {
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
*/
|
||||
public function testConstruct() {
|
||||
$hookRunner = $this->createMock( AbuseFilterHookRunner::class );
|
||||
$this->assertInstanceOf(
|
||||
|
@ -27,9 +24,6 @@ class ConsequencesRegistryTest extends MediaWikiUnitTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getAllActionNames
|
||||
*/
|
||||
public function testGetAllActionNames() {
|
||||
$configActions = [ 'nothing' => false, 'rickroll' => true ];
|
||||
$customActionName = 'spell';
|
||||
|
@ -44,9 +38,6 @@ class ConsequencesRegistryTest extends MediaWikiUnitTestCase {
|
|||
$this->assertSame( $expected, $registry->getAllActionNames() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getAllEnabledActionNames
|
||||
*/
|
||||
public function testGetAllEnabledActionNames() {
|
||||
$configActions = [ 'nothing' => false, 'rickroll' => true ];
|
||||
$customActionName = 'spell';
|
||||
|
@ -61,9 +52,6 @@ class ConsequencesRegistryTest extends MediaWikiUnitTestCase {
|
|||
$this->assertSame( $expected, $registry->getAllEnabledActionNames() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getDangerousActionNames
|
||||
*/
|
||||
public function testGetDangerousActionNames() {
|
||||
// Cheat a bit
|
||||
$regReflection = new ReflectionClass( ConsequencesRegistry::class );
|
||||
|
@ -73,9 +61,6 @@ class ConsequencesRegistryTest extends MediaWikiUnitTestCase {
|
|||
$this->assertSame( $expected, $registry->getDangerousActionNames() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getDangerousActionNames
|
||||
*/
|
||||
public function testGetDangerousActionNames_hook() {
|
||||
$extraDangerous = 'rickroll';
|
||||
$hookRunner = $this->createMock( AbuseFilterHookRunner::class );
|
||||
|
@ -88,10 +73,6 @@ class ConsequencesRegistryTest extends MediaWikiUnitTestCase {
|
|||
$this->assertContains( $extraDangerous, $registry->getDangerousActionNames() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getCustomActions
|
||||
* @covers ::validateCustomActions
|
||||
*/
|
||||
public function testGetCustomActions() {
|
||||
$customActionName = 'rickroll';
|
||||
$customAction = 'strlen';
|
||||
|
@ -105,10 +86,6 @@ class ConsequencesRegistryTest extends MediaWikiUnitTestCase {
|
|||
$this->assertSame( [ $customActionName => $customAction ], $registry->getCustomActions() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getCustomActions
|
||||
* @covers ::validateCustomActions
|
||||
*/
|
||||
public function testGetCustomActions_invalidKey() {
|
||||
$hookRunner = $this->createMock( AbuseFilterHookRunner::class );
|
||||
$hookRunner->method( 'onAbuseFilterCustomActions' )->willReturnCallback(
|
||||
|
@ -122,10 +99,6 @@ class ConsequencesRegistryTest extends MediaWikiUnitTestCase {
|
|||
$registry->getCustomActions();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getCustomActions
|
||||
* @covers ::validateCustomActions
|
||||
*/
|
||||
public function testGetCustomActions_invalidValue() {
|
||||
$hookRunner = $this->createMock( AbuseFilterHookRunner::class );
|
||||
$hookRunner->method( 'onAbuseFilterCustomActions' )->willReturnCallback(
|
||||
|
|
|
@ -12,18 +12,9 @@ use MediaWikiUnitTestCase;
|
|||
/**
|
||||
* @group Test
|
||||
* @group AbuseFilter
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Consequences\Parameters
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Consequences\Parameters
|
||||
*/
|
||||
class ParametersTest extends MediaWikiUnitTestCase {
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getFilter
|
||||
* @covers ::getIsGlobalFilter
|
||||
* @covers ::getActionSpecifier
|
||||
* @covers ::getUser
|
||||
* @covers ::getTarget
|
||||
* @covers ::getAction
|
||||
*/
|
||||
public function testGetters() {
|
||||
$filter = $this->createMock( ExistingFilter::class );
|
||||
$global = true;
|
||||
|
|
|
@ -14,7 +14,7 @@ use MediaWikiUnitTestCase;
|
|||
use MessageLocalizer;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Editbox\EditBoxBuilderFactory
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Editbox\EditBoxBuilderFactory
|
||||
*/
|
||||
class EditBoxBuilderFactoryTest extends MediaWikiUnitTestCase {
|
||||
|
||||
|
@ -31,9 +31,7 @@ class EditBoxBuilderFactoryTest extends MediaWikiUnitTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::newEditBoxBuilder
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\EditBox\EditBoxBuilder::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\EditBox\EditBoxBuilder
|
||||
* @dataProvider provideNewEditBoxBuilder
|
||||
* @param bool $isCodeEditorLoaded
|
||||
*/
|
||||
|
@ -55,9 +53,6 @@ class EditBoxBuilderFactoryTest extends MediaWikiUnitTestCase {
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::newPlainBoxBuilder
|
||||
*/
|
||||
public function testNewPlainBoxBuilder() {
|
||||
$this->assertInstanceOf(
|
||||
PlainEditBoxBuilder::class,
|
||||
|
@ -69,9 +64,6 @@ class EditBoxBuilderFactoryTest extends MediaWikiUnitTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::newAceBoxBuilder
|
||||
*/
|
||||
public function testNewAceBoxBuilder() {
|
||||
$this->assertInstanceOf(
|
||||
AceEditBoxBuilder::class,
|
||||
|
@ -83,9 +75,6 @@ class EditBoxBuilderFactoryTest extends MediaWikiUnitTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::newAceBoxBuilder
|
||||
*/
|
||||
public function testNewAceBoxBuilder__invalid() {
|
||||
$this->expectException( LogicException::class );
|
||||
$this->getFactory( false )->newAceBoxBuilder(
|
||||
|
|
|
@ -19,13 +19,10 @@ use WikiPage;
|
|||
/**
|
||||
* @group Test
|
||||
* @group AbuseFilter
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\EditRevUpdater
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\EditRevUpdater
|
||||
*/
|
||||
class EditRevUpdaterTest extends MediaWikiUnitTestCase {
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
*/
|
||||
public function testConstruct() {
|
||||
$this->assertInstanceOf(
|
||||
EditRevUpdater::class,
|
||||
|
@ -80,21 +77,11 @@ class EditRevUpdaterTest extends MediaWikiUnitTestCase {
|
|||
return [ $wikiPage, new MutableRevisionRecord( $title ) ];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::updateRev
|
||||
* @covers ::getCacheKey
|
||||
*/
|
||||
public function testUpdateRev_noIDs() {
|
||||
$titleValue = new TitleValue( NS_PROJECT, 'EditRevUpdater' );
|
||||
$this->assertFalse( $this->getUpdater()->updateRev( ...$this->getPageAndRev( $titleValue ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::setLastEditPage
|
||||
* @covers ::setLogIdsForTarget
|
||||
* @covers ::updateRev
|
||||
* @covers ::getCacheKey
|
||||
*/
|
||||
public function testUpdateRev_differentPages() {
|
||||
$titleValue = new TitleValue( NS_PROJECT, 'EditRevUpdater' );
|
||||
$updater = $this->getUpdater();
|
||||
|
@ -105,12 +92,6 @@ class EditRevUpdaterTest extends MediaWikiUnitTestCase {
|
|||
$this->assertFalse( $updater->updateRev( ...$this->getPageAndRev( $titleValue ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::setLastEditPage
|
||||
* @covers ::setLogIdsForTarget
|
||||
* @covers ::updateRev
|
||||
* @covers ::getCacheKey
|
||||
*/
|
||||
public function testUpdateRev_nullEdit() {
|
||||
$titleValue = new TitleValue( NS_PROJECT, 'EditRevUpdater' );
|
||||
[ $page, $rev ] = $this->getPageAndRev( $titleValue );
|
||||
|
@ -126,10 +107,6 @@ class EditRevUpdaterTest extends MediaWikiUnitTestCase {
|
|||
|
||||
/**
|
||||
* @param array $ids
|
||||
* @covers ::setLastEditPage
|
||||
* @covers ::setLogIdsForTarget
|
||||
* @covers ::updateRev
|
||||
* @covers ::getCacheKey
|
||||
* @dataProvider provideIDsSuccess
|
||||
*/
|
||||
public function testUpdateRev_success( array $ids ) {
|
||||
|
@ -154,12 +131,6 @@ class EditRevUpdaterTest extends MediaWikiUnitTestCase {
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::setLastEditPage
|
||||
* @covers ::setLogIdsForTarget
|
||||
* @covers ::updateRev
|
||||
* @covers ::getCacheKey
|
||||
*/
|
||||
public function testUpdateRev_multipleTitles() {
|
||||
$goodTitleValue = new TitleValue( NS_PROJECT, 'EditRevUpdater' );
|
||||
$badTitleValue = new TitleValue( NS_PROJECT, 'These should not be used' );
|
||||
|
@ -178,10 +149,6 @@ class EditRevUpdaterTest extends MediaWikiUnitTestCase {
|
|||
$this->assertTrue( $updater->updateRev( $page, $rev ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::clearLastEditPage
|
||||
* @covers ::updateRev
|
||||
*/
|
||||
public function testClearLastEditPage() {
|
||||
$titleValue = new TitleValue( NS_PROJECT, 'EditRevUpdater-clear' );
|
||||
[ $page, $revisionRecord ] = $this->getPageAndRev( $titleValue );
|
||||
|
@ -194,7 +161,6 @@ class EditRevUpdaterTest extends MediaWikiUnitTestCase {
|
|||
|
||||
/**
|
||||
* @param array $ids
|
||||
* @covers ::setLogIdsForTarget
|
||||
* @dataProvider provideInvalidIDs
|
||||
*/
|
||||
public function testSetLogIdsForTarget_invalid( array $ids ) {
|
||||
|
|
|
@ -14,8 +14,7 @@ use NullStatsdDataFactory;
|
|||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\EditStashCache
|
||||
* @covers ::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\EditStashCache
|
||||
*/
|
||||
class EditStashCacheTest extends MediaWikiUnitTestCase {
|
||||
|
||||
|
@ -26,11 +25,6 @@ class EditStashCacheTest extends MediaWikiUnitTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::store
|
||||
* @covers ::logCache
|
||||
* @covers ::getStashKey
|
||||
*/
|
||||
public function testStore() {
|
||||
$title = new TitleValue( NS_MAIN, 'Some title' );
|
||||
$cache = $this->getMockBuilder( HashBagOStuff::class )
|
||||
|
@ -76,10 +70,6 @@ class EditStashCacheTest extends MediaWikiUnitTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers ::store
|
||||
* @covers ::logCache
|
||||
* @covers ::seek
|
||||
* @covers ::getStashKey
|
||||
* @dataProvider provideRoundTrip
|
||||
*/
|
||||
public function testRoundTrip( array $storeVars, array $seekVars ) {
|
||||
|
@ -115,11 +105,6 @@ class EditStashCacheTest extends MediaWikiUnitTestCase {
|
|||
$this->assertArrayEquals( $data, $value );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::seek
|
||||
* @covers ::logCache
|
||||
* @covers ::getStashKey
|
||||
*/
|
||||
public function testSeek_miss() {
|
||||
$title = new TitleValue( NS_MAIN, 'Some title' );
|
||||
$cache = new HashBagOStuff();
|
||||
|
|
|
@ -7,28 +7,16 @@ use MediaWiki\Extension\AbuseFilter\EmergencyCache;
|
|||
use MediaWikiUnitTestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\EmergencyCache
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\EmergencyCache
|
||||
*/
|
||||
class EmergencyCacheTest extends MediaWikiUnitTestCase {
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getFiltersToCheckInGroup
|
||||
* @covers ::getForFilter
|
||||
*/
|
||||
public function testEmptyCache() {
|
||||
$cache = new EmergencyCache( new HashBagOStuff(), [ 'default' => 86400 ] );
|
||||
$this->assertSame( [], $cache->getFiltersToCheckInGroup( 'default' ) );
|
||||
$this->assertFalse( $cache->getForFilter( 1 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::setNewForFilter
|
||||
* @covers ::getFiltersToCheckInGroup
|
||||
* @covers ::getForFilter
|
||||
* @covers ::createGroupKey
|
||||
* @covers ::createFilterKey
|
||||
*/
|
||||
public function testSetNewForFilter() {
|
||||
$time = microtime( true );
|
||||
$stash = new HashBagOStuff();
|
||||
|
@ -55,11 +43,6 @@ class EmergencyCacheTest extends MediaWikiUnitTestCase {
|
|||
$this->assertSame( [], $cache->getFiltersToCheckInGroup( 'other' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::incrementForFilter
|
||||
* @covers ::getForFilter
|
||||
* @covers ::setNewForFilter
|
||||
*/
|
||||
public function testIncrementForFilter() {
|
||||
$time = microtime( true );
|
||||
$stash = new HashBagOStuff();
|
||||
|
@ -82,9 +65,6 @@ class EmergencyCacheTest extends MediaWikiUnitTestCase {
|
|||
$this->assertFalse( $cache->getForFilter( 1 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getFiltersToCheckInGroup
|
||||
*/
|
||||
public function testGetFiltersToCheckInGroup() {
|
||||
$time = microtime( true );
|
||||
$stash = new HashBagOStuff();
|
||||
|
|
|
@ -11,12 +11,9 @@ use Wikimedia\Assert\ParameterTypeException;
|
|||
/**
|
||||
* @group Test
|
||||
* @group AbuseFilter
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Filter\AbstractFilter
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Filter\AbstractFilter
|
||||
*/
|
||||
class AbstractFilterTest extends MediaWikiUnitTestCase {
|
||||
/**
|
||||
* @covers ::__construct
|
||||
*/
|
||||
public function testConstruct_invalidActions() {
|
||||
$this->expectException( ParameterTypeException::class );
|
||||
new AbstractFilter(
|
||||
|
@ -26,9 +23,6 @@ class AbstractFilterTest extends MediaWikiUnitTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
*/
|
||||
public function testConstruct_actionsFormats() {
|
||||
$specs = $this->createMock( Specs::class );
|
||||
$flags = $this->createMock( Flags::class );
|
||||
|
@ -45,18 +39,6 @@ class AbstractFilterTest extends MediaWikiUnitTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getRules
|
||||
* @covers ::getComments
|
||||
* @covers ::getName
|
||||
* @covers ::getActionsNames
|
||||
* @covers ::getGroup
|
||||
* @covers ::isEnabled
|
||||
* @covers ::isDeleted
|
||||
* @covers ::isHidden
|
||||
* @covers ::isGlobal
|
||||
*/
|
||||
public function testValueGetters() {
|
||||
$rules = 'rules';
|
||||
$comments = 'comments';
|
||||
|
@ -84,10 +66,6 @@ class AbstractFilterTest extends MediaWikiUnitTestCase {
|
|||
$this->assertSame( $global, $filter->isGlobal(), 'global' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getSpecs
|
||||
* @covers ::getFlags
|
||||
*/
|
||||
public function testGetObjects() {
|
||||
$specs = $this->createMock( Specs::class );
|
||||
$flags = $this->createMock( Flags::class );
|
||||
|
@ -103,8 +81,6 @@ class AbstractFilterTest extends MediaWikiUnitTestCase {
|
|||
/**
|
||||
* @param array|callable $value
|
||||
* @param array $expected
|
||||
* @covers ::getActions
|
||||
* @covers ::setActions
|
||||
* @dataProvider provideActions
|
||||
*/
|
||||
public function testActions( $value, array $expected ) {
|
||||
|
@ -135,10 +111,6 @@ class AbstractFilterTest extends MediaWikiUnitTestCase {
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::__clone
|
||||
*/
|
||||
public function testNoWriteableReferences() {
|
||||
$oldRules = 'rules';
|
||||
$specs = new Specs( $oldRules, 'x', 'x', [], 'x' );
|
||||
|
|
|
@ -11,13 +11,9 @@ use MediaWikiUnitTestCase;
|
|||
/**
|
||||
* @group Test
|
||||
* @group AbuseFilter
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Filter\ExistingFilter
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Filter\ExistingFilter
|
||||
*/
|
||||
class ExistingFilterTest extends MediaWikiUnitTestCase {
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getID
|
||||
*/
|
||||
public function testGetID() {
|
||||
$id = 163;
|
||||
$filter = new ExistingFilter(
|
||||
|
|
|
@ -11,18 +11,9 @@ use MediaWikiUnitTestCase;
|
|||
/**
|
||||
* @group Test
|
||||
* @group AbuseFilter
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Filter\Filter
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Filter\Filter
|
||||
*/
|
||||
class FilterTest extends MediaWikiUnitTestCase {
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getUserID
|
||||
* @covers ::getUserName
|
||||
* @covers ::getTimestamp
|
||||
* @covers ::getID
|
||||
* @covers ::getHitCount
|
||||
* @covers ::isThrottled
|
||||
*/
|
||||
public function testValueGetters() {
|
||||
$userID = 42;
|
||||
$userName = 'Admin';
|
||||
|
@ -48,9 +39,6 @@ class FilterTest extends MediaWikiUnitTestCase {
|
|||
$this->assertSame( $throttled, $filter->isThrottled(), 'throttled' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getLastEditInfo
|
||||
*/
|
||||
public function testGetObjects() {
|
||||
$specs = $this->createMock( Specs::class );
|
||||
$flags = $this->createMock( Flags::class );
|
||||
|
@ -61,10 +49,6 @@ class FilterTest extends MediaWikiUnitTestCase {
|
|||
$this->assertNotSame( $lastEditInfo, $filter->getLastEditInfo(), 'not identical' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::__clone
|
||||
*/
|
||||
public function testNoWriteableReferences() {
|
||||
$oldUsername = 'User1';
|
||||
$lastEditInfo = new LastEditInfo( 1, $oldUsername, '123' );
|
||||
|
|
|
@ -8,16 +8,9 @@ use MediaWikiUnitTestCase;
|
|||
/**
|
||||
* @group Test
|
||||
* @group AbuseFilter
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Filter\Flags
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Filter\Flags
|
||||
*/
|
||||
class FlagsTest extends MediaWikiUnitTestCase {
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getEnabled
|
||||
* @covers ::getDeleted
|
||||
* @covers ::getHidden
|
||||
* @covers ::getGlobal
|
||||
*/
|
||||
public function testGetters() {
|
||||
$enabled = true;
|
||||
$deleted = false;
|
||||
|
@ -35,10 +28,6 @@ class FlagsTest extends MediaWikiUnitTestCase {
|
|||
* @param mixed $value
|
||||
* @param string $setter
|
||||
* @param string $getter
|
||||
* @covers ::setEnabled
|
||||
* @covers ::setDeleted
|
||||
* @covers ::setHidden
|
||||
* @covers ::setGlobal
|
||||
* @dataProvider provideSetters
|
||||
*/
|
||||
public function testSetters( $value, string $setter, string $getter ) {
|
||||
|
|
|
@ -11,13 +11,9 @@ use MediaWikiUnitTestCase;
|
|||
/**
|
||||
* @group Test
|
||||
* @group AbuseFilter
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Filter\HistoryFilter
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Filter\HistoryFilter
|
||||
*/
|
||||
class HistoryFilterTest extends MediaWikiUnitTestCase {
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getHistoryID
|
||||
*/
|
||||
public function testGetID() {
|
||||
$historyID = 163;
|
||||
$filter = new HistoryFilter(
|
||||
|
|
|
@ -8,15 +8,9 @@ use MediaWikiUnitTestCase;
|
|||
/**
|
||||
* @group Test
|
||||
* @group AbuseFilter
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Filter\LastEditInfo
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Filter\LastEditInfo
|
||||
*/
|
||||
class LastEditInfoTest extends MediaWikiUnitTestCase {
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getUserID
|
||||
* @covers ::getUserName
|
||||
* @covers ::getTimestamp
|
||||
*/
|
||||
public function testGetters() {
|
||||
$userID = 42;
|
||||
$userName = 'Admin';
|
||||
|
@ -32,9 +26,6 @@ class LastEditInfoTest extends MediaWikiUnitTestCase {
|
|||
* @param mixed $value
|
||||
* @param string $setter
|
||||
* @param string $getter
|
||||
* @covers ::setUserID
|
||||
* @covers ::setUserName
|
||||
* @covers ::setTimestamp
|
||||
* @dataProvider provideSetters
|
||||
*/
|
||||
public function testSetters( $value, string $setter, string $getter ) {
|
||||
|
|
|
@ -13,29 +13,13 @@ use MediaWikiUnitTestCase;
|
|||
/**
|
||||
* @group Test
|
||||
* @group AbuseFilter
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Filter\MutableFilter
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Filter\MutableFilter
|
||||
*/
|
||||
class MutableFilterTest extends MediaWikiUnitTestCase {
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @param string $setter
|
||||
* @param string $getter
|
||||
* @covers ::setRules
|
||||
* @covers ::setComments
|
||||
* @covers ::setName
|
||||
* @covers ::setActionsNames
|
||||
* @covers ::setGroup
|
||||
* @covers ::setEnabled
|
||||
* @covers ::setDeleted
|
||||
* @covers ::setHidden
|
||||
* @covers ::setGlobal
|
||||
* @covers ::setActions
|
||||
* @covers ::setUserID
|
||||
* @covers ::setUserName
|
||||
* @covers ::setTimestamp
|
||||
* @covers ::setID
|
||||
* @covers ::setHitCount
|
||||
* @covers ::setThrottled
|
||||
* @dataProvider provideSetters
|
||||
*/
|
||||
public function testSetters( $value, string $setter, string $getter ) {
|
||||
|
@ -76,9 +60,6 @@ class MutableFilterTest extends MediaWikiUnitTestCase {
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::setActionsNames
|
||||
*/
|
||||
public function testSetActionsNames_withActionsSet() {
|
||||
$filter = new MutableFilter(
|
||||
new Specs( 'rules', 'comments', 'name', [], 'group' ),
|
||||
|
@ -90,9 +71,6 @@ class MutableFilterTest extends MediaWikiUnitTestCase {
|
|||
$filter->setActionsNames( [ 'x' ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::newFromParentFilter
|
||||
*/
|
||||
public function testNewFromParentFilter() {
|
||||
$baseFilter = new Filter(
|
||||
new Specs( 'rules', 'comments', 'name', [ 'x' ], 'group' ),
|
||||
|
|
|
@ -14,14 +14,13 @@ use MediaWikiUnitTestCase;
|
|||
/**
|
||||
* @group Test
|
||||
* @group AbuseFilter
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\FilterCompare
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\FilterCompare
|
||||
*/
|
||||
class FilterCompareTest extends MediaWikiUnitTestCase {
|
||||
/**
|
||||
* @param Filter $firstVersion
|
||||
* @param Filter $secondVersion
|
||||
* @param array $expected The differences
|
||||
* @covers ::compareVersions
|
||||
* @dataProvider provideVersions
|
||||
*/
|
||||
public function testCompareVersions(
|
||||
|
@ -336,9 +335,6 @@ class FilterCompareTest extends MediaWikiUnitTestCase {
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
*/
|
||||
public function testConstruct() {
|
||||
$this->assertInstanceOf(
|
||||
FilterCompare::class,
|
||||
|
|
|
@ -18,7 +18,7 @@ use MediaWikiUnitTestCase;
|
|||
/**
|
||||
* @group Test
|
||||
* @group AbuseFilter
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\FilterImporter
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\FilterImporter
|
||||
*/
|
||||
class FilterImporterTest extends MediaWikiUnitTestCase {
|
||||
private const GOOD_FILTER_DATA = [
|
||||
|
@ -61,9 +61,6 @@ class FilterImporterTest extends MediaWikiUnitTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::encodeData
|
||||
*/
|
||||
public function testEncodeData() {
|
||||
$importer = $this->getImporter();
|
||||
$filter = MutableFilter::newDefault();
|
||||
|
@ -73,8 +70,6 @@ class FilterImporterTest extends MediaWikiUnitTestCase {
|
|||
|
||||
/**
|
||||
* @param mixed $data
|
||||
* @covers ::decodeData
|
||||
* @covers ::isValidImportData
|
||||
* @dataProvider provideInvalidData
|
||||
*/
|
||||
public function testDecodeData_invalid( $data ) {
|
||||
|
@ -112,9 +107,6 @@ class FilterImporterTest extends MediaWikiUnitTestCase {
|
|||
* @param array $origActions
|
||||
* @param Filter $expectedFilter
|
||||
* @param array $configOptions
|
||||
* @covers ::decodeData
|
||||
* @covers ::encodeData
|
||||
* @covers ::isValidImportData
|
||||
* @dataProvider provideRoundTrip
|
||||
*/
|
||||
public function testRoundTrip(
|
||||
|
@ -188,9 +180,6 @@ class FilterImporterTest extends MediaWikiUnitTestCase {
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
*/
|
||||
public function testConstruct() {
|
||||
$this->assertInstanceOf(
|
||||
FilterImporter::class,
|
||||
|
|
|
@ -28,7 +28,7 @@ use Wikimedia\Rdbms\SelectQueryBuilder;
|
|||
/**
|
||||
* @group Test
|
||||
* @group AbuseFilter
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\FilterLookup
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\FilterLookup
|
||||
* @todo Some integration tests with a real DB might be helpful
|
||||
*/
|
||||
class FilterLookupTest extends MediaWikiUnitTestCase {
|
||||
|
@ -106,8 +106,6 @@ class FilterLookupTest extends MediaWikiUnitTestCase {
|
|||
* @param stdClass $dbRow
|
||||
* @param HistoryFilter $expected
|
||||
* @dataProvider provideFilterVersions
|
||||
* @covers ::getFilterVersion
|
||||
* @covers ::filterFromHistoryRow
|
||||
*/
|
||||
public function testGetFilterVersion( int $version, stdClass $dbRow, HistoryFilter $expected ) {
|
||||
$db = $this->getDBWithMockRows( [ $dbRow ] );
|
||||
|
@ -196,9 +194,6 @@ class FilterLookupTest extends MediaWikiUnitTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getFilterVersion
|
||||
*/
|
||||
public function testGetFilterVersion_notfound() {
|
||||
$db = $this->createMock( DBConnRef::class );
|
||||
$db->method( 'selectRow' )->willReturn( false );
|
||||
|
@ -208,9 +203,6 @@ class FilterLookupTest extends MediaWikiUnitTestCase {
|
|||
$filterLookup->getFilterVersion( 42 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getLastHistoryVersion
|
||||
*/
|
||||
public function testGetLastHistoryVersion() {
|
||||
// Reuse this data provider for conveniency
|
||||
[ , $historyRow, $filter ] = $this->provideFilterVersions()->current();
|
||||
|
@ -219,9 +211,6 @@ class FilterLookupTest extends MediaWikiUnitTestCase {
|
|||
$this->assertEquals( $filter, $filterLookup->getLastHistoryVersion( $filter->getID() ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getLastHistoryVersion
|
||||
*/
|
||||
public function testGetLastHistoryVersion_notfound() {
|
||||
$db = $this->createMock( DBConnRef::class );
|
||||
$db->method( 'selectRow' )->willReturn( false );
|
||||
|
@ -231,9 +220,6 @@ class FilterLookupTest extends MediaWikiUnitTestCase {
|
|||
$filterLookup->getLastHistoryVersion( 42 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getClosestVersion
|
||||
*/
|
||||
public function testGetClosestVersion() {
|
||||
// Reuse this data provider for conveniency
|
||||
[ , $historyRow, $filter ] = $this->provideFilterVersions()->current();
|
||||
|
@ -242,9 +228,6 @@ class FilterLookupTest extends MediaWikiUnitTestCase {
|
|||
$this->assertEquals( $filter, $filterLookup->getClosestVersion( 1, 42, FilterLookup::DIR_NEXT ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getClosestVersion
|
||||
*/
|
||||
public function testGetClosestVersion_notfound() {
|
||||
$db = $this->createMock( DBConnRef::class );
|
||||
$db->method( 'selectRow' )->willReturn( false );
|
||||
|
@ -254,9 +237,6 @@ class FilterLookupTest extends MediaWikiUnitTestCase {
|
|||
$filterLookup->getClosestVersion( 42, 42, FilterLookup::DIR_PREV );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getFirstFilterVersionID
|
||||
*/
|
||||
public function testGetFirstFilterVersionID() {
|
||||
$versionID = 1234;
|
||||
$db = $this->createMock( DBConnRef::class );
|
||||
|
@ -266,9 +246,6 @@ class FilterLookupTest extends MediaWikiUnitTestCase {
|
|||
$this->assertSame( $versionID, $filterLookup->getFirstFilterVersionID( 42 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getFirstFilterVersionID
|
||||
*/
|
||||
public function testGetFirstFilterVersionID_notfound() {
|
||||
$db = $this->createMock( DBConnRef::class );
|
||||
$db->method( 'selectField' )->willReturn( false );
|
||||
|
@ -278,10 +255,6 @@ class FilterLookupTest extends MediaWikiUnitTestCase {
|
|||
$filterLookup->getFirstFilterVersionID( 42 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getFilter
|
||||
* @covers ::getCacheKey
|
||||
*/
|
||||
public function testLocalCache() {
|
||||
$row = $this->getRowsAndFilters()['no actions']['row'];
|
||||
$db = $this->createMock( DBConnRef::class );
|
||||
|
@ -295,9 +268,6 @@ class FilterLookupTest extends MediaWikiUnitTestCase {
|
|||
$filterLookup->getFilter( 42, false );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::clearLocalCache
|
||||
*/
|
||||
public function testClearLocalCache() {
|
||||
$row = $this->getRowsAndFilters()['no actions']['row'];
|
||||
$db = $this->createMock( DBConnRef::class );
|
||||
|
@ -324,8 +294,6 @@ class FilterLookupTest extends MediaWikiUnitTestCase {
|
|||
|
||||
/**
|
||||
* @param bool $isCentral
|
||||
* @covers ::getAllActiveFiltersInGroup
|
||||
* @covers ::getGlobalRulesKey
|
||||
* @dataProvider provideIsCentral
|
||||
*/
|
||||
public function testGlobalCache( bool $isCentral ) {
|
||||
|
@ -350,11 +318,6 @@ class FilterLookupTest extends MediaWikiUnitTestCase {
|
|||
$filterLookup->getAllActiveFiltersInGroup( $group, $global );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::purgeGroupWANCache
|
||||
* @covers ::getAllActiveFiltersInGroup
|
||||
* @covers ::getGlobalRulesKey
|
||||
*/
|
||||
public function testFilterLookupClearNetworkCache() {
|
||||
$row = $this->getRowsAndFilters()['no actions']['row'];
|
||||
$db = $this->createMock( DBConnRef::class );
|
||||
|
@ -380,9 +343,6 @@ class FilterLookupTest extends MediaWikiUnitTestCase {
|
|||
$filterLookup->getAllActiveFiltersInGroup( $group, $global );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
*/
|
||||
public function testValidConstructor() {
|
||||
$this->assertInstanceOf(
|
||||
FilterLookup::class,
|
||||
|
@ -398,10 +358,6 @@ class FilterLookupTest extends MediaWikiUnitTestCase {
|
|||
* @param stdClass $row
|
||||
* @param stdClass[] $actionsRows
|
||||
* @param ExistingFilter $expected
|
||||
* @covers ::getFilter
|
||||
* @covers ::filterFromRow
|
||||
* @covers ::getDBConnection
|
||||
* @covers ::getActionsFromDB
|
||||
* @dataProvider getRowsAndFilters
|
||||
*/
|
||||
public function testGetFilter( stdClass $row, array $actionsRows, ExistingFilter $expected ) {
|
||||
|
@ -418,10 +374,6 @@ class FilterLookupTest extends MediaWikiUnitTestCase {
|
|||
* @param stdClass $row
|
||||
* @param stdClass[] $actionsRows
|
||||
* @param ExistingFilter $expected
|
||||
* @covers ::getFilter
|
||||
* @covers ::filterFromRow
|
||||
* @covers ::getDBConnection
|
||||
* @covers ::getActionsFromDB
|
||||
* @dataProvider getRowsAndFilters
|
||||
*/
|
||||
public function testGetFilter_global( stdClass $row, array $actionsRows, ExistingFilter $expected ) {
|
||||
|
@ -434,9 +386,6 @@ class FilterLookupTest extends MediaWikiUnitTestCase {
|
|||
$this->assertEquals( $expected, $actual );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getFilter
|
||||
*/
|
||||
public function testGetFilter_notfound() {
|
||||
$db = $this->createMock( DBConnRef::class );
|
||||
$db->method( 'newSelectQueryBuilder' )->willReturnCallback( static fn () => new SelectQueryBuilder( $db ) );
|
||||
|
@ -447,20 +396,12 @@ class FilterLookupTest extends MediaWikiUnitTestCase {
|
|||
$filterLookup->getFilter( 42, false );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getFilter
|
||||
* @covers ::getDBConnection
|
||||
*/
|
||||
public function testGetFilter_globaldisabled() {
|
||||
$filterLookup = $this->getLookup();
|
||||
$this->expectException( CentralDBNotAvailableException::class );
|
||||
$filterLookup->getFilter( 42, true );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getAllActiveFiltersInGroup
|
||||
* @covers ::getAllActiveFiltersInGroupFromDB
|
||||
*/
|
||||
public function testGetAllActiveFiltersInGroup() {
|
||||
$data = $this->getRowsAndFilters();
|
||||
$db = $this->getDBWithMockRows(
|
||||
|
@ -486,9 +427,6 @@ class FilterLookupTest extends MediaWikiUnitTestCase {
|
|||
|
||||
/**
|
||||
* @param bool $isCentral
|
||||
* @covers ::getAllActiveFiltersInGroup
|
||||
* @covers ::getAllActiveFiltersInGroupFromDB
|
||||
* @covers ::getGlobalRulesKey
|
||||
* @dataProvider provideIsCentral
|
||||
*/
|
||||
public function testGetAllActiveFiltersInGroup_global( bool $isCentral ) {
|
||||
|
|
|
@ -15,8 +15,7 @@ use Wikimedia\WRStats\BagOStuffStatsStore;
|
|||
use Wikimedia\WRStats\WRStatsFactory;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\FilterProfiler
|
||||
* @covers ::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\FilterProfiler
|
||||
*/
|
||||
class FilterProfilerTest extends MediaWikiUnitTestCase {
|
||||
|
||||
|
@ -49,20 +48,11 @@ class FilterProfilerTest extends MediaWikiUnitTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getFilterProfile
|
||||
*/
|
||||
public function testGetFilterProfile_noData() {
|
||||
$profiler = $this->getFilterProfiler();
|
||||
$this->assertSame( self::NULL_FILTER_PROFILE, $profiler->getFilterProfile( 1 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getFilterProfile
|
||||
* @covers ::recordPerFilterProfiling
|
||||
* @covers ::recordProfilingResult
|
||||
* @covers ::filterProfileKey
|
||||
*/
|
||||
public function testGetFilterProfile() {
|
||||
$profiler = $this->getFilterProfiler();
|
||||
$profiler->recordPerFilterProfiling(
|
||||
|
@ -86,11 +76,6 @@ class FilterProfilerTest extends MediaWikiUnitTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getFilterProfile
|
||||
* @covers ::recordPerFilterProfiling
|
||||
* @covers ::recordProfilingResult
|
||||
*/
|
||||
public function testRecordPerFilterProfiling_mergesResults() {
|
||||
$profiler = $this->getFilterProfiler();
|
||||
$profiler->recordPerFilterProfiling(
|
||||
|
@ -124,11 +109,6 @@ class FilterProfilerTest extends MediaWikiUnitTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::recordPerFilterProfiling
|
||||
* @covers ::recordProfilingResult
|
||||
* @covers ::recordSlowFilter
|
||||
*/
|
||||
public function testRecordPerFilterProfiling_reportsSlowFilter() {
|
||||
$logger = new TestLogger();
|
||||
$logger->setCollect( true );
|
||||
|
@ -164,9 +144,6 @@ class FilterProfilerTest extends MediaWikiUnitTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::resetFilterProfile
|
||||
*/
|
||||
public function testResetFilterProfile() {
|
||||
$profiler = $this->getFilterProfiler();
|
||||
$profiler->recordPerFilterProfiling(
|
||||
|
@ -189,11 +166,6 @@ class FilterProfilerTest extends MediaWikiUnitTestCase {
|
|||
$this->assertNotSame( self::NULL_FILTER_PROFILE, $profiler->getFilterProfile( 2 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::recordStats
|
||||
* @covers ::getGroupProfile
|
||||
* @covers ::filterProfileGroupKey
|
||||
*/
|
||||
public function testGetGroupProfile_noData() {
|
||||
$profiler = $this->getFilterProfiler();
|
||||
$this->assertSame( self::NULL_GROUP_PROFILE, $profiler->getGroupProfile( 'default' ) );
|
||||
|
@ -204,9 +176,6 @@ class FilterProfilerTest extends MediaWikiUnitTestCase {
|
|||
* @param float $time
|
||||
* @param bool $matches
|
||||
* @param array $expected
|
||||
* @covers ::recordStats
|
||||
* @covers ::getGroupProfile
|
||||
* @covers ::filterProfileGroupKey
|
||||
* @dataProvider provideRecordStats
|
||||
*/
|
||||
public function testRecordStats( int $condsUsed, float $time, bool $matches, array $expected ) {
|
||||
|
@ -245,10 +214,6 @@ class FilterProfilerTest extends MediaWikiUnitTestCase {
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::recordStats
|
||||
* @covers ::getGroupProfile
|
||||
*/
|
||||
public function testRecordStats_mergesResults() {
|
||||
$profiler = $this->getFilterProfiler();
|
||||
$profiler->recordStats( 'default', 100, 256.5, true );
|
||||
|
|
|
@ -28,13 +28,9 @@ use Psr\Log\NullLogger;
|
|||
/**
|
||||
* @group Test
|
||||
* @group AbuseFilter
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\FilterRunnerFactory
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\FilterRunnerFactory
|
||||
*/
|
||||
class FilterRunnerFactoryTest extends MediaWikiUnitTestCase {
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::newRunner
|
||||
*/
|
||||
public function testNewRunner() {
|
||||
$opts = new ServiceOptions(
|
||||
FilterRunner::CONSTRUCTOR_OPTIONS,
|
||||
|
|
|
@ -17,13 +17,10 @@ use Wikimedia\Rdbms\LBFactory;
|
|||
/**
|
||||
* @group Test
|
||||
* @group AbuseFilter
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\FilterStore
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\FilterStore
|
||||
* @todo Expand this. FilterStore is tightly bound to a Database, so it's not easy.
|
||||
*/
|
||||
class FilterStoreTest extends MediaWikiUnitTestCase {
|
||||
/**
|
||||
* @covers ::__construct
|
||||
*/
|
||||
public function testConstruct() {
|
||||
$this->assertInstanceOf(
|
||||
FilterStore::class,
|
||||
|
|
|
@ -23,8 +23,7 @@ use PHPUnit\Framework\MockObject\MockObject;
|
|||
* @group Test
|
||||
* @group AbuseFilter
|
||||
* @group AbuseFilterSave
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\FilterValidator
|
||||
* @covers ::__construct()
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\FilterValidator
|
||||
*/
|
||||
class FilterValidatorTest extends MediaWikiUnitTestCase {
|
||||
|
||||
|
@ -97,7 +96,6 @@ class FilterValidatorTest extends MediaWikiUnitTestCase {
|
|||
* @param ExceptionBase|null $excep
|
||||
* @param string|null $expected
|
||||
* @param array|null $expParams
|
||||
* @covers ::checkValidSyntax
|
||||
* @dataProvider provideSyntax
|
||||
*/
|
||||
public function testCheckValidSyntax( ?ExceptionBase $excep, ?string $expected, ?array $expParams ) {
|
||||
|
@ -131,7 +129,6 @@ class FilterValidatorTest extends MediaWikiUnitTestCase {
|
|||
* @param string $rules
|
||||
* @param string $name
|
||||
* @param string|null $expected
|
||||
* @covers ::checkRequiredFields
|
||||
* @dataProvider provideRequiredFields
|
||||
*/
|
||||
public function testCheckRequiredFields( string $rules, string $name, ?string $expected ) {
|
||||
|
@ -154,7 +151,6 @@ class FilterValidatorTest extends MediaWikiUnitTestCase {
|
|||
/**
|
||||
* @param array $actions
|
||||
* @param string|null $expected
|
||||
* @covers ::checkEmptyMessages
|
||||
* @dataProvider provideEmptyMessages
|
||||
*/
|
||||
public function testCheckEmptyMessages( array $actions, ?string $expected ) {
|
||||
|
@ -176,7 +172,6 @@ class FilterValidatorTest extends MediaWikiUnitTestCase {
|
|||
* @param bool $enabled
|
||||
* @param bool $deleted
|
||||
* @param string|null $expected
|
||||
* @covers ::checkConflictingFields
|
||||
* @dataProvider provideConflictingFields
|
||||
*/
|
||||
public function testCheckConflictingFields( bool $enabled, bool $deleted, ?string $expected ) {
|
||||
|
@ -197,7 +192,6 @@ class FilterValidatorTest extends MediaWikiUnitTestCase {
|
|||
* @param bool $canEditNew
|
||||
* @param bool $canEditOrig
|
||||
* @param string|null $expected
|
||||
* @covers ::checkGlobalFilterEditPermission
|
||||
* @dataProvider provideCheckGlobalFilterEditPermission
|
||||
*/
|
||||
public function testCheckGlobalFilterEditPermission(
|
||||
|
@ -229,7 +223,6 @@ class FilterValidatorTest extends MediaWikiUnitTestCase {
|
|||
* @param array $actions
|
||||
* @param bool $isGlobal
|
||||
* @param string|null $expected
|
||||
* @covers ::checkMessagesOnGlobalFilters
|
||||
* @dataProvider provideMessagesOnGlobalFilters
|
||||
*/
|
||||
public function testCheckMessagesOnGlobalFilters( array $actions, bool $isGlobal, ?string $expected ) {
|
||||
|
@ -273,7 +266,6 @@ class FilterValidatorTest extends MediaWikiUnitTestCase {
|
|||
* @param array $restrictions
|
||||
* @param AbuseFilterPermissionManager $permManager
|
||||
* @param string|null $expected
|
||||
* @covers ::checkRestrictedActions
|
||||
* @dataProvider provideRestrictedActions
|
||||
*/
|
||||
public function testCheckRestrictedActions(
|
||||
|
@ -320,9 +312,6 @@ class FilterValidatorTest extends MediaWikiUnitTestCase {
|
|||
[ $unrestricted, $restricted, $restrictions, $canModifyRestrictedPM, null ];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::checkAllTags
|
||||
*/
|
||||
public function testCheckAllTags_noTags() {
|
||||
$this->assertStatusMessageParams( 'tags-create-no-name', $this->getFilterValidator()->checkAllTags( [] ) );
|
||||
}
|
||||
|
@ -330,7 +319,6 @@ class FilterValidatorTest extends MediaWikiUnitTestCase {
|
|||
/**
|
||||
* @param array $params Throttle parameters
|
||||
* @param string|null $expectedError The expected error message. Null if validations should pass
|
||||
* @covers ::checkThrottleParameters
|
||||
* @dataProvider provideThrottleParameters
|
||||
*/
|
||||
public function testCheckThrottleParameters( array $params, ?string $expectedError ) {
|
||||
|
@ -370,7 +358,6 @@ class FilterValidatorTest extends MediaWikiUnitTestCase {
|
|||
* @param AbuseFilterPermissionManager|null $permissionManager
|
||||
* @param FilterEvaluator|null $ruleChecker
|
||||
* @param array $restrictions
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\FilterValidator::checkAll
|
||||
* @dataProvider provideCheckAll
|
||||
*/
|
||||
public function testCheckAll(
|
||||
|
@ -458,7 +445,6 @@ class FilterValidatorTest extends MediaWikiUnitTestCase {
|
|||
* @param string $group
|
||||
* @param string[] $validGroups
|
||||
* @param string|null $expected
|
||||
* @covers ::checkGroup
|
||||
* @dataProvider provideGroups
|
||||
*/
|
||||
public function testCheckGroup( string $group, array $validGroups, ?string $expected ) {
|
||||
|
|
|
@ -29,12 +29,11 @@ use MediaWiki\Extension\AbuseFilter\GlobalNameUtils;
|
|||
* @group Test
|
||||
* @group AbuseFilter
|
||||
* @group AbuseFilterGeneric
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\GlobalNameUtils
|
||||
*/
|
||||
class GlobalNameUtilsTest extends MediaWikiUnitTestCase {
|
||||
|
||||
/**
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\GlobalNameUtils::splitGlobalName
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\GlobalNameUtils::buildGlobalName
|
||||
* @dataProvider provideBuildGlobalName
|
||||
*/
|
||||
public function testBuildGlobalName( int $id, bool $global, string $expected ) {
|
||||
|
@ -55,7 +54,6 @@ class GlobalNameUtilsTest extends MediaWikiUnitTestCase {
|
|||
* @param string $name The name of a filter
|
||||
* @param array|null $expected If array, the expected result like [ id, isGlobal ].
|
||||
* If null it means that we're expecting an exception.
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\GlobalNameUtils::splitGlobalName
|
||||
* @dataProvider provideGlobalNames
|
||||
*/
|
||||
public function testSplitGlobalName( $name, $expected ) {
|
||||
|
@ -68,11 +66,6 @@ class GlobalNameUtilsTest extends MediaWikiUnitTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testSplitGlobalName
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function provideGlobalNames() {
|
||||
return [
|
||||
[ '15', [ 15, false ] ],
|
||||
|
|
|
@ -10,8 +10,7 @@ use MediaWiki\User\UserIdentityValue;
|
|||
use MediaWikiUnitTestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Hooks\Handlers\AutoPromoteGroupsHandler
|
||||
* @covers ::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Hooks\Handlers\AutoPromoteGroupsHandler
|
||||
*/
|
||||
class AutoPromoteGroupsHandlerTest extends MediaWikiUnitTestCase {
|
||||
|
||||
|
@ -31,7 +30,6 @@ class AutoPromoteGroupsHandlerTest extends MediaWikiUnitTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers ::onGetAutoPromoteGroups
|
||||
* @dataProvider provideOnGetAutoPromoteGroups_nothingToDo
|
||||
*/
|
||||
public function testOnGetAutoPromoteGroups_nothingToDo( bool $enabled, array $groups ) {
|
||||
|
@ -56,7 +54,6 @@ class AutoPromoteGroupsHandlerTest extends MediaWikiUnitTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers ::onGetAutoPromoteGroups
|
||||
* @dataProvider provideOnGetAutoPromoteGroups
|
||||
*/
|
||||
public function testOnGetAutoPromoteGroups_cacheHit(
|
||||
|
@ -76,7 +73,6 @@ class AutoPromoteGroupsHandlerTest extends MediaWikiUnitTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers ::onGetAutoPromoteGroups
|
||||
* @dataProvider provideOnGetAutoPromoteGroups
|
||||
*/
|
||||
public function testOnGetAutoPromoteGroups_cacheMiss(
|
||||
|
|
|
@ -7,14 +7,10 @@ use MediaWiki\Extension\AbuseFilter\Hooks\Handlers\ChangeTagsHandler;
|
|||
use MediaWikiUnitTestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Hooks\Handlers\ChangeTagsHandler
|
||||
* @covers ::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Hooks\Handlers\ChangeTagsHandler
|
||||
*/
|
||||
class ChangeTagsHandlerTest extends MediaWikiUnitTestCase {
|
||||
|
||||
/**
|
||||
* @covers ::onListDefinedTags
|
||||
*/
|
||||
public function testOnListDefinedTags() {
|
||||
$condsLimitTag = 'conds-limit';
|
||||
$filtersTags = [ 'foo', 'bar' ];
|
||||
|
@ -27,9 +23,6 @@ class ChangeTagsHandlerTest extends MediaWikiUnitTestCase {
|
|||
$this->assertArrayEquals( [ ...$initial, $condsLimitTag, ...$filtersTags ], $tags );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::onChangeTagsListActive
|
||||
*/
|
||||
public function testOnChangeTagsListActive() {
|
||||
$condsLimitTag = 'conds-limit';
|
||||
$activeFiltersTags = [ 'foo', 'bar' ];
|
||||
|
|
|
@ -14,8 +14,7 @@ use MediaWikiUnitTestCase;
|
|||
use Message;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Hooks\Handlers\ToolLinksHandler
|
||||
* @covers ::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Hooks\Handlers\ToolLinksHandler
|
||||
*/
|
||||
class ToolLinksHandlerTest extends MediaWikiUnitTestCase {
|
||||
|
||||
|
@ -25,9 +24,6 @@ class ToolLinksHandlerTest extends MediaWikiUnitTestCase {
|
|||
return new ToolLinksHandler( $permManager );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::onContributionsToolLinks
|
||||
*/
|
||||
public function testOnContributionsToolLinks() {
|
||||
$handler = $this->getToolLinksHandler();
|
||||
$sp = $this->createMock( SpecialPage::class );
|
||||
|
@ -40,9 +36,6 @@ class ToolLinksHandlerTest extends MediaWikiUnitTestCase {
|
|||
$this->assertArrayHasKey( 'abuselog', $tools );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::onContributionsToolLinks
|
||||
*/
|
||||
public function testOnContributionsToolLinks_notAllowed() {
|
||||
$handler = $this->getToolLinksHandler( false );
|
||||
$sp = $this->createMock( SpecialPage::class );
|
||||
|
@ -57,9 +50,6 @@ class ToolLinksHandlerTest extends MediaWikiUnitTestCase {
|
|||
$this->assertCount( 0, $tools );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::onContributionsToolLinks
|
||||
*/
|
||||
public function testOnContributionsToolLinks_range() {
|
||||
$handler = $this->getToolLinksHandler();
|
||||
$sp = $this->createMock( SpecialPage::class );
|
||||
|
@ -71,9 +61,6 @@ class ToolLinksHandlerTest extends MediaWikiUnitTestCase {
|
|||
$this->assertCount( 0, $tools );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::onHistoryPageToolLinks
|
||||
*/
|
||||
public function testOnHistoryPageToolLinks() {
|
||||
$handler = $this->getToolLinksHandler();
|
||||
$ctx = $this->createMock( IContextSource::class );
|
||||
|
@ -85,9 +72,6 @@ class ToolLinksHandlerTest extends MediaWikiUnitTestCase {
|
|||
$this->assertCount( 1, $links );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::onHistoryPageToolLinks
|
||||
*/
|
||||
public function testOnHistoryPageToolLinks_notAllowed() {
|
||||
$handler = $this->getToolLinksHandler( false );
|
||||
$ctx = $this->createMock( IContextSource::class );
|
||||
|
@ -97,9 +81,6 @@ class ToolLinksHandlerTest extends MediaWikiUnitTestCase {
|
|||
$this->assertCount( 0, $links );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::onUndeletePageToolLinks
|
||||
*/
|
||||
public function testOnUndeletePageToolLinks() {
|
||||
$handler = $this->getToolLinksHandler();
|
||||
$ctx = $this->createMock( IContextSource::class );
|
||||
|
@ -114,9 +95,6 @@ class ToolLinksHandlerTest extends MediaWikiUnitTestCase {
|
|||
$this->assertCount( 1, $links );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::onUndeletePageToolLinks
|
||||
*/
|
||||
public function testOnUndeletePageToolLinks_notAllowed() {
|
||||
$handler = $this->getToolLinksHandler( false );
|
||||
$ctx = $this->createMock( IContextSource::class );
|
||||
|
@ -129,9 +107,6 @@ class ToolLinksHandlerTest extends MediaWikiUnitTestCase {
|
|||
$this->assertCount( 0, $links );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::onUndeletePageToolLinks
|
||||
*/
|
||||
public function testOnUndeletePageToolLinks_historyAction() {
|
||||
$handler = $this->getToolLinksHandler();
|
||||
$ctx = $this->createMock( IContextSource::class );
|
||||
|
|
|
@ -10,8 +10,7 @@ use MediaWikiUnitTestCase;
|
|||
* @group Test
|
||||
* @group AbuseFilter
|
||||
* @group AbuseFilterParser
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\KeywordsManager
|
||||
* @covers ::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\KeywordsManager
|
||||
*/
|
||||
class KeywordsManagerTest extends MediaWikiUnitTestCase {
|
||||
/**
|
||||
|
@ -22,9 +21,6 @@ class KeywordsManagerTest extends MediaWikiUnitTestCase {
|
|||
return new KeywordsManager( $this->createMock( AbuseFilterHookRunner::class ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getDisabledVariables
|
||||
*/
|
||||
public function testGetDisabledVariables() {
|
||||
$actual = $this->getKeywordsManager()->getDisabledVariables();
|
||||
// Value should be an associative array mapping var names to i18n strings
|
||||
|
@ -33,9 +29,6 @@ class KeywordsManagerTest extends MediaWikiUnitTestCase {
|
|||
$this->assertContainsOnly( 'string', array_keys( $actual ), true );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getDeprecatedVariables
|
||||
*/
|
||||
public function testGetDeprecatedVariables() {
|
||||
$actual = $this->getKeywordsManager()->getDisabledVariables();
|
||||
// Value should be an associative array mapping old names to new names
|
||||
|
@ -44,9 +37,6 @@ class KeywordsManagerTest extends MediaWikiUnitTestCase {
|
|||
$this->assertContainsOnly( 'string', array_keys( $actual ), true );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getDeprecatedVariables
|
||||
*/
|
||||
public function testGetDeprecatedVariables_hook() {
|
||||
$oldVarName = 'foobardeprecated';
|
||||
$newVarName = 'foobarpleaseuseme';
|
||||
|
@ -60,9 +50,6 @@ class KeywordsManagerTest extends MediaWikiUnitTestCase {
|
|||
$this->assertSame( $newVarName, $actual[$oldVarName] );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getBuilderValues
|
||||
*/
|
||||
public function testGetBuilderValues() {
|
||||
$actual = $this->getKeywordsManager()->getBuilderValues();
|
||||
// Value should be an associative array mapping old names to new names
|
||||
|
@ -75,9 +62,6 @@ class KeywordsManagerTest extends MediaWikiUnitTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getBuilderValues
|
||||
*/
|
||||
public function testGetBuilderValues_hook() {
|
||||
$varName = 'magic_stuff';
|
||||
$varMessage = 'magic-stuff';
|
||||
|
@ -95,7 +79,6 @@ class KeywordsManagerTest extends MediaWikiUnitTestCase {
|
|||
/**
|
||||
* @param string $varName
|
||||
* @param bool $expected
|
||||
* @covers ::isVarDisabled
|
||||
* @dataProvider provideIsVarDisabled
|
||||
*/
|
||||
public function testIsVarDisabled( string $varName, bool $expected ) {
|
||||
|
@ -117,7 +100,6 @@ class KeywordsManagerTest extends MediaWikiUnitTestCase {
|
|||
/**
|
||||
* @param string $varName
|
||||
* @param bool $expected
|
||||
* @covers ::isVarDeprecated
|
||||
* @dataProvider provideIsVarDeprecated
|
||||
*/
|
||||
public function testIsVarDeprecated( string $varName, bool $expected ) {
|
||||
|
@ -136,9 +118,6 @@ class KeywordsManagerTest extends MediaWikiUnitTestCase {
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::isVarInUse
|
||||
*/
|
||||
public function testIsVarInUse() {
|
||||
// Add a new variable to avoid relying on what's currently valid
|
||||
$varName = 'my_new_var';
|
||||
|
@ -154,7 +133,6 @@ class KeywordsManagerTest extends MediaWikiUnitTestCase {
|
|||
/**
|
||||
* @param string $varName
|
||||
* @param bool $expected
|
||||
* @covers ::varExists
|
||||
* @dataProvider provideVarExists
|
||||
*/
|
||||
public function testVarExists( string $varName, bool $expected ) {
|
||||
|
@ -165,7 +143,6 @@ class KeywordsManagerTest extends MediaWikiUnitTestCase {
|
|||
/**
|
||||
* @param string $varName
|
||||
* @param bool $exists
|
||||
* @covers ::getMessageKeyForVar
|
||||
* @dataProvider provideVarExists
|
||||
*/
|
||||
public function testGetMessageKeyForVar( string $varName, bool $exists ) {
|
||||
|
@ -190,9 +167,6 @@ class KeywordsManagerTest extends MediaWikiUnitTestCase {
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getVarsMappings
|
||||
*/
|
||||
public function testGetVarsMappings() {
|
||||
$actual = $this->getKeywordsManager()->getVarsMappings();
|
||||
// Value should be an associative array mapping var names to i18n strings
|
||||
|
@ -201,9 +175,6 @@ class KeywordsManagerTest extends MediaWikiUnitTestCase {
|
|||
$this->assertContainsOnly( 'string', array_keys( $actual ), true );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getCoreVariables
|
||||
*/
|
||||
public function testGetCoreVariables() {
|
||||
$actual = $this->getKeywordsManager()->getCoreVariables();
|
||||
$this->assertIsArray( $actual );
|
||||
|
|
|
@ -30,12 +30,12 @@ use MediaWiki\Extension\AbuseFilter\Parser\Exception\InternalException;
|
|||
* @group Test
|
||||
* @group AbuseFilter
|
||||
* @group AbuseFilterParser
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Parser\AFPData
|
||||
*/
|
||||
class AFPDataTest extends ParserTestCase {
|
||||
/**
|
||||
* @param string $expr The expression to test
|
||||
* @param string $caller The function where the exception is thrown
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Parser\AFPData::mulRel
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Parser\FilterEvaluator
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Parser\AFPTreeParser
|
||||
*
|
||||
|
@ -70,7 +70,6 @@ class AFPDataTest extends ParserTestCase {
|
|||
/**
|
||||
* @param mixed $raw
|
||||
* @param AFPData|null $expected If null, we expect an exception due to unsupported data type
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Parser\AFPData::newFromPHPVar
|
||||
* @dataProvider providePHPVars
|
||||
*/
|
||||
public function testNewFromPHPVar( $raw, $expected ) {
|
||||
|
@ -80,11 +79,6 @@ class AFPDataTest extends ParserTestCase {
|
|||
$this->assertEquals( $expected, AFPData::newFromPHPVar( $raw ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testNewFromPHPVar
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function providePHPVars() {
|
||||
return [
|
||||
[ 15, new AFPData( AFPData::DINT, 15 ) ],
|
||||
|
@ -116,7 +110,6 @@ class AFPDataTest extends ParserTestCase {
|
|||
* @param AFPData $orig
|
||||
* @param string $newType One of the AFPData::D* constants
|
||||
* @param AFPData|null $expected If null, we expect an exception due to unsupported data type
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Parser\AFPData::castTypes
|
||||
* @dataProvider provideMissingCastTypes
|
||||
*/
|
||||
public function testMissingCastTypes( $orig, $newType, $expected ) {
|
||||
|
@ -126,11 +119,6 @@ class AFPDataTest extends ParserTestCase {
|
|||
$this->assertEquals( $expected, AFPData::castTypes( $orig, $newType ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testMissingCastTypes
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function provideMissingCastTypes() {
|
||||
return [
|
||||
[ new AFPData( AFPData::DINT, 1 ), AFPData::DNULL, new AFPData( AFPData::DNULL ) ],
|
||||
|
@ -178,18 +166,12 @@ class AFPDataTest extends ParserTestCase {
|
|||
/**
|
||||
* @param AFPData $orig
|
||||
* @param mixed $expected
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Parser\AFPData::toNative
|
||||
* @dataProvider provideToNative
|
||||
*/
|
||||
public function testToNative( $orig, $expected ) {
|
||||
$this->assertEquals( $expected, $orig->toNative() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testToNative
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function provideToNative() {
|
||||
return [
|
||||
[ new AFPData( AFPData::DFLOAT, 1.2345 ), 1.2345 ],
|
||||
|
@ -215,19 +197,12 @@ class AFPDataTest extends ParserTestCase {
|
|||
* @param AFPData $lhs
|
||||
* @param AFPData $rhs
|
||||
* @dataProvider provideDUNDEFINEDEquals
|
||||
*
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Parser\AFPData::equals
|
||||
*/
|
||||
public function testNoDUNDEFINEDEquals( $lhs, $rhs ) {
|
||||
$this->expectException( InternalException::class );
|
||||
$lhs->equals( $rhs );
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testNoDUNDEFINEDEquals
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function provideDUNDEFINEDEquals() {
|
||||
$undefined = new AFPData( AFPData::DUNDEFINED );
|
||||
$nonempty = new AFPData( AFPData::DSTRING, 'foo' );
|
||||
|
@ -240,8 +215,6 @@ class AFPDataTest extends ParserTestCase {
|
|||
|
||||
/**
|
||||
* Test that DUNDEFINED can only have null value
|
||||
*
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Parser\AFPData::__construct
|
||||
*/
|
||||
public function testDUNDEFINEDRequiresNullValue() {
|
||||
$this->expectException( InvalidArgumentException::class );
|
||||
|
@ -250,8 +223,6 @@ class AFPDataTest extends ParserTestCase {
|
|||
|
||||
/**
|
||||
* Test that casting DUNDEFINED to something else is forbidden
|
||||
*
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Parser\AFPData::castTypes
|
||||
*/
|
||||
public function testDUNDEFINEDCannotBeCast() {
|
||||
$data = new AFPData( AFPData::DUNDEFINED );
|
||||
|
@ -263,16 +234,12 @@ class AFPDataTest extends ParserTestCase {
|
|||
/**
|
||||
* @param AFPData $obj
|
||||
* @param bool $expected
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Parser\AFPData::hasUndefined
|
||||
* @dataProvider provideHasUndefined
|
||||
*/
|
||||
public function testHasUndefined( AFPData $obj, bool $expected ) {
|
||||
$this->assertSame( $expected, $obj->hasUndefined() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Provider for testHasUndefined
|
||||
*/
|
||||
public static function provideHasUndefined() {
|
||||
return [
|
||||
[ new AFPData( AFPData::DUNDEFINED ), true ],
|
||||
|
@ -286,16 +253,12 @@ class AFPDataTest extends ParserTestCase {
|
|||
/**
|
||||
* @param AFPData $obj
|
||||
* @param AFPData $expected
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Parser\AFPData::cloneAsUndefinedReplacedWithNull
|
||||
* @dataProvider provideCloneAsUndefinedReplacedWithNull
|
||||
*/
|
||||
public function testCloneAsUndefinedReplacedWithNull( AFPData $obj, AFPData $expected ) {
|
||||
$this->assertEquals( $expected, $obj->cloneAsUndefinedReplacedWithNull() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Provider for testHasUndefined
|
||||
*/
|
||||
public static function provideCloneAsUndefinedReplacedWithNull() {
|
||||
return [
|
||||
[
|
||||
|
|
|
@ -10,14 +10,10 @@ use MediaWikiUnitTestCase;
|
|||
* @group AbuseFilter
|
||||
* @group AbuseFilterParser
|
||||
*
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Parser\Exception\ExceptionBase
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Parser\Exception\ExceptionBase
|
||||
*/
|
||||
class ExceptionBaseTest extends MediaWikiUnitTestCase {
|
||||
|
||||
/**
|
||||
* @covers ::toArray
|
||||
* @covers ::fromArray
|
||||
*/
|
||||
public function testToArrayRoundTrip() {
|
||||
$exc = new InternalException( 'Foo' );
|
||||
$newExc = InternalException::fromArray( $exc->toArray() );
|
||||
|
|
|
@ -10,16 +10,10 @@ use MediaWikiUnitTestCase;
|
|||
* @group AbuseFilter
|
||||
* @group AbuseFilterParser
|
||||
*
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Parser\Exception\UserVisibleException
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Parser\Exception\UserVisibleException
|
||||
*/
|
||||
class UserVisibleExceptionTest extends MediaWikiUnitTestCase {
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getPosition
|
||||
* @covers ::getMessageForLogs
|
||||
* @covers ::getMessageObj
|
||||
*/
|
||||
public function testGetters() {
|
||||
$excID = 'abusefilter-foo';
|
||||
$position = 42;
|
||||
|
@ -33,10 +27,6 @@ class UserVisibleExceptionTest extends MediaWikiUnitTestCase {
|
|||
$this->assertArrayEquals( [ $position, ...$params ], $message->getParams(), 'msg params' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::toArray
|
||||
* @covers ::fromArray
|
||||
*/
|
||||
public function testToArrayRoundTrip() {
|
||||
$exc = new UserVisibleException( 'abusefilter-foo', 42, [ 'foo' ] );
|
||||
$newExc = UserVisibleException::fromArray( $exc->toArray() );
|
||||
|
|
|
@ -10,13 +10,10 @@ use MediaWikiUnitTestCase;
|
|||
* @group AbuseFilter
|
||||
* @group AbuseFilterParser
|
||||
*
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Parser\Exception\UserVisibleWarning
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Parser\Exception\UserVisibleWarning
|
||||
*/
|
||||
class UserVisibleWarningTest extends MediaWikiUnitTestCase {
|
||||
|
||||
/**
|
||||
* @covers ::getMessageObj
|
||||
*/
|
||||
public function testGetMessageObj() {
|
||||
$excID = 'abusefilter-foo';
|
||||
$position = 42;
|
||||
|
|
|
@ -12,16 +12,10 @@ use MediaWikiUnitTestCase;
|
|||
* @group AbuseFilter
|
||||
* @group AbuseFilterParser
|
||||
*
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Parser\ParserStatus
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Parser\ParserStatus
|
||||
*/
|
||||
class ParserStatusTest extends MediaWikiUnitTestCase {
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getException
|
||||
* @covers ::getWarnings
|
||||
* @covers ::getCondsUsed
|
||||
*/
|
||||
public function testGetters() {
|
||||
$exc = $this->createMock( UserVisibleException::class );
|
||||
$warnings = [ new UserVisibleWarning( 'foo', 1, [] ) ];
|
||||
|
@ -32,17 +26,11 @@ class ParserStatusTest extends MediaWikiUnitTestCase {
|
|||
$this->assertSame( $condsUsed, $status->getCondsUsed() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::isValid
|
||||
*/
|
||||
public function testIsValid_true() {
|
||||
$status = new ParserStatus( null, [], 42 );
|
||||
$this->assertTrue( $status->isValid() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::isValid
|
||||
*/
|
||||
public function testIsValid_false() {
|
||||
$status = new ParserStatus( $this->createMock( UserVisibleException::class ), [], 42 );
|
||||
$this->assertFalse( $status->isValid() );
|
||||
|
|
|
@ -110,11 +110,6 @@ class ParserTest extends ParserTestCase {
|
|||
$this->assertFalse( $this->getParser()->parse( $code ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testEmptySyntax
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function provideEmptySyntax() {
|
||||
return [
|
||||
[ '' ],
|
||||
|
@ -158,10 +153,6 @@ class ParserTest extends ParserTestCase {
|
|||
$this->assertEquals( $expected, $this->getParser()->checkConditions( $rule )->getCondsUsed(), "Rule: $rule" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testCondCount method.
|
||||
* @return array
|
||||
*/
|
||||
public static function condCountCases() {
|
||||
return [
|
||||
[ '((("a" == "b")))', 1 ],
|
||||
|
@ -777,8 +768,8 @@ class ParserTest extends ParserTestCase {
|
|||
* @param string $new The new name of the variable
|
||||
* @dataProvider provideDeprecatedVars
|
||||
*
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Parser\FilterEvaluator::getVarValue
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Parser\AFPTreeParser::checkLogDeprecatedVar
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Parser\FilterEvaluator
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Parser\AFPTreeParser
|
||||
*/
|
||||
public function testDeprecatedVars( $old, $new ) {
|
||||
// Set it under the new name, and check that the old name points to it
|
||||
|
@ -1120,9 +1111,6 @@ class ParserTest extends ParserTestCase {
|
|||
$this->exceptionTestInSkippedBlock( $expID, $code, $caller );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function provideArgsErrorsInSyntaxCheck() {
|
||||
return [
|
||||
[ 'accountname rlike "("', 'regexfailure' ],
|
||||
|
@ -1149,7 +1137,7 @@ class ParserTest extends ParserTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Parser\FilterEvaluator::toggleConditionLimit
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Parser\FilterEvaluator
|
||||
*/
|
||||
public function testToggleConditionLimit() {
|
||||
/** @var FilterEvaluator $wrapper */
|
||||
|
@ -1164,7 +1152,7 @@ class ParserTest extends ParserTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Parser\FilterEvaluator::setVariables
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Parser\FilterEvaluator
|
||||
*/
|
||||
public function testSetVariables() {
|
||||
$parser = $this->getParser();
|
||||
|
|
|
@ -18,13 +18,9 @@ use Wikimedia\Equivset\Equivset;
|
|||
* @group AbuseFilter
|
||||
* @group AbuseFilterParser
|
||||
*
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Parser\RuleCheckerFactory
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Parser\RuleCheckerFactory
|
||||
*/
|
||||
class RuleCheckerFactoryTest extends MediaWikiUnitTestCase {
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::newRuleChecker
|
||||
*/
|
||||
public function testNewRuleChecker() {
|
||||
$factory = new RuleCheckerFactory(
|
||||
$this->createMock( Language::class ),
|
||||
|
|
|
@ -14,18 +14,10 @@ use MediaWikiUnitTestCase;
|
|||
* @group AbuseFilter
|
||||
* @group AbuseFilterParser
|
||||
*
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Parser\RuleCheckerStatus
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Parser\RuleCheckerStatus
|
||||
*/
|
||||
class RuleCheckerStatusTest extends MediaWikiUnitTestCase {
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getResult
|
||||
* @covers ::getWarmCache
|
||||
* @covers ::getException
|
||||
* @covers ::getWarnings
|
||||
* @covers ::getCondsUsed
|
||||
*/
|
||||
public function testGetters() {
|
||||
$result = true;
|
||||
$warm = false;
|
||||
|
@ -47,8 +39,6 @@ class RuleCheckerStatusTest extends MediaWikiUnitTestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider provideToArrayException
|
||||
* @covers ::toArray
|
||||
* @covers ::fromArray
|
||||
*/
|
||||
public function testToArrayRoundTrip( ?ExceptionBase $exception ) {
|
||||
$status = new RuleCheckerStatus(
|
||||
|
|
|
@ -29,12 +29,12 @@ use MediaWiki\Extension\AbuseFilter\Parser\AbuseFilterTokenizer;
|
|||
* @group Test
|
||||
* @group AbuseFilter
|
||||
* @group AbuseFilterParser
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Parser\AbuseFilterTokenizer
|
||||
*/
|
||||
class TokenizerTest extends ParserTestCase {
|
||||
/**
|
||||
* @param string $expr The expression to test
|
||||
* @param string $caller The function where the exception is thrown
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Parser\AbuseFilterTokenizer
|
||||
* @dataProvider unclosedComment
|
||||
*/
|
||||
public function testUnclosedCommentException( $expr, $caller ) {
|
||||
|
@ -57,7 +57,6 @@ class TokenizerTest extends ParserTestCase {
|
|||
/**
|
||||
* @param string $expr The expression to test
|
||||
* @param string $caller The function where the exception is thrown
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Parser\AbuseFilterTokenizer
|
||||
* @dataProvider unrecognisedToken
|
||||
*/
|
||||
public function testUnrecognisedTokenException( $expr, $caller ) {
|
||||
|
@ -80,7 +79,6 @@ class TokenizerTest extends ParserTestCase {
|
|||
/**
|
||||
* @param string $expr The expression to test
|
||||
* @param string $caller The function where the exception is thrown
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Parser\AbuseFilterTokenizer
|
||||
* @dataProvider unclosedString
|
||||
*/
|
||||
public function testUnclosedStringException( $expr, $caller ) {
|
||||
|
@ -105,7 +103,6 @@ class TokenizerTest extends ParserTestCase {
|
|||
*
|
||||
* @param string $code To be tokenized
|
||||
* @dataProvider provideCode
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Parser\AbuseFilterTokenizer::getTokens
|
||||
*/
|
||||
public function testCaching( $code ) {
|
||||
$cache = new HashBagOStuff();
|
||||
|
@ -117,11 +114,6 @@ class TokenizerTest extends ParserTestCase {
|
|||
$this->assertNotFalse( $cache->get( $key ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testCaching
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function provideCode() {
|
||||
return [
|
||||
[ '1 === 1' ],
|
||||
|
|
|
@ -9,17 +9,10 @@ use MediaWiki\Extension\AbuseFilter\RunnerData;
|
|||
use MediaWikiUnitTestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\RunnerData
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\RunnerData
|
||||
*/
|
||||
class RunnerDataTest extends MediaWikiUnitTestCase {
|
||||
|
||||
/**
|
||||
* @covers ::__construct()
|
||||
* @covers ::getMatchesMap
|
||||
* @covers ::getProfilingData
|
||||
* @covers ::getTotalRuntime
|
||||
* @covers ::getTotalConditions
|
||||
*/
|
||||
public function testRunnerData_empty() {
|
||||
$runnerData = new RunnerData();
|
||||
$this->assertSame( [], $runnerData->getMatchesMap() );
|
||||
|
@ -28,13 +21,6 @@ class RunnerDataTest extends MediaWikiUnitTestCase {
|
|||
$this->assertSame( 0.0, $runnerData->getTotalRuntime() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::record
|
||||
* @covers ::getMatchesMap
|
||||
* @covers ::getProfilingData
|
||||
* @covers ::getTotalRuntime
|
||||
* @covers ::getTotalConditions
|
||||
*/
|
||||
public function testRecord() {
|
||||
$runnerData = new RunnerData();
|
||||
$runnerData->record(
|
||||
|
@ -67,9 +53,6 @@ class RunnerDataTest extends MediaWikiUnitTestCase {
|
|||
$this->assertSame( 35.7, $runnerData->getTotalRuntime() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::record
|
||||
*/
|
||||
public function testRecord_throwsOnSameFilter() {
|
||||
$runnerData = new RunnerData();
|
||||
$runnerData->record(
|
||||
|
@ -85,11 +68,6 @@ class RunnerDataTest extends MediaWikiUnitTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::toArray
|
||||
* @covers ::fromArray
|
||||
*/
|
||||
public function testToArrayRoundTrip() {
|
||||
$runnerData = new RunnerData();
|
||||
$runnerData->record(
|
||||
|
@ -115,10 +93,6 @@ class RunnerDataTest extends MediaWikiUnitTestCase {
|
|||
$this->assertSame( $runnerData->getMatchesMap(), $newData->getMatchesMap() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getAllFilters
|
||||
* @covers ::getMatchedFilters
|
||||
*/
|
||||
public function testGetAllAndMatchedFilters() {
|
||||
$runnerData = new RunnerData();
|
||||
$runnerData->record(
|
||||
|
|
|
@ -17,12 +17,11 @@ use MediaWikiUnitTestCase;
|
|||
use Wikimedia\ObjectFactory\ObjectFactory;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Special\SpecialAbuseFilter
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Special\SpecialAbuseFilter
|
||||
*/
|
||||
class SpecialAbuseFilterTest extends MediaWikiUnitTestCase {
|
||||
|
||||
/**
|
||||
* @covers ::getViewClassAndPageType
|
||||
* @dataProvider provideGetViewClassAndPageType
|
||||
*/
|
||||
public function testGetViewClassAndPageType( $subpage, $view, $pageType, $params = [] ) {
|
||||
|
|
|
@ -20,8 +20,7 @@ use WikitextContent;
|
|||
/**
|
||||
* @group Test
|
||||
* @group AbuseFilter
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\TextExtractor
|
||||
* @covers ::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\TextExtractor
|
||||
*/
|
||||
class TextExtractorTest extends MediaWikiUnitTestCase {
|
||||
|
||||
|
@ -29,7 +28,6 @@ class TextExtractorTest extends MediaWikiUnitTestCase {
|
|||
* @param RevisionRecord|null $rev The revision being converted
|
||||
* @param bool $sysop Whether the user should be a sysop (i.e. able to see deleted stuff)
|
||||
* @param string $expected The expected textual representation of the Revision
|
||||
* @covers ::revisionToString
|
||||
* @dataProvider provideRevisionToString
|
||||
*/
|
||||
public function testRevisionToString( ?RevisionRecord $rev, bool $sysop, string $expected ) {
|
||||
|
@ -81,7 +79,6 @@ class TextExtractorTest extends MediaWikiUnitTestCase {
|
|||
/**
|
||||
* @param Content $content
|
||||
* @param string $expected
|
||||
* @covers ::contentToString
|
||||
* @dataProvider provideContentToString
|
||||
*/
|
||||
public function testContentToString( Content $content, string $expected ) {
|
||||
|
@ -100,9 +97,6 @@ class TextExtractorTest extends MediaWikiUnitTestCase {
|
|||
yield 'non-text' => [ new DummyNonTextContent( $text ), '' ];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::contentToString
|
||||
*/
|
||||
public function testContentToString__hook() {
|
||||
$expected = 'Text changed by hook';
|
||||
$hookCb = static function ( Content $content, ?string &$text ) use ( $expected ) {
|
||||
|
|
|
@ -19,8 +19,7 @@ use RepoGroup;
|
|||
* @group Test
|
||||
* @group AbuseFilter
|
||||
*
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\VariableGenerator\VariableGeneratorFactory
|
||||
* @covers ::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\VariableGenerator\VariableGeneratorFactory
|
||||
*/
|
||||
class VariableGeneratorFactoryTest extends MediaWikiUnitTestCase {
|
||||
private function getFactory(): VariableGeneratorFactory {
|
||||
|
@ -34,17 +33,11 @@ class VariableGeneratorFactoryTest extends MediaWikiUnitTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::newGenerator
|
||||
*/
|
||||
public function testNewGenerator() {
|
||||
$this->getFactory()->newGenerator( new VariableHolder() );
|
||||
$this->addToAssertionCount( 1 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::newRunGenerator
|
||||
*/
|
||||
public function testNewRunGenerator() {
|
||||
$this->getFactory()->newRunGenerator(
|
||||
$this->createMock( User::class ),
|
||||
|
@ -54,9 +47,6 @@ class VariableGeneratorFactoryTest extends MediaWikiUnitTestCase {
|
|||
$this->addToAssertionCount( 1 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::newRCGenerator
|
||||
*/
|
||||
public function testNewRCGenerator() {
|
||||
$this->getFactory()->newRCGenerator(
|
||||
$this->createMock( RecentChange::class ),
|
||||
|
|
|
@ -20,13 +20,9 @@ use WikiPage;
|
|||
* @group AbuseFilter
|
||||
* @group AbuseFilterGeneric
|
||||
*
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\VariableGenerator\VariableGenerator
|
||||
* @covers ::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\VariableGenerator\VariableGenerator
|
||||
*/
|
||||
class VariableGeneratorTest extends MediaWikiUnitTestCase {
|
||||
/**
|
||||
* @covers ::getVariableHolder
|
||||
*/
|
||||
public function testGetVariableHolder() {
|
||||
$holder = new VariableHolder();
|
||||
$generator = new VariableGenerator(
|
||||
|
@ -37,9 +33,6 @@ class VariableGeneratorTest extends MediaWikiUnitTestCase {
|
|||
$this->assertSame( $holder, $generator->getVariableHolder() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::addUserVars
|
||||
*/
|
||||
public function testAddUserVars() {
|
||||
$user = $this->createMock( User::class );
|
||||
$userName = 'Some user';
|
||||
|
@ -75,7 +68,6 @@ class VariableGeneratorTest extends MediaWikiUnitTestCase {
|
|||
* @param string $prefix
|
||||
* @param Title $title
|
||||
* @param array $expected
|
||||
* @covers ::addTitleVars
|
||||
* @dataProvider provideTitleVarsNotLazy
|
||||
*/
|
||||
public function testAddTitleVars_notLazy( string $prefix, Title $title, array $expected ) {
|
||||
|
@ -118,7 +110,6 @@ class VariableGeneratorTest extends MediaWikiUnitTestCase {
|
|||
/**
|
||||
* @param string $prefix
|
||||
* @param array $expectedKeys
|
||||
* @covers ::addTitleVars
|
||||
* @dataProvider provideTitleVarsLazy
|
||||
*/
|
||||
public function testAddTitleVars_lazy( string $prefix, array $expectedKeys ) {
|
||||
|
@ -153,9 +144,6 @@ class VariableGeneratorTest extends MediaWikiUnitTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::addGenericVars
|
||||
*/
|
||||
public function testAddGenericVars() {
|
||||
$expectedKeys = [
|
||||
'timestamp',
|
||||
|
@ -177,8 +165,6 @@ class VariableGeneratorTest extends MediaWikiUnitTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers ::addEditVars
|
||||
* @covers ::addDerivedEditVars
|
||||
* @dataProvider provideForFilter
|
||||
*/
|
||||
public function testAddEditVars( bool $forFilter ) {
|
||||
|
|
|
@ -8,14 +8,9 @@ use MediaWikiUnitTestCase;
|
|||
/**
|
||||
* @group Test
|
||||
* @group AbuseFilter
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Variables\LazyLoadedVariable
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Variables\LazyLoadedVariable
|
||||
*/
|
||||
class LazyLoadedVariableTest extends MediaWikiUnitTestCase {
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getMethod
|
||||
* @covers ::getParameters
|
||||
*/
|
||||
public function testGetters() {
|
||||
$method = 'magic';
|
||||
$params = [ 'foo', true, 1, null ];
|
||||
|
|
|
@ -31,8 +31,7 @@ use WANObjectCache;
|
|||
use Wikimedia\Rdbms\LBFactory;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Variables\LazyVariableComputer
|
||||
* @covers ::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Variables\LazyVariableComputer
|
||||
*/
|
||||
class LazyVariableComputerTest extends MediaWikiUnitTestCase {
|
||||
|
||||
|
@ -66,9 +65,6 @@ class LazyVariableComputerTest extends MediaWikiUnitTestCase {
|
|||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::compute
|
||||
*/
|
||||
public function testWikiNameVar() {
|
||||
$fakeID = 'some-wiki-ID';
|
||||
$var = new LazyLoadedVariable( 'get-wiki-name', [] );
|
||||
|
@ -79,9 +75,6 @@ class LazyVariableComputerTest extends MediaWikiUnitTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::compute
|
||||
*/
|
||||
public function testWikiLanguageVar() {
|
||||
$fakeCode = 'foobar';
|
||||
$fakeLang = $this->createMock( Language::class );
|
||||
|
@ -94,9 +87,6 @@ class LazyVariableComputerTest extends MediaWikiUnitTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::compute
|
||||
*/
|
||||
public function testCompute_invalidName() {
|
||||
$computer = $this->getComputer();
|
||||
$this->expectException( UnexpectedValueException::class );
|
||||
|
@ -107,9 +97,6 @@ class LazyVariableComputerTest extends MediaWikiUnitTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::compute
|
||||
*/
|
||||
public function testInterceptVariableHook() {
|
||||
$expected = new AFPData( AFPData::DSTRING, 'foobar' );
|
||||
$handler = static function ( $method, $vars, $params, &$result ) use ( $expected ) {
|
||||
|
@ -125,9 +112,6 @@ class LazyVariableComputerTest extends MediaWikiUnitTestCase {
|
|||
$this->assertSame( $expected, $actual );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::compute
|
||||
*/
|
||||
public function testComputeVariableHook() {
|
||||
$expected = new AFPData( AFPData::DSTRING, 'foobar' );
|
||||
$handler = static function ( $method, $vars, $params, &$result ) use ( $expected ) {
|
||||
|
@ -147,7 +131,6 @@ class LazyVariableComputerTest extends MediaWikiUnitTestCase {
|
|||
* @param LazyLoadedVariable $var
|
||||
* @param mixed $expected
|
||||
* @param array $services
|
||||
* @covers ::compute
|
||||
* @dataProvider provideUserRelatedVars
|
||||
*/
|
||||
public function testUserRelatedVars(
|
||||
|
@ -263,7 +246,6 @@ class LazyVariableComputerTest extends MediaWikiUnitTestCase {
|
|||
* @param LazyLoadedVariable $var
|
||||
* @param mixed $expected
|
||||
* @param array $services
|
||||
* @covers ::compute
|
||||
* @dataProvider provideTitleRelatedVars
|
||||
*/
|
||||
public function testTitleRelatedVars(
|
||||
|
|
|
@ -32,12 +32,9 @@ use MediaWikiUnitTestCase;
|
|||
* @group Test
|
||||
* @group AbuseFilter
|
||||
* @group AbuseFilterParser
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Variables\VariableHolder
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Variables\VariableHolder
|
||||
*/
|
||||
class VariableHolderTest extends MediaWikiUnitTestCase {
|
||||
/**
|
||||
* @covers ::newFromArray
|
||||
*/
|
||||
public function testNewFromArray() {
|
||||
$vars = [
|
||||
'foo' => 12,
|
||||
|
@ -53,9 +50,6 @@ class VariableHolderTest extends MediaWikiUnitTestCase {
|
|||
$this->assertEquals( $expected, $actual );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::setVar
|
||||
*/
|
||||
public function testVarsAreLowercased() {
|
||||
$vars = new VariableHolder();
|
||||
$this->assertCount( 0, $vars->getVars(), 'precondition' );
|
||||
|
@ -71,7 +65,6 @@ class VariableHolderTest extends MediaWikiUnitTestCase {
|
|||
*
|
||||
* @dataProvider provideSetVar
|
||||
*
|
||||
* @covers ::setVar
|
||||
*/
|
||||
public function testSetVar( string $name, $val, $expected ) {
|
||||
$vars = new VariableHolder();
|
||||
|
@ -89,9 +82,6 @@ class VariableHolderTest extends MediaWikiUnitTestCase {
|
|||
yield 'lazy-loaded' => [ 'foo', $lazyloadVar, $lazyloadVar ];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getVars
|
||||
*/
|
||||
public function testGetVars() {
|
||||
$vars = new VariableHolder();
|
||||
$this->assertSame( [], $vars->getVars(), 'precondition' );
|
||||
|
@ -110,7 +100,6 @@ class VariableHolderTest extends MediaWikiUnitTestCase {
|
|||
* @param VariableHolder $vars
|
||||
* @param string $name
|
||||
* @param AFPData|LazyLoadedVariable $expected
|
||||
* @covers ::getVarThrow
|
||||
*
|
||||
* @dataProvider provideGetVarThrow
|
||||
*/
|
||||
|
@ -132,9 +121,6 @@ class VariableHolderTest extends MediaWikiUnitTestCase {
|
|||
yield 'set, AFPData' => [ $vars, $name, $afpd ];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getVarThrow
|
||||
*/
|
||||
public function testGetVarThrow_unset() {
|
||||
$vars = new VariableHolder();
|
||||
$this->expectException( UnsetVariableException::class );
|
||||
|
@ -146,7 +132,6 @@ class VariableHolderTest extends MediaWikiUnitTestCase {
|
|||
* @param VariableHolder ...$holders
|
||||
* @dataProvider provideHoldersForAddition
|
||||
*
|
||||
* @covers ::addHolders
|
||||
*/
|
||||
public function testAddHolders( array $expected, VariableHolder ...$holders ) {
|
||||
$actual = new VariableHolder();
|
||||
|
@ -170,9 +155,6 @@ class VariableHolderTest extends MediaWikiUnitTestCase {
|
|||
return [ [ $expected, $v1, $v2, $v3 ] ];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::varIsSet
|
||||
*/
|
||||
public function testVarIsSet() {
|
||||
$vars = new VariableHolder();
|
||||
$vars->setVar( 'foo', null );
|
||||
|
@ -180,9 +162,6 @@ class VariableHolderTest extends MediaWikiUnitTestCase {
|
|||
$this->assertFalse( $vars->varIsSet( 'foobarbaz' ), 'Unset variable should be unset' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::setLazyLoadVar
|
||||
*/
|
||||
public function testLazyLoader() {
|
||||
$var = 'foobar';
|
||||
$method = 'compute-foo';
|
||||
|
@ -194,9 +173,6 @@ class VariableHolderTest extends MediaWikiUnitTestCase {
|
|||
$this->assertEquals( $exp, $vars->getVars()[$var] );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::removeVar
|
||||
*/
|
||||
public function testRemoveVar() {
|
||||
$vars = new VariableHolder();
|
||||
$varName = 'foo';
|
||||
|
|
|
@ -17,8 +17,7 @@ use Wikimedia\TestingAccessWrapper;
|
|||
/**
|
||||
* @group Test
|
||||
* @group AbuseFilter
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Variables\VariablesBlobStore
|
||||
* @covers ::__construct
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Variables\VariablesBlobStore
|
||||
*/
|
||||
class VariablesBlobStoreTest extends MediaWikiUnitTestCase {
|
||||
|
||||
|
@ -53,9 +52,6 @@ class VariablesBlobStoreTest extends MediaWikiUnitTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::storeVarDump
|
||||
*/
|
||||
public function testStoreVarDump() {
|
||||
$expectID = 123456;
|
||||
$blobStore = $this->createMock( BlobStore::class );
|
||||
|
@ -66,9 +62,6 @@ class VariablesBlobStoreTest extends MediaWikiUnitTestCase {
|
|||
$this->assertSame( $expectID, $varBlobStore->storeVarDump( new VariableHolder() ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::loadVarDump
|
||||
*/
|
||||
public function testLoadVarDump() {
|
||||
$vars = [ 'foo-variable' => 42 ];
|
||||
$blob = FormatJson::encode( $vars );
|
||||
|
@ -80,9 +73,6 @@ class VariablesBlobStoreTest extends MediaWikiUnitTestCase {
|
|||
$this->assertSame( 42, $loadedVars['foo-variable']->toNative() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::loadVarDump
|
||||
*/
|
||||
public function testLoadVarDump_fail() {
|
||||
$blobStore = $this->createMock( BlobStore::class );
|
||||
$blobStore->expects( $this->once() )->method( 'getBlob' )->willThrowException( new BlobAccessException );
|
||||
|
@ -117,8 +107,6 @@ class VariablesBlobStoreTest extends MediaWikiUnitTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers ::storeVarDump
|
||||
* @covers ::loadVarDump
|
||||
* @dataProvider provideVariables
|
||||
*/
|
||||
public function testRoundTrip( array $toStore, array $expected = null ) {
|
||||
|
|
|
@ -11,12 +11,9 @@ use MessageLocalizer;
|
|||
use Wikimedia\TestingAccessWrapper;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Variables\VariablesFormatter
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Variables\VariablesFormatter
|
||||
*/
|
||||
class VariablesFormatterTest extends MediaWikiUnitTestCase {
|
||||
/**
|
||||
* @covers ::__construct
|
||||
*/
|
||||
public function testConstruct() {
|
||||
$this->assertInstanceOf(
|
||||
VariablesFormatter::class,
|
||||
|
@ -28,9 +25,6 @@ class VariablesFormatterTest extends MediaWikiUnitTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::setMessageLocalizer
|
||||
*/
|
||||
public function testSetMessageLocalizer() {
|
||||
$formatter = new VariablesFormatter(
|
||||
$this->createMock( KeywordsManager::class ),
|
||||
|
@ -47,7 +41,6 @@ class VariablesFormatterTest extends MediaWikiUnitTestCase {
|
|||
/**
|
||||
* @param mixed $var
|
||||
* @param string $expected
|
||||
* @covers ::formatVar
|
||||
* @dataProvider provideFormatVar
|
||||
*/
|
||||
public function testFormatVar( $var, string $expected ) {
|
||||
|
@ -81,9 +74,6 @@ class VariablesFormatterTest extends MediaWikiUnitTestCase {
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::buildVarDumpTable
|
||||
*/
|
||||
public function testBuildVarDumpTable_empty() {
|
||||
$ml = $this->createMock( MessageLocalizer::class );
|
||||
$ml->method( 'msg' )->willReturnCallback( function ( $key ) {
|
||||
|
@ -100,9 +90,6 @@ class VariablesFormatterTest extends MediaWikiUnitTestCase {
|
|||
$this->assertStringNotContainsString( 'mw-abuselog-var-value', $actual, 'no values' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::buildVarDumpTable
|
||||
*/
|
||||
public function testBuildVarDumpTable() {
|
||||
$ml = $this->createMock( MessageLocalizer::class );
|
||||
$ml->method( 'msg' )->willReturnCallback( function ( $key ) {
|
||||
|
|
|
@ -16,7 +16,7 @@ use MediaWikiUnitTestCase;
|
|||
/**
|
||||
* @group Test
|
||||
* @group AbuseFilter
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Variables\VariablesManager
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Variables\VariablesManager
|
||||
*/
|
||||
class VariablesManagerTest extends MediaWikiUnitTestCase {
|
||||
/**
|
||||
|
@ -30,9 +30,6 @@ class VariablesManagerTest extends MediaWikiUnitTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::translateDeprecatedVars
|
||||
*/
|
||||
public function testTranslateDeprecatedVars() {
|
||||
$varsMap = [
|
||||
'timestamp' => new AFPData( AFPData::DSTRING, '123' ),
|
||||
|
@ -59,7 +56,6 @@ class VariablesManagerTest extends MediaWikiUnitTestCase {
|
|||
* @param array $expected
|
||||
* @dataProvider provideDumpAllVars
|
||||
*
|
||||
* @covers ::dumpAllVars
|
||||
*/
|
||||
public function testDumpAllVars(
|
||||
VariableHolder $holder,
|
||||
|
@ -128,9 +124,6 @@ class VariablesManagerTest extends MediaWikiUnitTestCase {
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::computeDBVars
|
||||
*/
|
||||
public function testComputeDBVars() {
|
||||
$nonDBMet = [ 'unknown', 'certainly-not-db' ];
|
||||
$dbMet = [ 'page-age', 'user-age', 'load-recent-authors' ];
|
||||
|
@ -172,7 +165,6 @@ class VariablesManagerTest extends MediaWikiUnitTestCase {
|
|||
* @param string $name
|
||||
* @param int $flags
|
||||
* @param AFPData|string $expected String if expecting an exception
|
||||
* @covers ::getVar
|
||||
*
|
||||
* @dataProvider provideGetVar
|
||||
*/
|
||||
|
@ -245,9 +237,6 @@ class VariablesManagerTest extends MediaWikiUnitTestCase {
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::exportAllVars
|
||||
*/
|
||||
public function testExportAllVars() {
|
||||
$pairs = [
|
||||
'foo' => 42,
|
||||
|
@ -261,9 +250,6 @@ class VariablesManagerTest extends MediaWikiUnitTestCase {
|
|||
$this->assertSame( $pairs, $manager->exportAllVars( $vars ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::exportNonLazyVars
|
||||
*/
|
||||
public function testExportNonLazyVars() {
|
||||
$afcv = $this->createMock( LazyLoadedVariable::class );
|
||||
$pairs = [
|
||||
|
@ -287,9 +273,6 @@ class VariablesManagerTest extends MediaWikiUnitTestCase {
|
|||
$this->assertSame( $nonLazy, $manager->exportNonLazyVars( $vars ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
*/
|
||||
public function testConstruct() {
|
||||
$this->assertInstanceOf(
|
||||
VariablesManager::class,
|
||||
|
|
|
@ -13,7 +13,7 @@ use MediaWikiUnitTestCase;
|
|||
use Wikimedia\Rdbms\LBFactory;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \MediaWiki\Extension\AbuseFilter\Watcher\EmergencyWatcher
|
||||
* @covers \MediaWiki\Extension\AbuseFilter\Watcher\EmergencyWatcher
|
||||
*/
|
||||
class EmergencyWatcherTest extends MediaWikiUnitTestCase {
|
||||
|
||||
|
@ -145,8 +145,6 @@ class EmergencyWatcherTest extends MediaWikiUnitTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers ::getFiltersToThrottle
|
||||
* @covers ::getEmergencyValue
|
||||
* @dataProvider provideFiltersToThrottle
|
||||
*/
|
||||
public function testGetFiltersToThrottle(
|
||||
|
@ -174,9 +172,6 @@ class EmergencyWatcherTest extends MediaWikiUnitTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
*/
|
||||
public function testConstruct() {
|
||||
$watcher = new EmergencyWatcher(
|
||||
$this->createMock( EmergencyCache::class ),
|
||||
|
|
Loading…
Reference in a new issue