mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-27 08:20:02 +00:00
Use more narrow UserIdentity interface where possible
Change-Id: I766eaa904a9eaeb7ac2a32a98289a364b1c25355
This commit is contained in:
parent
c5539052b9
commit
0ed6cafb3b
|
@ -52,7 +52,7 @@ class ReferencePreviewsContext {
|
|||
|
||||
// Anonymous users can (de)activate the feature via a cookie at runtime, hence it must load
|
||||
return !$user->isNamed() || $this->userOptionsLookup->getBoolOption(
|
||||
$user, self::REFERENCE_PREVIEWS_PREFERENCE_NAME
|
||||
);
|
||||
$user, self::REFERENCE_PREVIEWS_PREFERENCE_NAME
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ namespace Cite\ReferencePreviews;
|
|||
use InvalidArgumentException;
|
||||
use MediaWiki\Config\Config;
|
||||
use MediaWiki\Extension\Gadgets\GadgetRepo;
|
||||
use MediaWiki\User\User;
|
||||
use MediaWiki\User\UserIdentity;
|
||||
|
||||
/**
|
||||
|
@ -50,11 +49,11 @@ class ReferencePreviewsGadgetsIntegration {
|
|||
return false;
|
||||
}
|
||||
|
||||
public function isNavPopupsGadgetEnabled( User $user ): bool {
|
||||
public function isNavPopupsGadgetEnabled( UserIdentity $user ): bool {
|
||||
return $this->isGadgetEnabled( $user, $this->navPopupsGadgetName );
|
||||
}
|
||||
|
||||
public function isRefTooltipsGadgetEnabled( User $user ): bool {
|
||||
public function isRefTooltipsGadgetEnabled( UserIdentity $user ): bool {
|
||||
return $this->isGadgetEnabled( $user, $this->refTooltipsGadgetName );
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ use MediaWiki\Config\Config;
|
|||
use MediaWiki\Config\HashConfig;
|
||||
use MediaWiki\Extension\Gadgets\Gadget;
|
||||
use MediaWiki\Extension\Gadgets\GadgetRepo;
|
||||
use MediaWiki\User\User;
|
||||
use MediaWiki\User\UserIdentity;
|
||||
use MediaWikiIntegrationTestCase;
|
||||
|
||||
/**
|
||||
|
@ -44,7 +44,7 @@ class ReferencePreviewsGadgetsIntegrationTest extends MediaWikiIntegrationTestCa
|
|||
$this->getConfig(),
|
||||
null
|
||||
) )
|
||||
->isNavPopupsGadgetEnabled( $this->createNoOpMock( User::class ) ),
|
||||
->isNavPopupsGadgetEnabled( $this->createNoOpMock( UserIdentity::class ) ),
|
||||
'No conflict is identified.'
|
||||
);
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ class ReferencePreviewsGadgetsIntegrationTest extends MediaWikiIntegrationTestCa
|
|||
->willReturn( [] );
|
||||
|
||||
$this->executeIsNavPopupsGadgetEnabled(
|
||||
$this->createNoOpMock( User::class ),
|
||||
$this->createNoOpMock( UserIdentity::class ),
|
||||
$this->getConfig(),
|
||||
$gadgetRepoMock,
|
||||
self::GADGET_DISABLED
|
||||
|
@ -68,7 +68,7 @@ class ReferencePreviewsGadgetsIntegrationTest extends MediaWikiIntegrationTestCa
|
|||
public function testConflictsWithNavPopupsGadgetIfGadgetExists() {
|
||||
$this->markTestSkippedIfExtensionNotLoaded( 'Gadgets' );
|
||||
|
||||
$user = $this->createMock( User::class );
|
||||
$user = $this->createMock( UserIdentity::class );
|
||||
|
||||
$gadgetMock = $this->createMock( Gadget::class );
|
||||
$gadgetMock->expects( $this->once() )
|
||||
|
@ -109,7 +109,7 @@ class ReferencePreviewsGadgetsIntegrationTest extends MediaWikiIntegrationTestCa
|
|||
->willThrowException( new InvalidArgumentException() );
|
||||
|
||||
$this->executeIsNavPopupsGadgetEnabled(
|
||||
$this->createNoOpMock( User::class ),
|
||||
$this->createNoOpMock( UserIdentity::class ),
|
||||
$this->getConfig(),
|
||||
$gadgetRepoMock,
|
||||
self::GADGET_DISABLED
|
||||
|
@ -137,7 +137,7 @@ class ReferencePreviewsGadgetsIntegrationTest extends MediaWikiIntegrationTestCa
|
|||
->willReturn( $gadgetMock );
|
||||
|
||||
$this->executeIsNavPopupsGadgetEnabled(
|
||||
$this->createNoOpMock( User::class ),
|
||||
$this->createNoOpMock( UserIdentity::class ),
|
||||
$this->getConfig( $gadgetName ),
|
||||
$gadgetRepoMock,
|
||||
self::GADGET_ENABLED
|
||||
|
@ -151,7 +151,7 @@ class ReferencePreviewsGadgetsIntegrationTest extends MediaWikiIntegrationTestCa
|
|||
}
|
||||
|
||||
private function executeIsNavPopupsGadgetEnabled(
|
||||
User $user,
|
||||
UserIdentity $user,
|
||||
Config $config,
|
||||
GadgetRepo $repoMock,
|
||||
bool $expected
|
||||
|
|
Loading…
Reference in a new issue