mediawiki-extensions-Confir.../tests/phpunit/QuestyCaptchaTest.php
James D. Forrester 86246f0172 build: Upgrade mediawiki-codesniffer to v28.0.0
Change-Id: I12c3660e74e42937f6cfb31ec4771a67d8651f42
2019-10-09 15:45:51 -07:00

58 lines
1.1 KiB
PHP

<?php
/**
* @covers QuestyCaptcha
*/
class QuestyCaptchaTest extends MediaWikiTestCase {
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!',
],
]
];
}
}