diff options
| author | Christian Weiske <cweiske@cweiske.de> | 2014-07-04 07:43:14 +0200 |
|---|---|---|
| committer | Christian Weiske <cweiske@cweiske.de> | 2014-07-04 07:43:14 +0200 |
| commit | 7a46f728adc38e3507f83015354cfbdd2de7969e (patch) | |
| tree | 5c493fb1628cbb6486c0366f79a69d124ba7350c | |
| parent | 3cd888fdd3bcd9f8d8ed47acf1c3420c09f4030d (diff) | |
| download | phorkie-7a46f728adc38e3507f83015354cfbdd2de7969e.tar.gz phorkie-7a46f728adc38e3507f83015354cfbdd2de7969e.zip | |
tests for baseurl detection
| -rw-r--r-- | tests/phorkie/ToolsTest.php | 37 | ||||
| -rw-r--r-- | tests/phpunit.xml | 10 |
2 files changed, 47 insertions, 0 deletions
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 @@ +<?php +namespace phorkie; + +class ToolsTest extends \PHPUnit_Framework_TestCase +{ + public function testDetectBaseUrlPhar() + { + $_SERVER['REQUEST_URI'] = '/phar/phorkie-0.4.0.phar/list.php'; + $_SERVER['SCRIPT_NAME'] = '/phar/phorkie-0.4.0.phar'; + $this->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 @@ +<phpunit strict="true" colors="true" bootstrap="../src/phorkie/autoload.php" backupGlobals="true"> + <php> + <includePath>../src/</includePath> + </php> + <filter> + <whitelist addUncoveredFilesFromWhitelist="true"> + <directory suffix=".php">../src/</directory> + </whitelist> + </filter> +</phpunit> |
