summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/ConfirmEdit/tests/CaptchaAuthenticationRequestTest.php
diff options
context:
space:
mode:
authorYaco <franco@reevo.org>2020-06-04 11:01:00 -0300
committerYaco <franco@reevo.org>2020-06-04 11:01:00 -0300
commitfc7369835258467bf97eb64f184b93691f9a9fd5 (patch)
treedaabd60089d2dd76d9f5fb416b005fbe159c799d /www/wiki/extensions/ConfirmEdit/tests/CaptchaAuthenticationRequestTest.php
first commit
Diffstat (limited to 'www/wiki/extensions/ConfirmEdit/tests/CaptchaAuthenticationRequestTest.php')
-rw-r--r--www/wiki/extensions/ConfirmEdit/tests/CaptchaAuthenticationRequestTest.php52
1 files changed, 52 insertions, 0 deletions
diff --git a/www/wiki/extensions/ConfirmEdit/tests/CaptchaAuthenticationRequestTest.php b/www/wiki/extensions/ConfirmEdit/tests/CaptchaAuthenticationRequestTest.php
new file mode 100644
index 00000000..d32b3ba9
--- /dev/null
+++ b/www/wiki/extensions/ConfirmEdit/tests/CaptchaAuthenticationRequestTest.php
@@ -0,0 +1,52 @@
+<?php
+
+use MediaWiki\Auth\AuthenticationRequestTestCase;
+use MediaWiki\Auth\AuthManager;
+
+class CaptchaAuthenticationRequestTest extends AuthenticationRequestTestCase {
+ public function setUp() {
+ parent::setUp();
+ $this->setMwGlobals( [
+ 'wgCaptchaClass' => 'SimpleCaptcha',
+ 'wgCaptchaStorageClass' => CaptchaHashStore::class,
+ ] );
+ 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 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' ],
+ ],
+ ];
+ }
+}