MediaWiki  1.34.0
CaptchaAuthenticationRequestTest.php
Go to the documentation of this file.
1 <?php
2 
3 use MediaWiki\Auth\AuthenticationRequestTestCase;
4 
8 class CaptchaAuthenticationRequestTest extends AuthenticationRequestTestCase {
9  public function setUp() {
10  parent::setUp();
11  $this->setMwGlobals( [
12  'wgCaptchaClass' => SimpleCaptcha::class,
13  'wgCaptchaStorageClass' => CaptchaHashStore::class,
14  ] );
16  CaptchaStore::get()->clearAll();
17  CaptchaStore::get()->store( '345', [ 'question' => '2+2', 'answer' => '4' ] );
18  }
19 
20  protected function getInstance( array $args = [] ) {
21  return new CaptchaAuthenticationRequest( $args[0], $args[1] );
22  }
23 
24  public static function provideGetFieldInfo() {
25  return [
26  [ [ '123', [ 'question' => '1+2', 'answer' => '3' ] ] ],
27  ];
28  }
29 
30  public function provideLoadFromSubmission() {
31  return [
32  'no id' => [
33  [ '123', [ 'question' => '1+2', 'answer' => '3' ] ],
34  [],
35  false,
36  ],
37  'no answer' => [
38  [ '123', [ 'question' => '1+2', 'answer' => '3' ] ],
39  [ 'captchaId' => '345' ],
40  false,
41  ],
42  'missing' => [
43  [ '123', [ 'question' => '1+2', 'answer' => '3' ] ],
44  [ 'captchaId' => '234', 'captchaWord' => '5' ],
45  false,
46  ],
47  'normal' => [
48  [ '123', [ 'question' => '1+2', 'answer' => '3' ] ],
49  [ 'captchaId' => '345', 'captchaWord' => '5' ],
50  [ 'captchaId' => '345', 'captchaData' => [ 'question' => '2+2', 'answer' => '4' ],
51  'captchaWord' => '5' ],
52  ],
53  ];
54  }
55 }
CaptchaStore\get
static get()
Get somewhere to store captcha data that will persist between requests.
Definition: CaptchaStore.php:42
CaptchaStore\unsetInstanceForTests
static unsetInstanceForTests()
Definition: CaptchaStore.php:54
CaptchaAuthenticationRequestTest\setUp
setUp()
Definition: CaptchaAuthenticationRequestTest.php:9
CaptchaAuthenticationRequestTest\getInstance
getInstance(array $args=[])
Definition: CaptchaAuthenticationRequestTest.php:20
CaptchaAuthenticationRequestTest
@covers CaptchaAuthenticationRequest
Definition: CaptchaAuthenticationRequestTest.php:8
$args
if( $line===false) $args
Definition: cdb.php:64
CaptchaAuthenticationRequestTest\provideLoadFromSubmission
provideLoadFromSubmission()
Definition: CaptchaAuthenticationRequestTest.php:30
CaptchaAuthenticationRequestTest\provideGetFieldInfo
static provideGetFieldInfo()
Definition: CaptchaAuthenticationRequestTest.php:24
CaptchaAuthenticationRequest
Generic captcha authentication request class.
Definition: CaptchaAuthenticationRequest.php:10