MediaWiki
REL1_31
FormOptionsInitializationTest.php
Go to the documentation of this file.
1
<?php
16
class
FormOptionsExposed
extends
FormOptions
{
17
public
function
getOptions
() {
18
return
$this->options
;
19
}
20
}
21
30
class
FormOptionsInitializationTest
extends
MediaWikiTestCase
{
34
protected
$object
;
35
40
protected
function
setUp
() {
41
parent::setUp();
42
$this->
object
=
new
FormOptionsExposed
();
43
}
44
48
public
function
testAddStringOption
() {
49
$this->
object
->add(
'foo'
,
'string value'
);
50
$this->assertEquals(
51
[
52
'foo'
=> [
53
'default'
=>
'string value'
,
54
'consumed'
=>
false
,
55
'type'
=>
FormOptions::STRING
,
56
'value'
=>
null
,
57
]
58
],
59
$this->object->getOptions()
60
);
61
}
62
66
public
function
testAddIntegers
() {
67
$this->
object
->add(
'one'
, 1 );
68
$this->
object
->add(
'negone'
, -1 );
69
$this->assertEquals(
70
[
71
'negone'
=> [
72
'default'
=> -1,
73
'value'
=>
null
,
74
'consumed'
=>
false
,
75
'type'
=>
FormOptions::INT
,
76
],
77
'one'
=> [
78
'default'
=> 1,
79
'value'
=>
null
,
80
'consumed'
=>
false
,
81
'type'
=>
FormOptions::INT
,
82
]
83
],
84
$this->object->getOptions()
85
);
86
}
87
}
FormOptionsExposed
This file host two test case classes for the MediaWiki FormOptions class:
Definition
FormOptionsInitializationTest.php:16
FormOptionsExposed\getOptions
getOptions()
Definition
FormOptionsInitializationTest.php:17
FormOptionsInitializationTest
Test class for FormOptions initialization Ensure the FormOptions::add() does what we want it to do.
Definition
FormOptionsInitializationTest.php:30
FormOptionsInitializationTest\testAddStringOption
testAddStringOption()
FormOptionsExposed::add.
Definition
FormOptionsInitializationTest.php:48
FormOptionsInitializationTest\$object
FormOptions $object
Definition
FormOptionsInitializationTest.php:34
FormOptionsInitializationTest\testAddIntegers
testAddIntegers()
FormOptionsExposed::add.
Definition
FormOptionsInitializationTest.php:66
FormOptionsInitializationTest\setUp
setUp()
A new fresh and empty FormOptions object to test initialization with.
Definition
FormOptionsInitializationTest.php:40
FormOptions
Helper class to keep track of options when mixing links and form elements.
Definition
FormOptions.php:35
FormOptions\STRING
const STRING
String type, maps guessType() to WebRequest::getText()
Definition
FormOptions.php:43
FormOptions\$options
$options
Map of known option names to information about them.
Definition
FormOptions.php:70
FormOptions\INT
const INT
Integer type, maps guessType() to WebRequest::getInt()
Definition
FormOptions.php:45
MediaWikiTestCase
Definition
MediaWikiTestCase.php:17
tests
phpunit
includes
FormOptionsInitializationTest.php
Generated on Mon Nov 25 2024 15:36:22 for MediaWiki by
1.10.0