4 class ToolsTest extends \PHPUnit_Framework_TestCase
6 public function setUp()
11 public function testDetectBaseUrlPhar()
13 $_SERVER['REQUEST_URI'] = '/phar/phorkie-0.4.0.phar/list.php';
14 $_SERVER['SCRIPT_NAME'] = '/phar/phorkie-0.4.0.phar';
16 '/phar/phorkie-0.4.0.phar/',
17 Tools::detectBaseUrl()
21 public function testDetectBaseUrlRoot()
23 $_SERVER['REQUEST_URI'] = '/new';
24 $_SERVER['SCRIPT_NAME'] = '/new.php';
25 $this->assertEquals('/', Tools::detectBaseUrl());
28 public function testDetectBaseUrlRootWithPhp()
30 $_SERVER['REQUEST_URI'] = '/new.php';
31 $_SERVER['SCRIPT_NAME'] = '/new.php';
32 $this->assertEquals('/', Tools::detectBaseUrl());
35 public function testDetectBaseUrlSubdir()
37 $_SERVER['REQUEST_URI'] = '/foo/new';
38 $_SERVER['SCRIPT_NAME'] = '/new.php';
39 $this->assertEquals('/foo/', Tools::detectBaseUrl());
42 public function testDetectBaseUrlEdit()
45 $_SERVER['REQUEST_URI'] = '/82/edit';
46 $_SERVER['SCRIPT_NAME'] = '/edit.php';
47 $this->assertEquals('/', Tools::detectBaseUrl());
50 public function testDetectBaseUrlEditSubdir()
53 $_SERVER['REQUEST_URI'] = '/foo/82/edit';
54 $_SERVER['SCRIPT_NAME'] = '/edit.php';
55 $this->assertEquals('/foo/', Tools::detectBaseUrl());
58 public function testFoldPathParentSingle()
62 Tools::foldPath('/path/to/bar/../foo')
66 public function testFoldPathParentDouble()
70 Tools::foldPath('/path/to/foo/bar/../../foo')
74 public function testFoldPathCurrentSingle()
78 Tools::foldPath('/path/to/foo/./')
82 public function testFoldPathCurrentThrice()
86 Tools::foldPath('/path/././to/foo/./')