From f40a91b0a300377d7c74e764bbf83b27a3dfae5f Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Sun, 6 Jul 2014 14:20:56 +0200 Subject: fix basedir detection for rewritten paths --- tests/phorkie/ToolsTest.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'tests') diff --git a/tests/phorkie/ToolsTest.php b/tests/phorkie/ToolsTest.php index 021797d..d8df8f4 100644 --- a/tests/phorkie/ToolsTest.php +++ b/tests/phorkie/ToolsTest.php @@ -3,6 +3,11 @@ namespace phorkie; class ToolsTest extends \PHPUnit_Framework_TestCase { + public function setUp() + { + $_GET[] = array(); + } + public function testDetectBaseUrlPhar() { $_SERVER['REQUEST_URI'] = '/phar/phorkie-0.4.0.phar/list.php'; @@ -34,6 +39,22 @@ class ToolsTest extends \PHPUnit_Framework_TestCase $this->assertEquals('/foo/', Tools::detectBaseUrl()); } + public function testDetectBaseUrlEdit() + { + $_GET['id'] = 82; + $_SERVER['REQUEST_URI'] = '/82/edit'; + $_SERVER['SCRIPT_NAME'] = '/edit.php'; + $this->assertEquals('/', Tools::detectBaseUrl()); + } + + public function testDetectBaseUrlEditSubdir() + { + $_GET['id'] = 82; + $_SERVER['REQUEST_URI'] = '/foo/82/edit'; + $_SERVER['SCRIPT_NAME'] = '/edit.php'; + $this->assertEquals('/foo/', Tools::detectBaseUrl()); + } + public function testFoldPathParentSingle() { $this->assertEquals( -- cgit v1.2.3