mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ConfirmEdit
synced 2024-11-27 17:40:11 +00:00
e1f45829d4
Change-Id: I1e99261acb13c86e96c1b2dd1cb61918ebc660c2
58 lines
1.1 KiB
PHP
58 lines
1.1 KiB
PHP
<?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!',
|
|
],
|
|
]
|
|
];
|
|
}
|
|
}
|