mediawiki-extensions-Confir.../tests/phpunit/QuestyCaptchaTest.php
Alexander Vorwerk 9ee7caa78e MediaWikiTestCase -> MediaWikiIntegrationTestCase
MediaWikiTestCase has been renamed to MediaWikiIntegrationTestCase in 1.34.

Bug: T293043
Change-Id: Iba498b9107753233b4fbb1f8d435663199635507
2021-11-29 19:54:25 +00:00

58 lines
1.1 KiB
PHP

<?php
/**
* @covers QuestyCaptcha
*/
class QuestyCaptchaTest extends MediaWikiIntegrationTestCase {
public function setUp(): void {
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!',
],
]
];
}
}