2011-10-16 18:35:32 +00:00
|
|
|
<?php
|
|
|
|
|
|
2013-10-24 09:53:24 +00:00
|
|
|
/**
|
2014-07-18 19:35:43 +00:00
|
|
|
* @group GlobalFunctions
|
2013-10-24 09:53:24 +00:00
|
|
|
* @covers ::wfShorthandToInteger
|
|
|
|
|
*/
|
2013-02-21 23:58:19 +00:00
|
|
|
class WfShorthandToIntegerTest extends MediaWikiTestCase {
|
2011-10-16 18:35:32 +00:00
|
|
|
/**
|
|
|
|
|
* @dataProvider provideABunchOfShorthands
|
|
|
|
|
*/
|
2013-10-23 22:51:31 +00:00
|
|
|
public function testWfShorthandToInteger( $input, $output, $description ) {
|
2011-10-16 18:35:32 +00:00
|
|
|
$this->assertEquals(
|
|
|
|
|
wfShorthandToInteger( $input ),
|
|
|
|
|
$output,
|
|
|
|
|
$description
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-22 02:12:37 +00:00
|
|
|
public static function provideABunchOfShorthands() {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
|
|
|
|
[ '', -1, 'Empty string' ],
|
|
|
|
|
[ ' ', -1, 'String of spaces' ],
|
|
|
|
|
[ '1G', 1024 * 1024 * 1024, 'One gig uppercased' ],
|
|
|
|
|
[ '1g', 1024 * 1024 * 1024, 'One gig lowercased' ],
|
|
|
|
|
[ '1M', 1024 * 1024, 'One meg uppercased' ],
|
|
|
|
|
[ '1m', 1024 * 1024, 'One meg lowercased' ],
|
|
|
|
|
[ '1K', 1024, 'One kb uppercased' ],
|
|
|
|
|
[ '1k', 1024, 'One kb lowercased' ],
|
|
|
|
|
];
|
2011-10-16 18:35:32 +00:00
|
|
|
}
|
|
|
|
|
}
|