Page MenuHomeWickedGov Phorge

WfStringToBoolTest.php
No OneTemporary

Size
948 B
Referenced Files
None
Subscribers
None

WfStringToBoolTest.php

<?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 ) );
}
}
}

File Metadata

Mime Type
text/x-php
Expires
Sat, Oct 3, 22:16 (1 w, 3 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
b4/3c/e5b6683656049f38d8fb288139bb
Default Alt Text
WfStringToBoolTest.php (948 B)

Event Timeline