MediaWiki  1.34.0
QuestyCaptchaTest.php
Go to the documentation of this file.
1 <?php
2 
6 class 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 }
QuestyCaptcha
Definition: QuestyCaptcha.php:13
QuestyCaptchaTest\setUp
setUp()
Definition: QuestyCaptchaTest.php:8
QuestyCaptchaTest
@covers QuestyCaptcha
Definition: QuestyCaptchaTest.php:6
QuestyCaptchaTest\provideGetCaptcha
static provideGetCaptcha()
Definition: QuestyCaptchaTest.php:32
$GLOBALS
$GLOBALS['IP']
Definition: ComposerHookHandler.php:6
QuestyCaptchaTest\testGetCaptcha
testGetCaptcha( $config, $expected)
@covers QuestyCaptcha::getCaptcha @dataProvider provideGetCaptcha
Definition: QuestyCaptchaTest.php:21