xref: /dokuwiki/_test/tests/inc/pageutils_nons.test.php (revision abe29f62bf6f821be6fd94e83404da1ff9d64d58)
1<?php
2
3class init_noNS_test extends DokuWikiTest {
4
5    /**
6     * @dataProvider noNSProvider
7     */
8    public function test_noNS($input, $expected)
9    {
10        global $conf;
11        $conf['start'] = 'start';
12
13        $this->assertSame($expected, noNS($input), $input);
14    }
15
16    public function noNSProvider()
17    {
18        return [
19            ['0:0:0', '0'],
20            ['0:0:start', 'start'],
21            ['foo:0', '0'],
22            ['0', '0'],
23        ];
24    }
25
26    /**
27     * @dataProvider noNSorNSProvider
28     */
29    public function test_noNSorNS($input, $expected)
30    {
31        global $conf;
32        $conf['start'] = 'start';
33
34        $this->assertSame($expected, noNSorNS($input), $input);
35    }
36
37    public function noNSorNSProvider()
38    {
39        return [
40            ['0:0:0', '0'],
41            ['0:0:start', '0'],
42            ['0:start', '0'],
43            ['0:foo', 'foo'],
44            ['foo:0', '0'],
45            ['0', '0'],
46            ['0:', '0'],
47            ['a:b:', 'b'], // breadcrumbs code passes IDs ending with a colon #3114
48        ];
49    }
50
51}
52//Setup VIM: ex: et ts=4 :
53