7a5be16f71367fd95f445626610e027664fc441d
[phorkie.git] / tests / phorkie / ToolsTest.php
1 <?php
2 namespace phorkie;
3
4 class ToolsTest extends \PHPUnit_Framework_TestCase
5 {
6     public function testDetectBaseUrlPhar()
7     {
8         $_SERVER['REQUEST_URI'] = '/phar/phorkie-0.4.0.phar/list.php';
9         $_SERVER['SCRIPT_NAME'] = '/phar/phorkie-0.4.0.phar';
10         $this->assertEquals(
11             '/phar/phorkie-0.4.0.phar/',
12             Tools::detectBaseUrl()
13         );
14     }
15
16     public function testDetectBaseUrlRoot()
17     {
18         $_SERVER['REQUEST_URI'] = '/new';
19         $_SERVER['SCRIPT_NAME'] = '/new.php';
20         $this->assertEquals('/', Tools::detectBaseUrl());
21     }
22
23     public function testDetectBaseUrlRootWithPhp()
24     {
25         $_SERVER['REQUEST_URI'] = '/new.php';
26         $_SERVER['SCRIPT_NAME'] = '/new.php';
27         $this->assertEquals('/', Tools::detectBaseUrl());
28     }
29
30     public function testDetectBaseUrlSubdir()
31     {
32         $_SERVER['REQUEST_URI'] = '/foo/new';
33         $_SERVER['SCRIPT_NAME'] = '/new.php';
34         $this->assertEquals('/foo/', Tools::detectBaseUrl());
35     }
36 }
37 ?>