78e09e60baebd00cc37055bd9c836caa4120f7af
[lhc/web/wiklou.git] / tests / phpunit / includes / GlobalFunctions / wfBaseNameTest.php
1 <?php
2 /**
3 * @group GlobalFunctions
4 * @covers ::wfBaseName
5 */
6 class WfBaseNameTest extends MediaWikiTestCase {
7 /**
8 * @dataProvider providePaths
9 */
10 public function testBaseName( $fullpath, $basename ) {
11 $this->assertEquals( $basename, wfBaseName( $fullpath ),
12 "wfBaseName('$fullpath') => '$basename'" );
13 }
14
15 public static function providePaths() {
16 return [
17 [ '', '' ],
18 [ '/', '' ],
19 [ '\\', '' ],
20 [ '//', '' ],
21 [ '\\\\', '' ],
22 [ 'a', 'a' ],
23 [ 'aaaa', 'aaaa' ],
24 [ '/a', 'a' ],
25 [ '\\a', 'a' ],
26 [ '/aaaa', 'aaaa' ],
27 [ '\\aaaa', 'aaaa' ],
28 [ '/aaaa/', 'aaaa' ],
29 [ '\\aaaa\\', 'aaaa' ],
30 [ '\\aaaa\\', 'aaaa' ],
31 [
32 '/mnt/upload3/wikipedia/en/thumb/8/8b/'
33 . 'Zork_Grand_Inquisitor_box_cover.jpg/93px-Zork_Grand_Inquisitor_box_cover.jpg',
34 '93px-Zork_Grand_Inquisitor_box_cover.jpg'
35 ],
36 [ 'C:\\Progra~1\\Wikime~1\\Wikipe~1\\VIEWER.EXE', 'VIEWER.EXE' ],
37 [ 'Östergötland_coat_of_arms.png', 'Östergötland_coat_of_arms.png' ],
38 ];
39 }
40 }