xref: /dokuwiki/_test/tests/inc/utf8_basename.test.php (revision a8c343f2838765f8034ee6b91263b1b417f3a7ec)
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'),
65*a8c343f2SMichael Hamann
66*a8c343f2SMichael Hamann            array('/bar.test.png', '', 'bar.test.png'),
67*a8c343f2SMichael Hamann            array('\\bar.test.png', '', 'bar.test.png'),
68*a8c343f2SMichael Hamann            array('/bar.test.png', '.png', 'bar.test'),
69f393a4ebSAndreas Gohr        );
70f393a4ebSAndreas Gohr
71f393a4ebSAndreas Gohr        foreach($data as $test){
72f393a4ebSAndreas Gohr            $this->assertEquals($test[2], utf8_basename($test[0], $test[1]), "input: ('".$test[0]."', '".$test[1]."')");
73f393a4ebSAndreas Gohr        }
74f393a4ebSAndreas Gohr     }
75f393a4ebSAndreas Gohr
76f393a4ebSAndreas Gohr}