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