MediaWiki REL1_31
wfStringToBoolTest.php
Go to the documentation of this file.
1<?php
2
8
9 public function getTestCases() {
10 return [
11 [ 'true', true ],
12 [ 'on', true ],
13 [ 'yes', true ],
14 [ 'TRUE', true ],
15 [ 'YeS', true ],
16 [ 'On', true ],
17 [ '1', true ],
18 [ '+1', true ],
19 [ '01', true ],
20 [ '-001', true ],
21 [ ' 1', true ],
22 [ '-1 ', true ],
23 [ '', false ],
24 [ '0', false ],
25 [ 'false', false ],
26 [ 'NO', false ],
27 [ 'NOT', false ],
28 [ 'never', false ],
29 [ '!&', false ],
30 [ '-0', false ],
31 [ '+0', false ],
32 [ 'forget about it', false ],
33 [ ' on', false ],
34 [ 'true ', false ],
35 ];
36 }
37
43 public function testStr2Bool( $str, $bool ) {
44 if ( $bool ) {
45 $this->assertTrue( wfStringToBool( $str ) );
46 } else {
47 $this->assertFalse( wfStringToBool( $str ) );
48 }
49 }
50
51}
wfStringToBool( $val)
Convert string value to boolean, when the following are interpreted as true:
GlobalFunctions wfStringToBool.
testStr2Bool( $str, $bool)
getTestCases
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
Definition hooks.txt:2006
processing should stop and the error should be shown to the user * false
Definition hooks.txt:187