FormOptions: adds doc & tests
[lhc/web/wiklou.git] / tests / phpunit / includes / FormOptionsTest.php
1 <?php
2 /**
3 * This file host two test case classes for the MediaWiki FormOptions class:
4 * - FormOptionsInitializationTest : tests initialization of the class.
5 * - FormOptionsTest : tests methods an on instance
6 *
7 * The split let us take advantage of setting up a fixture for the methods
8 * tests.
9 */
10
11 /**
12 * Test class for FormOptions methods.
13 * Generated by PHPUnit on 2011-02-28 at 20:46:27.
14 *
15 * Copyright © 2011, Ashar Voultoiz
16 *
17 * @author Ashar Voultoiz
18 */
19 class FormOptionsTest extends MediaWikiTestCase {
20 /**
21 * @var FormOptions
22 */
23 protected $object;
24
25 /**
26 * Instanciates a FormOptions object to play with.
27 * FormOptions::add() is tested by the class FormOptionsInitializationTest
28 * so we assume the function is well tested already an use it to create
29 * the fixture.
30 */
31 protected function setUp() {
32 $this->object = new FormOptions;
33 $this->object->add( 'string1', 'string one' );
34 $this->object->add( 'string2', 'string two' );
35 $this->object->add( 'integer', 0 );
36 $this->object->add( 'intnull', 0, FormOptions::INTNULL );
37 }
38
39 /**
40 * @todo Implement testDelete().
41 */
42 public function testDelete() {
43 // Remove the following lines when you implement this test.
44 $this->markTestIncomplete(
45 'This test has not been implemented yet.'
46 );
47 }
48
49 /** Helpers for testGuessType() */
50 /* @{ */
51 private function assertGuessBoolean( $data ) {
52 $this->guess( FormOptions::BOOL, $data );
53 }
54 private function assertGuessInt( $data ) {
55 $this->guess( FormOptions::INT, $data );
56 }
57 private function assertGuessString( $data ) {
58 $this->guess( FormOptions::STRING, $data );
59 }
60
61 /** Generic helper */
62 private function guess( $expected, $data ) {
63 $this->assertEquals(
64 $expected,
65 FormOptions::guessType( $data )
66 );
67 }
68 /* @} */
69
70 /**
71 * Reuse helpers above assertGuessBoolean assertGuessInt assertGuessString
72 */
73 public function testGuessTypeDetection() {
74 $this->assertGuessBoolean( true );
75 $this->assertGuessBoolean( false );
76
77 $this->assertGuessInt( 0 );
78 $this->assertGuessInt( -5 );
79 $this->assertGuessInt( 5 );
80 $this->assertGuessInt( 0x0F );
81
82 $this->assertGuessString( 'true' );
83 $this->assertGuessString( 'false' );
84 $this->assertGuessString( '5' );
85 $this->assertGuessString( '0' );
86 }
87
88 /**
89 * @expectedException MWException
90 */
91 public function testGuessTypeOnArrayThrowException() {
92 $this->object->guessType( array( 'foo' ) );
93 }
94 /**
95 * @expectedException MWException
96 */
97 public function testGuessTypeOnNullThrowException() {
98 $this->object->guessType( null );
99 }
100
101 /**
102 * @todo Implement testValidateName().
103 */
104 public function testValidateName() {
105 // Remove the following lines when you implement this test.
106 $this->markTestIncomplete(
107 'This test has not been implemented yet.'
108 );
109 }
110
111 /**
112 * @todo Implement testSetValue().
113 */
114 public function testSetValue() {
115 // Remove the following lines when you implement this test.
116 $this->markTestIncomplete(
117 'This test has not been implemented yet.'
118 );
119 }
120
121 /**
122 * @todo Implement testGetValue().
123 */
124 public function testGetValue() {
125 // Remove the following lines when you implement this test.
126 $this->markTestIncomplete(
127 'This test has not been implemented yet.'
128 );
129 }
130
131 /**
132 * @todo Implement testReset().
133 */
134 public function testReset() {
135 // Remove the following lines when you implement this test.
136 $this->markTestIncomplete(
137 'This test has not been implemented yet.'
138 );
139 }
140
141 /**
142 * @todo Implement testConsumeValue().
143 */
144 public function testConsumeValue() {
145 // Remove the following lines when you implement this test.
146 $this->markTestIncomplete(
147 'This test has not been implemented yet.'
148 );
149 }
150
151 /**
152 * @todo Implement testConsumeValues().
153 */
154 public function testConsumeValues() {
155 // Remove the following lines when you implement this test.
156 $this->markTestIncomplete(
157 'This test has not been implemented yet.'
158 );
159 }
160
161 /**
162 * @todo Implement testValidateIntBounds().
163 */
164 public function testValidateIntBounds() {
165 // Remove the following lines when you implement this test.
166 $this->markTestIncomplete(
167 'This test has not been implemented yet.'
168 );
169 }
170
171 /**
172 * @todo Implement testGetUnconsumedValues().
173 */
174 public function testGetUnconsumedValues() {
175 // Remove the following lines when you implement this test.
176 $this->markTestIncomplete(
177 'This test has not been implemented yet.'
178 );
179 }
180
181 /**
182 * @todo Implement testGetChangedValues().
183 */
184 public function testGetChangedValues() {
185 // Remove the following lines when you implement this test.
186 $this->markTestIncomplete(
187 'This test has not been implemented yet.'
188 );
189 }
190
191 /**
192 * @todo Implement testGetAllValues().
193 */
194 public function testGetAllValues() {
195 // Remove the following lines when you implement this test.
196 $this->markTestIncomplete(
197 'This test has not been implemented yet.'
198 );
199 }
200
201 /**
202 * @todo Implement testFetchValuesFromRequest().
203 */
204 public function testFetchValuesFromRequest() {
205 // Remove the following lines when you implement this test.
206 $this->markTestIncomplete(
207 'This test has not been implemented yet.'
208 );
209 }
210
211 /**
212 * @todo Implement testOffsetExists().
213 */
214 public function testOffsetExists() {
215 // Remove the following lines when you implement this test.
216 $this->markTestIncomplete(
217 'This test has not been implemented yet.'
218 );
219 }
220
221 /**
222 * @todo Implement testOffsetGet().
223 */
224 public function testOffsetGet() {
225 // Remove the following lines when you implement this test.
226 $this->markTestIncomplete(
227 'This test has not been implemented yet.'
228 );
229 }
230
231 /**
232 * @todo Implement testOffsetSet().
233 */
234 public function testOffsetSet() {
235 // Remove the following lines when you implement this test.
236 $this->markTestIncomplete(
237 'This test has not been implemented yet.'
238 );
239 }
240
241 /**
242 * @todo Implement testOffsetUnset().
243 */
244 public function testOffsetUnset() {
245 // Remove the following lines when you implement this test.
246 $this->markTestIncomplete(
247 'This test has not been implemented yet.'
248 );
249 }
250 }