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