mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ConfirmEdit
synced 2024-11-24 00:04:15 +00:00
65470a1c77
Shows up a deprecation message Follow-Up: I5ff35ad0e894f0a27beae00257dc1fc599ad518d Change-Id: If9787b27c4598711a0e5127385dbee57dab55d66
60 lines
1.7 KiB
PHP
60 lines
1.7 KiB
PHP
<?php
|
|
|
|
use MediaWiki\Auth\AuthenticationRequestTestCase;
|
|
use MediaWiki\Extension\ConfirmEdit\Auth\CaptchaAuthenticationRequest;
|
|
use MediaWiki\Extension\ConfirmEdit\SimpleCaptcha\SimpleCaptcha;
|
|
use MediaWiki\Extension\ConfirmEdit\Store\CaptchaHashStore;
|
|
use MediaWiki\Extension\ConfirmEdit\Store\CaptchaStore;
|
|
|
|
/**
|
|
* @covers \MediaWiki\Extension\ConfirmEdit\Auth\CaptchaAuthenticationRequest
|
|
*/
|
|
class CaptchaAuthenticationRequestTest extends AuthenticationRequestTestCase {
|
|
public function setUp(): void {
|
|
parent::setUp();
|
|
$this->setMwGlobals( [
|
|
'wgCaptchaClass' => SimpleCaptcha::class,
|
|
'wgCaptchaStorageClass' => CaptchaHashStore::class,
|
|
] );
|
|
CaptchaStore::unsetInstanceForTests();
|
|
CaptchaStore::get()->clearAll();
|
|
CaptchaStore::get()->store( '345', [ 'question' => '2+2', 'answer' => '4' ] );
|
|
}
|
|
|
|
protected function getInstance( array $args = [] ) {
|
|
return new CaptchaAuthenticationRequest( $args[0], $args[1] );
|
|
}
|
|
|
|
public static function provideGetFieldInfo() {
|
|
return [
|
|
[ [ '123', [ 'question' => '1+2', 'answer' => '3' ] ] ],
|
|
];
|
|
}
|
|
|
|
public static function provideLoadFromSubmission() {
|
|
return [
|
|
'no id' => [
|
|
[ '123', [ 'question' => '1+2', 'answer' => '3' ] ],
|
|
[],
|
|
false,
|
|
],
|
|
'no answer' => [
|
|
[ '123', [ 'question' => '1+2', 'answer' => '3' ] ],
|
|
[ 'captchaId' => '345' ],
|
|
false,
|
|
],
|
|
'missing' => [
|
|
[ '123', [ 'question' => '1+2', 'answer' => '3' ] ],
|
|
[ 'captchaId' => '234', 'captchaWord' => '5' ],
|
|
false,
|
|
],
|
|
'normal' => [
|
|
[ '123', [ 'question' => '1+2', 'answer' => '3' ] ],
|
|
[ 'captchaId' => '345', 'captchaWord' => '5' ],
|
|
[ 'captchaId' => '345', 'captchaData' => [ 'question' => '2+2', 'answer' => '4' ],
|
|
'captchaWord' => '5' ],
|
|
],
|
|
];
|
|
}
|
|
}
|