MediaWiki REL1_31
QuestyCaptchaTest.php
Go to the documentation of this file.
1<?php
2
7
8 public function setUp() {
9 parent::setUp();
10
12 'wgAutoloadClasses',
13 [ 'QuestyCaptcha' => __DIR__ . '/../../QuestyCaptcha/QuestyCaptcha.class.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']
mergeMwGlobalArrayValue( $name, $values)
Merges the given values into a MW global array variable.
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
testGetCaptcha( $config, $expected)
QuestyCaptcha::getCaptcha provideGetCaptcha.