2014-12-30 19:15:48 +00:00
|
|
|
<?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'] ) ) {
|
2016-05-09 23:41:17 +00:00
|
|
|
$GLOBALS['wgCaptchaQuestions'] = [];
|
2014-12-30 19:15:48 +00:00
|
|
|
}
|
|
|
|
$this->setMwGlobals( 'wgCaptchaQuestions', $config );
|
|
|
|
$this->mergeMwGlobalArrayValue(
|
|
|
|
'wgAutoloadClasses',
|
2016-05-09 23:41:17 +00:00
|
|
|
[ 'QuestyCaptcha' => __DIR__ . '/../QuestyCaptcha/QuestyCaptcha.class.php' ]
|
2014-12-30 19:15:48 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
$qc = new QuestyCaptcha();
|
|
|
|
$this->assertEquals( $expected, $qc->getCaptcha() );
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function provideGetCaptcha() {
|
2016-05-09 23:41:17 +00:00
|
|
|
return [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
[
|
2014-12-30 19:15:48 +00:00
|
|
|
'question' => 'FooBar',
|
|
|
|
'answer' => 'Answer!',
|
2016-05-09 23:41:17 +00:00
|
|
|
],
|
|
|
|
],
|
|
|
|
[
|
2014-12-30 19:15:48 +00:00
|
|
|
'question' => 'FooBar',
|
|
|
|
'answer' => 'Answer!',
|
2016-05-09 23:41:17 +00:00
|
|
|
],
|
|
|
|
],
|
|
|
|
[
|
|
|
|
[
|
2014-12-30 19:15:48 +00:00
|
|
|
'FooBar' => 'Answer!',
|
2016-05-09 23:41:17 +00:00
|
|
|
],
|
|
|
|
[
|
2014-12-30 19:15:48 +00:00
|
|
|
'question' => 'FooBar',
|
|
|
|
'answer' => 'Answer!',
|
2016-05-09 23:41:17 +00:00
|
|
|
],
|
|
|
|
]
|
|
|
|
];
|
2014-12-30 19:15:48 +00:00
|
|
|
}
|
|
|
|
}
|