Exclude redirects from Special:Fewestrevisions
[lhc/web/wiklou.git] / tests / phpunit / includes / GlobalFunctions / wfStringToBoolTest.php
1 <?php
2
3 /**
4 * @group GlobalFunctions
5 * @covers ::wfStringToBool
6 */
7 class WfStringToBoolTest extends MediaWikiTestCase {
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
38 /**
39 * @dataProvider getTestCases
40 * @param string $str
41 * @param bool $bool
42 */
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 }