Do not mock User in TextExtractorTest.

In I63d9807264d7e2295afef51fc9d982447f92fcbd we are
changing how the permission checks are applied for revision,
so it uses passed User instance as Authority. However, when
user is mocked, the tests are breaking since the new user methods
are not mocked. Pass a real user for now to fix the test. Once
Authority reaches maturity and is ok to use in extensions, the
test should be rewritten to use authority directly.

Bug: T271458
Change-Id: Iacab813b253cc6e1439007e573e8ace06645860f
This commit is contained in:
Petr Pchelko 2021-01-20 09:29:13 -06:00
parent 2e72e3a952
commit 6aa8f6f67b

View file

@ -23,11 +23,7 @@ class TextExtractorTest extends MediaWikiIntegrationTestCase {
* @dataProvider provideRevisionToString
*/
public function testRevisionToString( ?RevisionRecord $rev, bool $sysop, string $expected ) {
$user = $this->createMock( User::class );
$user->method( 'getName' )->willReturn( 'Test user 12345' );
$perms = $sysop ? [ 'deletedtext' ] : [];
$this->overrideUserPermissions( $user, $perms );
$user = $sysop ? $this->getTestSysop()->getUser() : $this->getTestUser()->getUser();
$hookRunner = new AbuseFilterHookRunner( $this->createHookContainer() );
$converter = new TextExtractor( $hookRunner );
$actual = $converter->revisionToString( $rev, $user );