| 1 |
<?php |
| 2 |
|
| 3 |
use MediaWiki\Request\FauxRequest; |
| 4 |
use MediaWiki\Specials\SpecialPasswordReset; |
| 5 |
use MediaWiki\Tests\SpecialPage\FormSpecialPageTestCase; |
| 6 |
use MediaWiki\Tests\User\TempUser\TempUserTestTrait; |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
class SpecialPasswordResetTest extends FormSpecialPageTestCase { |
| 13 |
|
| 14 |
use TempUserTestTrait; |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
protected function newSpecialPage() { |
| 20 |
return new SpecialPasswordReset( |
| 21 |
$this->getServiceContainer()->getPasswordReset() |
| 22 |
); |
| 23 |
} |
| 24 |
|
| 25 |
public function testView() { |
| 26 |
[ $html ] = $this->executeSpecialPage(); |
| 27 |
|
| 28 |
$this->assertStringContainsString( '(passwordreset-username', $html ); |
| 29 |
$this->assertStringContainsString( '(passwordreset-email', $html ); |
| 30 |
$this->assertStringContainsString( '(passwordreset-text-many', $html ); |
| 31 |
$this->assertStringContainsString( '(mailmypassword', $html ); |
| 32 |
} |
| 33 |
|
| 34 |
public function testExecuteForTemporaryAccountUsername() { |
| 35 |
|
| 36 |
$this->enableAutoCreateTempUser(); |
| 37 |
$tempUser = $this->getServiceContainer()->getTempUserCreator()->create( null, new FauxRequest() )->getUser(); |
| 38 |
|
| 39 |
$request = new FauxRequest( |
| 40 |
[ 'wpUsername' => $tempUser->getName() ], |
| 41 |
true |
| 42 |
); |
| 43 |
[ $html ] = $this->executeSpecialPage( '', $request ); |
| 44 |
$this->assertStringContainsString( '(htmlform-user-not-valid', $html ); |
| 45 |
} |
| 46 |
} |