mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-23 21:53:35 +00:00
Merge "Use LinkTarget in ConsequencesExecutor"
This commit is contained in:
commit
8d4c5d4d33
|
@ -12,10 +12,10 @@ use MediaWiki\Extension\AbuseFilter\FilterLookup;
|
|||
use MediaWiki\Extension\AbuseFilter\GlobalNameUtils;
|
||||
use MediaWiki\Extension\AbuseFilter\Variables\UnsetVariableException;
|
||||
use MediaWiki\Extension\AbuseFilter\Variables\VariableHolder;
|
||||
use MediaWiki\Linker\LinkTarget;
|
||||
use MediaWiki\User\UserIdentity;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Status;
|
||||
use Title;
|
||||
|
||||
class ConsequencesExecutor {
|
||||
public const CONSTRUCTOR_OPTIONS = [
|
||||
|
@ -39,7 +39,7 @@ class ConsequencesExecutor {
|
|||
private $options;
|
||||
/** @var UserIdentity */
|
||||
private $user;
|
||||
/** @var Title */
|
||||
/** @var LinkTarget */
|
||||
private $title;
|
||||
/** @var VariableHolder */
|
||||
private $vars;
|
||||
|
@ -52,7 +52,7 @@ class ConsequencesExecutor {
|
|||
* @param LoggerInterface $logger
|
||||
* @param ServiceOptions $options
|
||||
* @param UserIdentity $user
|
||||
* @param Title $title
|
||||
* @param LinkTarget $title
|
||||
* @param VariableHolder $vars
|
||||
*/
|
||||
public function __construct(
|
||||
|
@ -63,7 +63,7 @@ class ConsequencesExecutor {
|
|||
LoggerInterface $logger,
|
||||
ServiceOptions $options,
|
||||
UserIdentity $user,
|
||||
Title $title,
|
||||
LinkTarget $title,
|
||||
VariableHolder $vars
|
||||
) {
|
||||
$this->consLookup = $consLookup;
|
||||
|
|
|
@ -5,9 +5,9 @@ namespace MediaWiki\Extension\AbuseFilter\Consequences;
|
|||
use MediaWiki\Config\ServiceOptions;
|
||||
use MediaWiki\Extension\AbuseFilter\FilterLookup;
|
||||
use MediaWiki\Extension\AbuseFilter\Variables\VariableHolder;
|
||||
use MediaWiki\Linker\LinkTarget;
|
||||
use MediaWiki\User\UserIdentity;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Title;
|
||||
|
||||
class ConsequencesExecutorFactory {
|
||||
public const SERVICE_NAME = 'AbuseFilterConsequencesExecutorFactory';
|
||||
|
@ -52,11 +52,11 @@ class ConsequencesExecutorFactory {
|
|||
|
||||
/**
|
||||
* @param UserIdentity $user
|
||||
* @param Title $title
|
||||
* @param LinkTarget $title
|
||||
* @param VariableHolder $vars
|
||||
* @return ConsequencesExecutor
|
||||
*/
|
||||
public function newExecutor( UserIdentity $user, Title $title, VariableHolder $vars ): ConsequencesExecutor {
|
||||
public function newExecutor( UserIdentity $user, LinkTarget $title, VariableHolder $vars ): ConsequencesExecutor {
|
||||
return new ConsequencesExecutor(
|
||||
$this->consLookup,
|
||||
$this->consFactory,
|
||||
|
|
|
@ -9,10 +9,10 @@ use MediaWiki\Extension\AbuseFilter\Consequences\ConsequencesLookup;
|
|||
use MediaWiki\Extension\AbuseFilter\Consequences\ConsequencesRegistry;
|
||||
use MediaWiki\Extension\AbuseFilter\FilterLookup;
|
||||
use MediaWiki\Extension\AbuseFilter\Variables\VariableHolder;
|
||||
use MediaWiki\Linker\LinkTarget;
|
||||
use MediaWiki\User\UserIdentity;
|
||||
use MediaWikiUnitTestCase;
|
||||
use Psr\Log\NullLogger;
|
||||
use Title;
|
||||
|
||||
/**
|
||||
* @group Test
|
||||
|
@ -36,7 +36,7 @@ class ConsequencesExecutorFactoryTest extends MediaWikiUnitTestCase {
|
|||
);
|
||||
$factory->newExecutor(
|
||||
$this->createMock( UserIdentity::class ),
|
||||
$this->createMock( Title::class ),
|
||||
$this->createMock( LinkTarget::class ),
|
||||
new VariableHolder()
|
||||
);
|
||||
$this->addToAssertionCount( 1 );
|
||||
|
|
|
@ -13,11 +13,11 @@ use MediaWiki\Extension\AbuseFilter\Consequences\ConsequencesRegistry;
|
|||
use MediaWiki\Extension\AbuseFilter\Consequences\Parameters;
|
||||
use MediaWiki\Extension\AbuseFilter\FilterLookup;
|
||||
use MediaWiki\Extension\AbuseFilter\Variables\VariableHolder;
|
||||
use MediaWiki\Linker\LinkTarget;
|
||||
use MediaWiki\User\UserIdentity;
|
||||
use MediaWikiUnitTestCase;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Psr\Log\NullLogger;
|
||||
use Title;
|
||||
use Wikimedia\TestingAccessWrapper;
|
||||
|
||||
/**
|
||||
|
@ -50,7 +50,7 @@ class ConsequencesExecutorTest extends MediaWikiUnitTestCase {
|
|||
return $consFactory;
|
||||
}
|
||||
|
||||
private function getConsExecutor( array $consequences, Title $title ): ConsequencesExecutor {
|
||||
private function getConsExecutor( array $consequences, LinkTarget $title ): ConsequencesExecutor {
|
||||
$locallyDisabledActions = [
|
||||
'flag' => false,
|
||||
'throttle' => false,
|
||||
|
@ -96,7 +96,6 @@ class ConsequencesExecutorTest extends MediaWikiUnitTestCase {
|
|||
/**
|
||||
* @param array $rawConsequences A raw, unfiltered list of consequences
|
||||
* @param array $expectedKeys
|
||||
* @param Title $title
|
||||
*
|
||||
* @covers ::getActualConsequencesToExecute
|
||||
* @covers ::replaceLegacyParameters
|
||||
|
@ -110,10 +109,9 @@ class ConsequencesExecutorTest extends MediaWikiUnitTestCase {
|
|||
*/
|
||||
public function testGetActualConsequencesToExecute(
|
||||
array $rawConsequences,
|
||||
array $expectedKeys,
|
||||
Title $title
|
||||
array $expectedKeys
|
||||
): void {
|
||||
$executor = $this->getConsExecutor( $rawConsequences, $title );
|
||||
$executor = $this->getConsExecutor( $rawConsequences, $this->createMock( LinkTarget::class ) );
|
||||
$actual = $executor->getActualConsequencesToExecute( array_keys( $rawConsequences ) );
|
||||
|
||||
$actualKeys = [];
|
||||
|
@ -128,10 +126,6 @@ class ConsequencesExecutorTest extends MediaWikiUnitTestCase {
|
|||
* @return array
|
||||
*/
|
||||
public function provideConsequences(): array {
|
||||
$pageName = 'TestFilteredConsequences';
|
||||
$title = $this->createMock( Title::class );
|
||||
$title->method( 'getPrefixedText' )->willReturn( $pageName );
|
||||
|
||||
return [
|
||||
'warn and throttle exclude other actions' => [
|
||||
[
|
||||
|
@ -160,7 +154,6 @@ class ConsequencesExecutorTest extends MediaWikiUnitTestCase {
|
|||
13 => [ 'throttle' ],
|
||||
168 => [ 'degroup' ]
|
||||
],
|
||||
$title
|
||||
],
|
||||
'warn excludes other actions, block excludes disallow' => [
|
||||
[
|
||||
|
@ -189,7 +182,6 @@ class ConsequencesExecutorTest extends MediaWikiUnitTestCase {
|
|||
'global-2' => [ 'warn' ],
|
||||
4 => [ 'block' ]
|
||||
],
|
||||
$title
|
||||
],
|
||||
'some global actions are disabled locally, the longest block is chosen' => [
|
||||
[
|
||||
|
@ -222,7 +214,6 @@ class ConsequencesExecutorTest extends MediaWikiUnitTestCase {
|
|||
1 => [],
|
||||
2 => [ 'degroup', 'block' ]
|
||||
],
|
||||
$title
|
||||
],
|
||||
'do not use a block that will be skipped as the longer one' => [
|
||||
[
|
||||
|
@ -248,7 +239,6 @@ class ConsequencesExecutorTest extends MediaWikiUnitTestCase {
|
|||
1 => [ 'warn' ],
|
||||
2 => [ 'block' ]
|
||||
],
|
||||
$title
|
||||
],
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue