| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
o |
| 6 |
. |
| 7 |
|
| 8 |
|
| 9 |
use MediaWiki\MainConfigNames; |
| 10 |
use MediaWiki\Specials\SpecialPreferences; |
| 11 |
use MediaWiki\User\Options\UserOptionsManager; |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
class SpecialPreferencesTest extends SpecialPageTestBase { |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
private ?UserOptionsManager $userOptionsManager = null; |
| 26 |
|
| 27 |
protected function tearDown(): void { |
| 28 |
$this->userOptionsManager = null; |
| 29 |
parent::tearDown(); |
| 30 |
} |
| 31 |
|
| 32 |
protected function newSpecialPage() { |
| 33 |
return new SpecialPreferences( |
| 34 |
$this->getServiceContainer()->getPreferencesFactory(), |
| 35 |
$this->userOptionsManager ?? $this->getServiceContainer()->getUserOptionsManager() |
| 36 |
); |
| 37 |
} |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
public function testLongUsernameDoesNotFatal() { |
| 44 |
$maxSigChars = 2; |
| 45 |
$this->overrideConfigValue( MainConfigNames::MaxSigChars, $maxSigChars ); |
| 46 |
$nickname = str_repeat( 'x', $maxSigChars + 1 ); |
| 47 |
$user = $this->getMutableTestUser()->getUser(); |
| 48 |
|
| 49 |
$this->userOptionsManager = $this->createMock( UserOptionsManager::class ); |
| 50 |
$this->userOptionsManager->method( 'getOption' ) |
| 51 |
->with( $user, 'nickname' ) |
| 52 |
->willReturn( $nickname ); |
| 53 |
|
| 54 |
$this->executeSpecialPage( '', null, null, $user ); |
| 55 |
|
| 56 |
$this->addToAssertionCount( 1 ); |
| 57 |
} |
| 58 |
|
| 59 |
} |