2012-01-09 16:30:32 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
2014-07-18 19:35:43 +00:00
|
|
|
* @group GlobalFunctions
|
2013-10-24 09:53:24 +00:00
|
|
|
* @covers ::wfBaseName
|
2012-01-09 16:30:32 +00:00
|
|
|
*/
|
2013-02-21 23:58:19 +00:00
|
|
|
class WfBaseNameTest extends MediaWikiTestCase {
|
2012-01-09 16:30:32 +00:00
|
|
|
/**
|
|
|
|
|
* @dataProvider providePaths
|
|
|
|
|
*/
|
2013-10-23 22:51:31 +00:00
|
|
|
public function testBaseName( $fullpath, $basename ) {
|
2012-01-09 16:30:32 +00:00
|
|
|
$this->assertEquals( $basename, wfBaseName( $fullpath ),
|
2013-02-14 11:22:13 +00:00
|
|
|
"wfBaseName('$fullpath') => '$basename'" );
|
2012-01-09 16:30:32 +00:00
|
|
|
}
|
2013-02-14 11:22:13 +00:00
|
|
|
|
2013-03-22 02:12:37 +00:00
|
|
|
public static function providePaths() {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
|
|
|
|
[ '', '' ],
|
|
|
|
|
[ '/', '' ],
|
|
|
|
|
[ '\\', '' ],
|
|
|
|
|
[ '//', '' ],
|
|
|
|
|
[ '\\\\', '' ],
|
|
|
|
|
[ 'a', 'a' ],
|
|
|
|
|
[ 'aaaa', 'aaaa' ],
|
|
|
|
|
[ '/a', 'a' ],
|
|
|
|
|
[ '\\a', 'a' ],
|
|
|
|
|
[ '/aaaa', 'aaaa' ],
|
|
|
|
|
[ '\\aaaa', 'aaaa' ],
|
|
|
|
|
[ '/aaaa/', 'aaaa' ],
|
|
|
|
|
[ '\\aaaa\\', 'aaaa' ],
|
|
|
|
|
[ '\\aaaa\\', 'aaaa' ],
|
|
|
|
|
[
|
2014-04-24 09:47:06 +00:00
|
|
|
'/mnt/upload3/wikipedia/en/thumb/8/8b/'
|
|
|
|
|
. 'Zork_Grand_Inquisitor_box_cover.jpg/93px-Zork_Grand_Inquisitor_box_cover.jpg',
|
|
|
|
|
'93px-Zork_Grand_Inquisitor_box_cover.jpg'
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
[ 'C:\\Progra~1\\Wikime~1\\Wikipe~1\\VIEWER.EXE', 'VIEWER.EXE' ],
|
|
|
|
|
[ 'Östergötland_coat_of_arms.png', 'Östergötland_coat_of_arms.png' ],
|
|
|
|
|
];
|
2012-01-09 16:30:32 +00:00
|
|
|
}
|
|
|
|
|
}
|