wiki.techinc.nl/tests/phpunit/includes/GlobalFunctions/wfStringToBoolTest.php
Legoktm 4e35134f7a Revert "Separate MediaWiki unit and integration tests"
This reverts commit 0a2b996278.

Reason for revert: Broke postgres tests.

Change-Id: I27d8e0c807ad5f0748b9611a4f3df84cc213fbe1
2019-06-13 23:00:08 +00:00

51 lines
944 B
PHP

<?php
/**
* @group GlobalFunctions
* @covers ::wfStringToBool
*/
class WfStringToBoolTest extends MediaWikiTestCase {
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 ) );
}
}
}