xref: /PHP-8.2/ext/spl/tests/gh11338.phpt (revision bce53606)
1--TEST--
2GH-11338 (SplFileInfo empty getBasename with more than on slash)
3--FILE--
4<?php
5
6function test($path) {
7    echo "Testing: '$path'\n";
8    $file = new \SplFileInfo($path);
9    var_dump($file->getBasename());
10    var_dump($file->getFilename());
11}
12
13test('/dir/anotherdir/basedir//');
14test('/dir/anotherdir/basedir/');
15test('/dir/anotherdir/basedir');
16test('/dir/anotherdir//basedir');
17test('///');
18test('//');
19test('/');
20test('');
21
22?>
23--EXPECT--
24Testing: '/dir/anotherdir/basedir//'
25string(7) "basedir"
26string(7) "basedir"
27Testing: '/dir/anotherdir/basedir/'
28string(7) "basedir"
29string(7) "basedir"
30Testing: '/dir/anotherdir/basedir'
31string(7) "basedir"
32string(7) "basedir"
33Testing: '/dir/anotherdir//basedir'
34string(7) "basedir"
35string(7) "basedir"
36Testing: '///'
37string(0) ""
38string(1) "/"
39Testing: '//'
40string(0) ""
41string(1) "/"
42Testing: '/'
43string(0) ""
44string(1) "/"
45Testing: ''
46string(0) ""
47string(0) ""
48