Debian Codegraph @

extensions/ConfirmEdit/tests/phpunit/CaptchaAuthenticationRequestTest.php

raw symbols SCIP
1 <?php
2
3 use MediaWiki\Extension\ConfirmEdit\Auth\CaptchaAuthenticationRequest;
4 use MediaWiki\Extension\ConfirmEdit\SimpleCaptcha\SimpleCaptcha;
5 use MediaWiki\Extension\ConfirmEdit\Store\CaptchaHashStore;
6 use MediaWiki\Extension\ConfirmEdit\Store\CaptchaStore;
7 use MediaWiki\Tests\Auth\AuthenticationRequestTestCase;
8
9 /**
10 * @covers \MediaWiki\Extension\ConfirmEdit\Auth\CaptchaAuthenticationRequest
11 */
12 class CaptchaAuthenticationRequestTest extends AuthenticationRequestTestCase {
13 public function setUp(): void {
14 parent::setUp();
15 $this->overrideConfigValues( [
16 'CaptchaClass' => SimpleCaptcha::class,
17 'CaptchaStorageClass' => CaptchaHashStore::class,
18 ] );
19 CaptchaStore::unsetInstanceForTests();
20 CaptchaStore::get()->clearAll();
21 CaptchaStore::get()->store( '345', [ 'question' => '2+2', 'answer' => '4' ] );
22 }
23
24 protected function getInstance( array $args = [] ) {
25 return new CaptchaAuthenticationRequest( $args[0], $args[1] );
26 }
27
28 public static function provideGetFieldInfo() {
29 return [
30 [ [ '123', [ 'question' => '1+2', 'answer' => '3' ] ] ],
31 ];
32 }
33
34 public static function provideLoadFromSubmission() {
35 return [
36 'no id' => [
37 [ '123', [ 'question' => '1+2', 'answer' => '3' ] ],
38 [],
39 false,
40 ],
41 'no answer' => [
42 [ '123', [ 'question' => '1+2', 'answer' => '3' ] ],
43 [ 'captchaId' => '345' ],
44 false,
45 ],
46 'missing' => [
47 [ '123', [ 'question' => '1+2', 'answer' => '3' ] ],
48 [ 'captchaId' => '234', 'captchaWord' => '5' ],
49 false,
50 ],
51 'normal' => [
52 [ '123', [ 'question' => '1+2', 'answer' => '3' ] ],
53 [ 'captchaId' => '345', 'captchaWord' => '5' ],
54 [ 'captchaId' => '345', 'captchaData' => [ 'question' => '2+2', 'answer' => '4' ],
55 'captchaWord' => '5' ],
56 ],
57 ];
58 }
59 }