xref: /dokuwiki/_test/tests/inc/utf8_basename.test.php (revision 8cbc5ee84fe788597ede5266255a74af6da47555)
1f393a4ebSAndreas Gohr<?php
2f393a4ebSAndreas Gohr
3f393a4ebSAndreas Gohrclass utf8_basename_test extends DokuWikiTest {
4f393a4ebSAndreas Gohr
5f393a4ebSAndreas Gohr     function test1(){
6f393a4ebSAndreas Gohr        $data = array(
7f393a4ebSAndreas Gohr            array('/this/foo/bar.test.png',         '', 'bar.test.png'),
8f393a4ebSAndreas Gohr            array('\\this\\foo\\bar.test.png',      '', 'bar.test.png'),
9f393a4ebSAndreas Gohr            array('/this\\foo/bar.test.png',        '', 'bar.test.png'),
10f393a4ebSAndreas Gohr            array('/this/foo\\bar.test.png',        '', 'bar.test.png'),
11f393a4ebSAndreas Gohr
12f393a4ebSAndreas Gohr            array('/this/ДокуВики/bar.test.png',    '', 'bar.test.png'),
13f393a4ebSAndreas Gohr            array('\\this\\ДокуВики\\bar.test.png', '', 'bar.test.png'),
14f393a4ebSAndreas Gohr            array('/this\\ДокуВики/bar.test.png',   '', 'bar.test.png'),
15f393a4ebSAndreas Gohr            array('/this/ДокуВики\\bar.test.png',   '', 'bar.test.png'),
16f393a4ebSAndreas Gohr
17f393a4ebSAndreas Gohr            array('/this/foo/ДокуВики.test.png',    '', 'ДокуВики.test.png'),
18f393a4ebSAndreas Gohr            array('\\this\\foo\\ДокуВики.test.png', '', 'ДокуВики.test.png'),
19f393a4ebSAndreas Gohr            array('/this\\foo/ДокуВики.test.png',   '', 'ДокуВики.test.png'),
20f393a4ebSAndreas Gohr            array('/this/foo\\ДокуВики.test.png',   '', 'ДокуВики.test.png'),
21f393a4ebSAndreas Gohr
22f393a4ebSAndreas Gohr            array('/this/foo/bar.test.png',         '.png', 'bar.test'),
23f393a4ebSAndreas Gohr            array('\\this\\foo\\bar.test.png',      '.png', 'bar.test'),
24f393a4ebSAndreas Gohr            array('/this\\foo/bar.test.png',        '.png', 'bar.test'),
25f393a4ebSAndreas Gohr            array('/this/foo\\bar.test.png',        '.png', 'bar.test'),
26f393a4ebSAndreas Gohr
27f393a4ebSAndreas Gohr            array('/this/ДокуВики/bar.test.png',    '.png', 'bar.test'),
28f393a4ebSAndreas Gohr            array('\\this\\ДокуВики\\bar.test.png', '.png', 'bar.test'),
29f393a4ebSAndreas Gohr            array('/this\\ДокуВики/bar.test.png',   '.png', 'bar.test'),
30f393a4ebSAndreas Gohr            array('/this/ДокуВики\\bar.test.png',   '.png', 'bar.test'),
31f393a4ebSAndreas Gohr
32f393a4ebSAndreas Gohr            array('/this/foo/ДокуВики.test.png',    '.png', 'ДокуВики.test'),
33f393a4ebSAndreas Gohr            array('\\this\\foo\\ДокуВики.test.png', '.png', 'ДокуВики.test'),
34f393a4ebSAndreas Gohr            array('/this\\foo/ДокуВики.test.png',   '.png', 'ДокуВики.test'),
35f393a4ebSAndreas Gohr            array('/this/foo\\ДокуВики.test.png',   '.png', 'ДокуВики.test'),
36f393a4ebSAndreas Gohr
37f393a4ebSAndreas Gohr            array('/this/foo/bar.test.png',         '.foo', 'bar.test.png'),
38f393a4ebSAndreas Gohr            array('\\this\\foo\\bar.test.png',      '.foo', 'bar.test.png'),
39f393a4ebSAndreas Gohr            array('/this\\foo/bar.test.png',        '.foo', 'bar.test.png'),
40f393a4ebSAndreas Gohr            array('/this/foo\\bar.test.png',        '.foo', 'bar.test.png'),
41f393a4ebSAndreas Gohr
42f393a4ebSAndreas Gohr            array('/this/ДокуВики/bar.test.png',    '.foo', 'bar.test.png'),
43f393a4ebSAndreas Gohr            array('\\this\\ДокуВики\\bar.test.png', '.foo', 'bar.test.png'),
44f393a4ebSAndreas Gohr            array('/this\\ДокуВики/bar.test.png',   '.foo', 'bar.test.png'),
45f393a4ebSAndreas Gohr            array('/this/ДокуВики\\bar.test.png',   '.foo', 'bar.test.png'),
46f393a4ebSAndreas Gohr
47f393a4ebSAndreas Gohr            array('/this/foo/ДокуВики.test.png',    '.foo', 'ДокуВики.test.png'),
48f393a4ebSAndreas Gohr            array('\\this\\foo\\ДокуВики.test.png', '.foo', 'ДокуВики.test.png'),
49f393a4ebSAndreas Gohr            array('/this\\foo/ДокуВики.test.png',   '.foo', 'ДокуВики.test.png'),
50f393a4ebSAndreas Gohr            array('/this/foo\\ДокуВики.test.png',   '.foo', 'ДокуВики.test.png'),
51f393a4ebSAndreas Gohr
52f393a4ebSAndreas Gohr
53f393a4ebSAndreas Gohr            array('/this/foo/ДокуВики.test.Вик',    '.foo', 'ДокуВики.test.Вик'),
54f393a4ebSAndreas Gohr            array('\\this\\foo\\ДокуВики.test.Вик', '.foo', 'ДокуВики.test.Вик'),
55f393a4ebSAndreas Gohr            array('/this\\foo/ДокуВики.test.Вик',   '.foo', 'ДокуВики.test.Вик'),
56f393a4ebSAndreas Gohr            array('/this/foo\\ДокуВики.test.Вик',   '.foo', 'ДокуВики.test.Вик'),
57f393a4ebSAndreas Gohr
58f393a4ebSAndreas Gohr            array('/this/foo/ДокуВики.test.Вик',    '.Вик', 'ДокуВики.test'),
59f393a4ebSAndreas Gohr            array('\\this\\foo\\ДокуВики.test.Вик', '.Вик', 'ДокуВики.test'),
60f393a4ebSAndreas Gohr            array('/this\\foo/ДокуВики.test.Вик',   '.Вик', 'ДокуВики.test'),
61f393a4ebSAndreas Gohr            array('/this/foo\\ДокуВики.test.Вик',   '.Вик', 'ДокуВики.test'),
62420addb2SAndreas Gohr
63420addb2SAndreas Gohr            array('bar.test.png', '', 'bar.test.png'),
64420addb2SAndreas Gohr            array('bar.test.png', '.png', 'bar.test'),
65a8c343f2SMichael Hamann
66a8c343f2SMichael Hamann            array('/bar.test.png', '', 'bar.test.png'),
67a8c343f2SMichael Hamann            array('/bar.test.png', '.png', 'bar.test'),
68fa446926SAndreas Gohr            array('\\bar.test.png', '', 'bar.test.png'),
69fa446926SAndreas Gohr            array('\\bar.test.png', '.png', 'bar.test'),
70fa446926SAndreas Gohr            array('\\/bar.test.png', '', 'bar.test.png'),
71fa446926SAndreas Gohr            array('\\/bar.test.png', '.png', 'bar.test'),
72fa446926SAndreas Gohr            array('/\\bar.test.png', '', 'bar.test.png'),
73fa446926SAndreas Gohr            array('/\\bar.test.png', '.png', 'bar.test'),
74fa446926SAndreas Gohr
75fa446926SAndreas Gohr            // PHP's basename does this too:
76fa446926SAndreas Gohr            array('foo/',   '', 'foo'),
77fa446926SAndreas Gohr            array('foo\\',  '', 'foo'),
78fa446926SAndreas Gohr            array('foo\\/', '', 'foo'),
79fa446926SAndreas Gohr            array('foo/\\', '', 'foo'),
80fa446926SAndreas Gohr            array('foo.png/',   '.png', 'foo'),
81fa446926SAndreas Gohr            array('foo.png\\',  '.png', 'foo'),
82fa446926SAndreas Gohr            array('foo.png\\/', '.png', 'foo'),
83fa446926SAndreas Gohr            array('foo.png/\\', '.png', 'foo'),
84f393a4ebSAndreas Gohr        );
85f393a4ebSAndreas Gohr
86f393a4ebSAndreas Gohr        foreach($data as $test){
87*8cbc5ee8SAndreas Gohr            $this->assertEquals($test[2], \dokuwiki\Utf8\PhpString::basename($test[0], $test[1]), "input: ('".$test[0]."', '".$test[1]."')");
88f393a4ebSAndreas Gohr        }
89f393a4ebSAndreas Gohr     }
90f393a4ebSAndreas Gohr
91f393a4ebSAndreas Gohr}
92