mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ConfirmEdit
synced 2024-11-25 00:26:06 +00:00
79b09f4995
The captchas in production are registered conditional, in tests the class needs to be added to the autoloader. Moved this register up to setUp to detect the existing @covers correctly by the new testValidCovers from I1d564bcae2bfbedb004c440b90db6341148ed4ba Change-Id: I79f225126d7bbbfd436ab165bb98a0ed9517b8bc
55 lines
1 KiB
PHP
55 lines
1 KiB
PHP
<?php
|
|
|
|
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!',
|
|
],
|
|
]
|
|
];
|
|
}
|
|
}
|