diff options
Diffstat (limited to 'tests/phpunit/includes/logging/ProtectLogFormatterTest.php')
-rw-r--r-- | tests/phpunit/includes/logging/ProtectLogFormatterTest.php | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/tests/phpunit/includes/logging/ProtectLogFormatterTest.php b/tests/phpunit/includes/logging/ProtectLogFormatterTest.php index 12c96539a0ee..0cfbd8aa0201 100644 --- a/tests/phpunit/includes/logging/ProtectLogFormatterTest.php +++ b/tests/phpunit/includes/logging/ProtectLogFormatterTest.php @@ -1,10 +1,26 @@ <?php +use MediaWiki\Tests\Unit\Permissions\MockAuthorityTrait; +use MediaWiki\User\UserIdentityValue; +use Wikimedia\Rdbms\LBFactory; + /** * @covers ProtectLogFormatter */ class ProtectLogFormatterTest extends LogFormatterTestCase { + use MockAuthorityTrait; + + protected function setUp(): void { + parent::setUp(); + + $db = $this->createNoOpMock( IDatabase::class, [ 'getInfinity' ] ); + $db->method( 'getInfinity' )->willReturn( 'infinity' ); + $lbFactory = $this->createMock( LBFactory::class ); + $lbFactory->method( 'getReplicaDatabase' )->willReturn( $db ); + $this->setService( 'DBLoadBalancerFactory', $lbFactory ); + } + /** * Provide different rows from the logging table to test * for backward compatibility. @@ -448,8 +464,7 @@ class ProtectLogFormatterTest extends LogFormatterTestCase { */ public function testGetActionLinks( array $permissions, $shouldMatch ) { RequestContext::resetMain(); - $user = $this->getTestUser()->getUser(); - $this->overrideUserPermissions( $user, $permissions ); + $user = $this->mockUserAuthorityWithPermissions( new UserIdentityValue( 42, __METHOD__ ), $permissions ); $row = $this->expandDatabaseRow( [ 'type' => 'protect', 'action' => 'unprotect', @@ -459,7 +474,8 @@ class ProtectLogFormatterTest extends LogFormatterTestCase { 'params' => [], ], false ); $context = new RequestContext(); - $context->setUser( $user ); + $context->setAuthority( $user ); + $context->setLanguage( 'en' ); $formatter = LogFormatter::newFromRow( $row ); $formatter->setContext( $context ); if ( $shouldMatch ) { |