2014-12-30 19:15:48 +00:00
|
|
|
<?php
|
|
|
|
|
2022-04-08 16:53:12 +00:00
|
|
|
use MediaWiki\Extension\ConfirmEdit\QuestyCaptcha\QuestyCaptcha;
|
|
|
|
|
2018-01-23 23:59:08 +00:00
|
|
|
/**
|
2022-04-08 16:53:12 +00:00
|
|
|
* @covers \MediaWiki\Extension\ConfirmEdit\QuestyCaptcha\QuestyCaptcha
|
2018-01-23 23:59:08 +00:00
|
|
|
*/
|
2021-10-11 22:36:53 +00:00
|
|
|
class QuestyCaptchaTest extends MediaWikiIntegrationTestCase {
|
2017-12-27 20:59:19 +00:00
|
|
|
|
2021-07-22 06:38:52 +00:00
|
|
|
public function setUp(): void {
|
2017-12-27 20:59:19 +00:00
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$this->mergeMwGlobalArrayValue(
|
|
|
|
'wgAutoloadClasses',
|
2022-04-08 16:53:12 +00:00
|
|
|
[ 'MediaWiki\\Extension\\ConfirmEdit\\QuestyCaptcha\\QuestyCaptcha'
|
|
|
|
=> __DIR__ . '/../../QuestyCaptcha/includes/QuestyCaptcha.php' ]
|
2017-12-27 20:59:19 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-12-30 19:15:48 +00:00
|
|
|
/**
|
2022-04-08 16:53:12 +00:00
|
|
|
* @covers \MediaWiki\Extension\ConfirmEdit\QuestyCaptcha\QuestyCaptcha::getCaptcha
|
2014-12-30 19:15:48 +00:00
|
|
|
* @dataProvider provideGetCaptcha
|
|
|
|
*/
|
|
|
|
public function testGetCaptcha( $config, $expected ) {
|
|
|
|
# setMwGlobals() requires $wgCaptchaQuestion to be set
|
|
|
|
if ( !isset( $GLOBALS['wgCaptchaQuestions'] ) ) {
|
2016-05-09 23:41:17 +00:00
|
|
|
$GLOBALS['wgCaptchaQuestions'] = [];
|
2014-12-30 19:15:48 +00:00
|
|
|
}
|
|
|
|
$this->setMwGlobals( 'wgCaptchaQuestions', $config );
|
|
|
|
|
|
|
|
$qc = new QuestyCaptcha();
|
|
|
|
$this->assertEquals( $expected, $qc->getCaptcha() );
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function provideGetCaptcha() {
|
2016-05-09 23:41:17 +00:00
|
|
|
return [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
[
|
2014-12-30 19:15:48 +00:00
|
|
|
'question' => 'FooBar',
|
|
|
|
'answer' => 'Answer!',
|
2016-05-09 23:41:17 +00:00
|
|
|
],
|
|
|
|
],
|
|
|
|
[
|
2014-12-30 19:15:48 +00:00
|
|
|
'question' => 'FooBar',
|
|
|
|
'answer' => 'Answer!',
|
2016-05-09 23:41:17 +00:00
|
|
|
],
|
|
|
|
],
|
|
|
|
[
|
|
|
|
[
|
2014-12-30 19:15:48 +00:00
|
|
|
'FooBar' => 'Answer!',
|
2016-05-09 23:41:17 +00:00
|
|
|
],
|
|
|
|
[
|
2014-12-30 19:15:48 +00:00
|
|
|
'question' => 'FooBar',
|
|
|
|
'answer' => 'Answer!',
|
2016-05-09 23:41:17 +00:00
|
|
|
],
|
|
|
|
]
|
|
|
|
];
|
2014-12-30 19:15:48 +00:00
|
|
|
}
|
|
|
|
}
|