MediaWiki REL1_34
CaptchaAuthenticationRequestTest.php
Go to the documentation of this file.
1<?php
2
3use MediaWiki\Auth\AuthenticationRequestTestCase;
4
8class 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}
if( $line===false) $args
Definition cdb.php:64
@covers CaptchaAuthenticationRequest
Generic captcha authentication request class.
static unsetInstanceForTests()
static get()
Get somewhere to store captcha data that will persist between requests.