mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ConfirmEdit
synced 2024-11-14 19:30:11 +00:00
5b7a36a521
Change-Id: Ie956fe86184535a376d0398483ac3c853fa9127c
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/includes/QuestyCaptcha.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!',
|
|
],
|
|
]
|
|
];
|
|
}
|
|
}
|