r106711 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106710‎ | r106711 | r106712 >
Date:22:28, 19 December 2011
Author:krinkle
Status:ok
Tags:
Comment:
[RL2] Fix comment typo
* Fix comment typo (instead if, instead of)
* Space after //
* Follows-up r106524
Modified paths:
  • /branches/RL2/extensions/Gadgets/tests/GadgetPrefsTest.php (modified) (history)

Diff [purge]

Index: branches/RL2/extensions/Gadgets/tests/GadgetPrefsTest.php
@@ -3,13 +3,13 @@
44 * @group Gadgets
55 */
66 class GadgetPrefsTest extends MediaWikiTestCase {
7 - //Test preferences descriptions validator (generic)
 7+ // Test preferences descriptions validator (generic)
88 function testPrefsDescriptions() {
99 $this->assertFalse( GadgetPrefs::isPrefsDescriptionValid( null ) );
1010 $this->assertFalse( GadgetPrefs::isPrefsDescriptionValid( array() ) );
1111 $this->assertFalse( GadgetPrefs::isPrefsDescriptionValid( array( 'fields' => array() ) ) );
1212
13 - //Test with stdClass instead if array
 13+ // Test with stdClass instead of array
1414 $this->assertFalse( GadgetPrefs::isPrefsDescriptionValid( (object)array(
1515 'fields' => array(
1616 array(
@@ -21,7 +21,7 @@
2222 )
2323 ) ) );
2424
25 - //Test with wrong type
 25+ // Test with wrong type
2626 $this->assertFalse( GadgetPrefs::isPrefsDescriptionValid( array(
2727 'fields' => array(
2828 array(
@@ -33,7 +33,7 @@
3434 )
3535 ) ) );
3636
37 - //Test with missing name
 37+ // Test with missing name
3838 $this->assertFalse( GadgetPrefs::isPrefsDescriptionValid( array(
3939 'fields' => array(
4040 array(
@@ -44,7 +44,7 @@
4545 )
4646 ) ) );
4747
48 - //Test with wrong preference name
 48+ // Test with wrong preference name
4949 $this->assertFalse( GadgetPrefs::isPrefsDescriptionValid( array(
5050 'fields' => array(
5151 array(
@@ -56,7 +56,7 @@
5757 )
5858 ) ) );
5959
60 - //Test with two fields with the same name
 60+ // Test with two fields with the same name
6161 $this->assertFalse( GadgetPrefs::isPrefsDescriptionValid( array(
6262 'fields' => array(
6363 array(
@@ -74,7 +74,7 @@
7575 )
7676 ) ) );
7777
78 - //Test with fields encoded as associative array instead of regular array
 78+ // Test with fields encoded as associative array instead of regular array
7979 $this->assertFalse( GadgetPrefs::isPrefsDescriptionValid( array(
8080 'fields' => array(
8181 'testBoolean' => array(
@@ -86,7 +86,7 @@
8787 )
8888 ) ) );
8989
90 - //Test with too long preference name (41 characters)
 90+ // Test with too long preference name (41 characters)
9191 $this->assertFalse( GadgetPrefs::isPrefsDescriptionValid( array(
9292 'fields' => array(
9393 array(
@@ -111,7 +111,7 @@
112112 ) ) );
113113
114114
115 - //Test with an unexisting field parameter
 115+ // Test with an unexisting field parameter
116116 $this->assertFalse( GadgetPrefs::isPrefsDescriptionValid( array(
117117 'fields' => array(
118118 array(
@@ -125,7 +125,7 @@
126126 ) ) );
127127 }
128128
129 - //Tests for 'label' type preferences
 129+ // Tests for 'label' type preferences
130130 function testPrefsDescriptionsLabel() {
131131 $correct = array(
132132 'fields' => array(
@@ -136,13 +136,13 @@
137137 )
138138 );
139139
140 - //Tests with correct values for 'label'
 140+ // Tests with correct values for 'label'
141141 foreach ( array( '', '@', '@message', 'foo', '@@not message' ) as $def ) {
142142 $correct['fields'][0]['label'] = $def;
143143 $this->assertTrue( GadgetPrefs::isPrefsDescriptionValid( $correct ) );
144144 }
145145
146 - //Tests with wrong values for 'label'
 146+ // Tests with wrong values for 'label'
147147 $wrong = $correct;
148148 foreach ( array( 0, 1, true, false, null, array() ) as $label ) {
149149 $wrong['fields'][0]['label'] = $label;
@@ -151,7 +151,7 @@
152152
153153 }
154154
155 - //Tests for 'boolean' type preferences
 155+ // Tests for 'boolean' type preferences
156156 function testPrefsDescriptionsBoolean() {
157157 $correct = array(
158158 'fields' => array(
@@ -179,7 +179,7 @@
180180
181181 $this->assertTrue( GadgetPrefs::isPrefsDescriptionValid( $correct2 ) );
182182
183 - //Tests with wrong default values
 183+ // Tests with wrong default values
184184 $wrong = $correct;
185185 foreach ( array( 0, 1, '', 'false', 'true', null, array() ) as $def ) {
186186 $wrong['fields'][0]['default'] = $def;
@@ -187,7 +187,7 @@
188188 }
189189 }
190190
191 - //Tests for 'string' type preferences
 191+ // Tests for 'string' type preferences
192192 function testPrefsDescriptionsString() {
193193 $correct = array(
194194 'fields' => array(
@@ -204,21 +204,21 @@
205205
206206 $this->assertTrue( GadgetPrefs::isPrefsDescriptionValid( $correct ) );
207207
208 - //Tests with wrong default values (when 'required' is not given)
 208+ // Tests with wrong default values (when 'required' is not given)
209209 $wrong = $correct;
210210 foreach ( array( null, '', true, false, 0, 1, array(), 'short', 'veryverylongstring' ) as $def ) {
211211 $wrong['fields'][0]['default'] = $def;
212212 $this->assertFalse( GadgetPrefs::isPrefsDescriptionValid( $wrong ) );
213213 }
214214
215 - //Tests with correct default values (when required is not given)
 215+ // Tests with correct default values (when required is not given)
216216 $correct2 = $correct;
217217 foreach ( array( '6chars', '1234567890' ) as $def ) {
218218 $correct2['fields'][0]['default'] = $def;
219219 $this->assertTrue( GadgetPrefs::isPrefsDescriptionValid( $correct2 ) );
220220 }
221221
222 - //Tests with wrong default values (when 'required' is false)
 222+ // Tests with wrong default values (when 'required' is false)
223223 $wrong = $correct;
224224 $wrong['fields'][0]['required'] = false;
225225 foreach ( array( null, true, false, 0, 1, array(), 'short', 'veryverylongstring' ) as $def ) {
@@ -226,7 +226,7 @@
227227 $this->assertFalse( GadgetPrefs::isPrefsDescriptionValid( $wrong ) );
228228 }
229229
230 - //Tests with correct default values (when required is false)
 230+ // Tests with correct default values (when required is false)
231231 $correct2 = $correct;
232232 $correct2['fields'][0]['required'] = false;
233233 foreach ( array( '', '6chars', '1234567890' ) as $def ) {
@@ -245,22 +245,22 @@
246246 )
247247 );
248248
249 - //Test with empty default when "required" is true
 249+ // Test with empty default when "required" is true
250250 $this->assertTrue( GadgetPrefs::isPrefsDescriptionValid( $correct ) );
251251
252 - //Test with empty default when "required" is true
 252+ // Test with empty default when "required" is true
253253 $wrong = $correct;
254254 $wrong['fields'][0]['required'] = true;
255255 $this->assertFalse( GadgetPrefs::isPrefsDescriptionValid( $wrong ) );
256256
257 - //Test with empty default when "required" is false and minlength is given
 257+ // Test with empty default when "required" is false and minlength is given
258258 $correct2 = $correct;
259259 $correct2['fields'][0]['required'] = false;
260260 $correct2['fields'][0]['minlength'] = 3;
261261 $this->assertTrue( GadgetPrefs::isPrefsDescriptionValid( $correct2 ) );
262262 }
263263
264 - //Tests for 'number' type preferences
 264+ // Tests for 'number' type preferences
265265 function testPrefsDescriptionsNumber() {
266266 $correctFloat = array(
267267 'fields' => array(
@@ -294,7 +294,7 @@
295295 $this->assertTrue( GadgetPrefs::isPrefsDescriptionValid( $correctFloat ) );
296296 $this->assertTrue( GadgetPrefs::isPrefsDescriptionValid( $correctInt ) );
297297
298 - //Tests with wrong default values (with 'required' = true)
 298+ // Tests with wrong default values (with 'required' = true)
299299 $wrongFloat = $correctFloat;
300300 foreach ( array( '', false, true, null, array(), -100, +100 ) as $def ) {
301301 $wrongFloat['fields'][0]['default'] = $def;
@@ -315,7 +315,7 @@
316316 }
317317 }
318318
319 - //Tests for 'select' type preferences
 319+ // Tests for 'select' type preferences
320320 function testPrefsDescriptionsSelect() {
321321 $correct = array(
322322 'fields' => array(
@@ -335,14 +335,14 @@
336336 );
337337
338338
339 - //Tests with correct default values
 339+ // Tests with correct default values
340340 $correct2 = $correct;
341341 foreach ( array( null, true, 3, 'test' ) as $def ) {
342342 $correct2['fields'][0]['default'] = $def;
343343 $this->assertTrue( GadgetPrefs::isPrefsDescriptionValid( $correct2 ) );
344344 }
345345
346 - //Tests with wrong default values
 346+ // Tests with wrong default values
347347 $wrong = $correct;
348348 foreach ( array( '', 'true', 'null', false, array(), 0, 1, 3.0001 ) as $def ) {
349349 $wrong['fields'][0]['default'] = $def;
@@ -350,7 +350,7 @@
351351 }
352352 }
353353
354 - //Tests for 'range' type preferences
 354+ // Tests for 'range' type preferences
355355 function testPrefsDescriptionsRange() {
356356 $correct = array(
357357 'fields' => array(
@@ -365,27 +365,27 @@
366366 )
367367 );
368368
369 - //Tests with correct default values
 369+ // Tests with correct default values
370370 $correct2 = $correct;
371371 foreach ( array( 15, 33, 45 ) as $def ) {
372372 $correct2['fields'][0]['default'] = $def;
373373 $this->assertTrue( GadgetPrefs::isPrefsDescriptionValid( $correct2 ) );
374374 }
375375
376 - //Tests with wrong default values
 376+ // Tests with wrong default values
377377 $wrong = $correct;
378378 foreach ( array( '', true, false, null, array(), '35', 14, 46, 30.2 ) as $def ) {
379379 $wrong['fields'][0]['default'] = $def;
380380 $this->assertFalse( GadgetPrefs::isPrefsDescriptionValid( $wrong ) );
381381 }
382382
383 - //Test with max not in the set min + k*step (step not given, so it's 1)
 383+ // Test with max not in the set min + k*step (step not given, so it's 1)
384384 $wrong = $correct;
385385 $wrong['fields'][0]['max'] = 45.5;
386386 $this->assertFalse( GadgetPrefs::isPrefsDescriptionValid( $wrong ) );
387387
388388
389 - //Tests with floating point min, max and step
 389+ // Tests with floating point min, max and step
390390 $correct = array(
391391 'fields' => array(
392392 array(
@@ -402,14 +402,14 @@
403403
404404 $this->assertTrue( GadgetPrefs::isPrefsDescriptionValid( $correct ) );
405405
406 - //Tests with correct default values
 406+ // Tests with correct default values
407407 $correct2 = $correct;
408408 foreach ( array( -2.8, -2.55, 0.20, 4.2 ) as $def ) {
409409 $correct2['fields'][0]['default'] = $def;
410410 $this->assertTrue( GadgetPrefs::isPrefsDescriptionValid( $correct2 ) );
411411 }
412412
413 - //Tests with wrong default values
 413+ // Tests with wrong default values
414414 $wrong = $correct;
415415 foreach ( array( '', true, false, null, array(), '0.20', -2.7, 0, 4.199999 ) as $def ) {
416416 $wrong['fields'][0]['default'] = $def;
@@ -417,7 +417,7 @@
418418 }
419419 }
420420
421 - //Tests for 'date' type preferences
 421+ // Tests for 'date' type preferences
422422 function testPrefsDescriptionsDate() {
423423 $correct = array(
424424 'fields' => array(
@@ -430,7 +430,7 @@
431431 )
432432 );
433433
434 - //Tests with correct default values
 434+ // Tests with correct default values
435435 $correct2 = $correct;
436436 foreach ( array(
437437 null,
@@ -443,7 +443,7 @@
444444 $this->assertTrue( GadgetPrefs::isPrefsDescriptionValid( $correct2 ) );
445445 }
446446
447 - //Tests with wrong default values
 447+ // Tests with wrong default values
448448 $wrong = $correct;
449449 foreach ( array(
450450 '', true, false, array(), 0,
@@ -467,7 +467,7 @@
468468 }
469469 }
470470
471 - //Tests for 'color' type preferences
 471+ // Tests for 'color' type preferences
472472 function testPrefsDescriptionsColor() {
473473 $correct = array(
474474 'fields' => array(
@@ -480,7 +480,7 @@
481481 )
482482 );
483483
484 - //Tests with correct default values
 484+ // Tests with correct default values
485485 $correct2 = $correct;
486486 foreach ( array(
487487 '#000000',
@@ -492,7 +492,7 @@
493493 $this->assertTrue( GadgetPrefs::isPrefsDescriptionValid( $correct2 ) );
494494 }
495495
496 - //Tests with wrong default values
 496+ // Tests with wrong default values
497497 $wrong = $correct;
498498 foreach ( array(
499499 '', true, false, null, 0, array(),
@@ -510,7 +510,7 @@
511511 }
512512 }
513513
514 - //Tests for 'composite' type fields
 514+ // Tests for 'composite' type fields
515515 function testPrefsDescriptionsComposite() {
516516 $correct = array(
517517 'fields' => array(
@@ -574,7 +574,7 @@
575575 $this->assertEquals( $prefs, array( 'foo' => array( 'bar' => false, 'car' => '#123456' ) ) );
576576 }
577577
578 - //Tests for 'list' type fields
 578+ // Tests for 'list' type fields
579579 function testPrefsDescriptionsList() {
580580 $correct = array(
581581 'fields' => array(
@@ -618,7 +618,7 @@
619619
620620 $this->assertEquals( GadgetPrefs::getMessages( $correct ), array( 'msg1', 'msg2' ) );
621621
622 - //Tests with correct pref values
 622+ // Tests with correct pref values
623623 $this->assertTrue( GadgetPrefs::checkPrefsAgainstDescription(
624624 $correct,
625625 array( 'foo' => array() )
@@ -643,7 +643,7 @@
644644 )
645645 ) );
646646
647 - //Tests with wrong pref values
 647+ // Tests with wrong pref values
648648 $this->assertFalse( GadgetPrefs::checkPrefsAgainstDescription(
649649 $correct,
650650 array( 'foo' => array(
@@ -665,7 +665,7 @@
666666 ) );
667667
668668
669 - //Tests with 'minlength' and 'maxlength' options
 669+ // Tests with 'minlength' and 'maxlength' options
670670 $wrong = $correct;
671671 $wrong['fields'][0]['minlength'] = 4;
672672 $wrong['fields'][0]['maxlength'] = 3; //maxlength < minlength, wrong
@@ -704,14 +704,14 @@
705705 )
706706 ) );
707707
708 - //Test with 'required'
 708+ // Test with 'required'
709709 $correct2['fields'][0]['required'] = false;
710710 $this->assertTrue( GadgetPrefs::checkPrefsAgainstDescription(
711711 $correct2,
712712 array( 'foo' => array() ) //empty array, must be accepted because "required" is false
713713 ) );
714714
715 - //Tests matchPrefsWithDescription
 715+ // Tests matchPrefsWithDescription
716716 $prefs = array( 'foo' => array(
717717 array(
718718 'bar' => null,

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r106524[RL2] Move GadgetPrefs-related tests from GadgetsTest.php to GadgetPrefsTest.php...catrope20:00, 17 December 2011

Status & tagging log