mediawiki-extensions-Confir.../tests/QuestyCaptchaTest.php
Kunal Mehta 3244e44bd2 Add basic tests for QuestyCaptcha
Change-Id: I799e110ae42cd8cd3dc2276d638039d23149ca37
2015-01-05 14:19:13 +01:00

50 lines
1 KiB
PHP

<?php
class QuestyCaptchaTest extends MediaWikiTestCase {
/**
* @covers QuestyCaptcha::getCaptcha
* @dataProvider provideGetCaptcha
*/
public function testGetCaptcha( $config, $expected ) {
# setMwGlobals() requires $wgCaptchaQuestion to be set
if ( !isset( $GLOBALS['wgCaptchaQuestions'] ) ) {
$GLOBALS['wgCaptchaQuestions'] = array();
}
$this->setMwGlobals( 'wgCaptchaQuestions', $config );
$this->mergeMwGlobalArrayValue(
'wgAutoloadClasses',
array( 'QuestyCaptcha' => __DIR__ . '/../QuestyCaptcha.class.php' )
);
$qc = new QuestyCaptcha();
$this->assertEquals( $expected, $qc->getCaptcha() );
}
public static function provideGetCaptcha() {
return array(
array(
array(
array(
'question' => 'FooBar',
'answer' => 'Answer!',
),
),
array(
'question' => 'FooBar',
'answer' => 'Answer!',
),
),
array(
array(
'FooBar' => 'Answer!',
),
array(
'question' => 'FooBar',
'answer' => 'Answer!',
),
)
);
}
}