diff options
author | Amir Sarabadani <Ladsgroup@gmail.com> | 2019-07-13 22:50:28 +0200 |
---|---|---|
committer | Amir Sarabadani <ladsgroup@gmail.com> | 2019-07-14 01:28:07 +0200 |
commit | 06f645c453ebd1a3bbd065abd4f29e909f5656c7 (patch) | |
tree | 61565db57ed8ff33cc6384a84374f0b7f67994cd /tests/phpunit/unit/includes/GlobalFunctions/wfStringToBoolTest.php | |
parent | 3fda59f9621f55aed5602802d8e9d4dbc9d8dfa6 (diff) | |
download | mediawikicore-06f645c453ebd1a3bbd065abd4f29e909f5656c7.tar.gz mediawikicore-06f645c453ebd1a3bbd065abd4f29e909f5656c7.zip |
Load GlobalFunctions.php to tests/phpunit/bootstrap.php
That mostly enables testing global functions
Bug: T87781
Change-Id: Ib42c56a67926ebcdba53f4c6c54a5bff98cb77a3
Diffstat (limited to 'tests/phpunit/unit/includes/GlobalFunctions/wfStringToBoolTest.php')
-rw-r--r-- | tests/phpunit/unit/includes/GlobalFunctions/wfStringToBoolTest.php | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/phpunit/unit/includes/GlobalFunctions/wfStringToBoolTest.php b/tests/phpunit/unit/includes/GlobalFunctions/wfStringToBoolTest.php new file mode 100644 index 000000000000..b99d695ffc2a --- /dev/null +++ b/tests/phpunit/unit/includes/GlobalFunctions/wfStringToBoolTest.php @@ -0,0 +1,51 @@ +<?php + +/** + * @group GlobalFunctions + * @covers ::wfStringToBool + */ +class WfStringToBoolTest extends MediaWikiUnitTestCase { + + public function getTestCases() { + return [ + [ 'true', true ], + [ 'on', true ], + [ 'yes', true ], + [ 'TRUE', true ], + [ 'YeS', true ], + [ 'On', true ], + [ '1', true ], + [ '+1', true ], + [ '01', true ], + [ '-001', true ], + [ ' 1', true ], + [ '-1 ', true ], + [ '', false ], + [ '0', false ], + [ 'false', false ], + [ 'NO', false ], + [ 'NOT', false ], + [ 'never', false ], + [ '!&', false ], + [ '-0', false ], + [ '+0', false ], + [ 'forget about it', false ], + [ ' on', false ], + [ 'true ', false ], + ]; + } + + /** + * @dataProvider getTestCases + * @param string $str + * @param bool $bool + */ + public function testStr2Bool( $str, $bool ) { + if ( $bool ) { + $this->assertTrue( wfStringToBool( $str ) ); + } else { + $this->assertFalse( wfStringToBool( $str ) ); + } + } + +} |