diff options
Diffstat (limited to 'www/wiki/extensions/ConfirmEdit/tests/phpunit/QuestyCaptchaTest.php')
-rw-r--r-- | www/wiki/extensions/ConfirmEdit/tests/phpunit/QuestyCaptchaTest.php | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/www/wiki/extensions/ConfirmEdit/tests/phpunit/QuestyCaptchaTest.php b/www/wiki/extensions/ConfirmEdit/tests/phpunit/QuestyCaptchaTest.php new file mode 100644 index 00000000..e76469ba --- /dev/null +++ b/www/wiki/extensions/ConfirmEdit/tests/phpunit/QuestyCaptchaTest.php @@ -0,0 +1,57 @@ +<?php + +/** + * @covers QuestyCaptcha + */ +class QuestyCaptchaTest extends MediaWikiTestCase { + + public function setUp() { + parent::setUp(); + + $this->mergeMwGlobalArrayValue( + 'wgAutoloadClasses', + [ 'QuestyCaptcha' => __DIR__ . '/../../QuestyCaptcha/QuestyCaptcha.class.php' ] + ); + } + + /** + * @covers QuestyCaptcha::getCaptcha + * @dataProvider provideGetCaptcha + */ + public function testGetCaptcha( $config, $expected ) { + # setMwGlobals() requires $wgCaptchaQuestion to be set + if ( !isset( $GLOBALS['wgCaptchaQuestions'] ) ) { + $GLOBALS['wgCaptchaQuestions'] = []; + } + $this->setMwGlobals( 'wgCaptchaQuestions', $config ); + + $qc = new QuestyCaptcha(); + $this->assertEquals( $expected, $qc->getCaptcha() ); + } + + public static function provideGetCaptcha() { + return [ + [ + [ + [ + 'question' => 'FooBar', + 'answer' => 'Answer!', + ], + ], + [ + 'question' => 'FooBar', + 'answer' => 'Answer!', + ], + ], + [ + [ + 'FooBar' => 'Answer!', + ], + [ + 'question' => 'FooBar', + 'answer' => 'Answer!', + ], + ] + ]; + } +} |