From 7a46f728adc38e3507f83015354cfbdd2de7969e Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Fri, 4 Jul 2014 07:43:14 +0200 Subject: [PATCH] tests for baseurl detection --- tests/phorkie/ToolsTest.php | 37 +++++++++++++++++++++++++++++++++++++ tests/phpunit.xml | 10 ++++++++++ 2 files changed, 47 insertions(+) create mode 100644 tests/phorkie/ToolsTest.php create mode 100644 tests/phpunit.xml diff --git a/tests/phorkie/ToolsTest.php b/tests/phorkie/ToolsTest.php new file mode 100644 index 0000000..7a5be16 --- /dev/null +++ b/tests/phorkie/ToolsTest.php @@ -0,0 +1,37 @@ +assertEquals( + '/phar/phorkie-0.4.0.phar/', + Tools::detectBaseUrl() + ); + } + + public function testDetectBaseUrlRoot() + { + $_SERVER['REQUEST_URI'] = '/new'; + $_SERVER['SCRIPT_NAME'] = '/new.php'; + $this->assertEquals('/', Tools::detectBaseUrl()); + } + + public function testDetectBaseUrlRootWithPhp() + { + $_SERVER['REQUEST_URI'] = '/new.php'; + $_SERVER['SCRIPT_NAME'] = '/new.php'; + $this->assertEquals('/', Tools::detectBaseUrl()); + } + + public function testDetectBaseUrlSubdir() + { + $_SERVER['REQUEST_URI'] = '/foo/new'; + $_SERVER['SCRIPT_NAME'] = '/new.php'; + $this->assertEquals('/foo/', Tools::detectBaseUrl()); + } +} +?> diff --git a/tests/phpunit.xml b/tests/phpunit.xml new file mode 100644 index 0000000..f501a40 --- /dev/null +++ b/tests/phpunit.xml @@ -0,0 +1,10 @@ + + + ../src/ + + + + ../src/ + + + -- 2.30.2