MediaWiki REL1_34
QuestyCaptchaTest.php
Go to the documentation of this file.
1<?php
2
6class QuestyCaptchaTest extends MediaWikiTestCase {
7
8 public function setUp() {
9 parent::setUp();
10
11 $this->mergeMwGlobalArrayValue(
12 'wgAutoloadClasses',
13 [ 'QuestyCaptcha' => __DIR__ . '/../../QuestyCaptcha/includes/QuestyCaptcha.php' ]
14 );
15 }
16
21 public function testGetCaptcha( $config, $expected ) {
22 # setMwGlobals() requires $wgCaptchaQuestion to be set
23 if ( !isset( $GLOBALS['wgCaptchaQuestions'] ) ) {
24 $GLOBALS['wgCaptchaQuestions'] = [];
25 }
26 $this->setMwGlobals( 'wgCaptchaQuestions', $config );
27
28 $qc = new QuestyCaptcha();
29 $this->assertEquals( $expected, $qc->getCaptcha() );
30 }
31
32 public static function provideGetCaptcha() {
33 return [
34 [
35 [
36 [
37 'question' => 'FooBar',
38 'answer' => 'Answer!',
39 ],
40 ],
41 [
42 'question' => 'FooBar',
43 'answer' => 'Answer!',
44 ],
45 ],
46 [
47 [
48 'FooBar' => 'Answer!',
49 ],
50 [
51 'question' => 'FooBar',
52 'answer' => 'Answer!',
53 ],
54 ]
55 ];
56 }
57}
$GLOBALS['IP']
@covers QuestyCaptcha
testGetCaptcha( $config, $expected)
@covers QuestyCaptcha::getCaptcha @dataProvider provideGetCaptcha