xref: /dokuwiki/_test/tests/inc/io_createnamespace.test.php (revision bfc167db63967f8c872b3d797ca81138b9011ef4)
1<?php
2
3class io_createnamespace_test extends DokuWikiTest
4{
5    /**
6     * Test that io_createNamespace throws on excessively deep hierarchies
7     */
8    public function test_depth_limit()
9    {
10        $this->expectException(RuntimeException::class);
11
12        // build an ID with 200 segments — well above the 128 limit
13        $segments = array_fill(0, 200, 'ns');
14        $segments[] = 'file.txt';
15        $deep_id = implode(':', $segments);
16
17        io_createNamespace($deep_id, 'media');
18    }
19
20    /**
21     * Test that io_createNamespace still works for reasonable depths
22     */
23    public function test_normal_depth()
24    {
25        global $conf;
26
27        io_createNamespace('a:b:c:file.txt', 'media');
28
29        $path = $conf['mediadir'] . '/a/b/c';
30        $this->assertDirectoryExists($path, 'Normal namespace depth should be created');
31    }
32}
33