Debian Codegraph @

tests/phpunit/includes/specials/SpecialPasswordResetTest.php

raw symbols SCIP
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 * @covers \MediaWiki\Specials\SpecialPasswordReset
10 * @group Database
11 */
12 class SpecialPasswordResetTest extends FormSpecialPageTestCase {
13
14 use TempUserTestTrait;
15
16 /**
17 * @inheritDoc
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 // Check that the form fields are as expected
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 // Get an existing temporary account to test with
36 $this->enableAutoCreateTempUser();
37 $tempUser = $this->getServiceContainer()->getTempUserCreator()->create( null, new FauxRequest() )->getUser();
38 // Make a fake POST request that tries to use a temporary account for the password
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 }