unit tests : update the tests to route to be compliant with mod_rewrite or not
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2157 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
@@ -6,8 +6,9 @@
|
|||||||
/** Test the route.php file */
|
/** Test the route.php file */
|
||||||
class test_route extends PHPUnit_Framework_TestCase
|
class test_route extends PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
|
/// RELATIVE ///
|
||||||
/** Entry null */
|
/** Entry null */
|
||||||
public function test_baseURL_1 ()
|
public function test_baseURL_1_relative ()
|
||||||
{
|
{
|
||||||
$route = new route ();
|
$route = new route ();
|
||||||
$route->baseURL ();
|
$route->baseURL ();
|
||||||
@@ -15,18 +16,18 @@ class test_route extends PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Port 80 and HTTP without module */
|
/** Port 80 and HTTP without module */
|
||||||
public function test_baseURL_2 ()
|
public function test_baseURL_2_relative ()
|
||||||
{
|
{
|
||||||
$_SERVER["SERVER_NAME"] = "localhost";
|
$_SERVER["SERVER_NAME"] = "localhost";
|
||||||
$_SERVER["SERVER_PORT"] = "80";
|
$_SERVER["SERVER_PORT"] = "80";
|
||||||
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
||||||
$route = new route ();
|
$route = new route ();
|
||||||
echo $route->baseURL ();
|
echo $route->baseURL ();
|
||||||
$this->expectOutputString("http://localhost/");
|
$this->expectOutputString("./");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Port 443 and HTTPS without module */
|
/** Port 443 and HTTPS without module */
|
||||||
public function test_baseURL_3 ()
|
public function test_baseURL_3_relative ()
|
||||||
{
|
{
|
||||||
unset ($_SERVER["HTTPS"]);
|
unset ($_SERVER["HTTPS"]);
|
||||||
$_SERVER["SERVER_NAME"] = "localhost";
|
$_SERVER["SERVER_NAME"] = "localhost";
|
||||||
@@ -35,126 +36,288 @@ class test_route extends PHPUnit_Framework_TestCase
|
|||||||
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
||||||
$route = new route ();
|
$route = new route ();
|
||||||
echo $route->baseURL ();
|
echo $route->baseURL ();
|
||||||
|
$this->expectOutputString("./");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Port 888 and HTTP without module */
|
||||||
|
public function test_baseURL_4_relative ()
|
||||||
|
{
|
||||||
|
unset ($_SERVER["HTTPS"]);
|
||||||
|
$_SERVER["SERVER_NAME"] = "localhost";
|
||||||
|
$_SERVER["SERVER_PORT"] = "888";
|
||||||
|
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
||||||
|
$route = new route ();
|
||||||
|
echo $route->baseURL ();
|
||||||
|
$this->expectOutputString("./");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Port 888 and HTTPS without module */
|
||||||
|
public function test_baseURL_5_relative ()
|
||||||
|
{
|
||||||
|
$_SERVER["SERVER_NAME"] = "localhost";
|
||||||
|
$_SERVER["SERVER_PORT"] = "888";
|
||||||
|
$_SERVER["HTTPS"] = true;
|
||||||
|
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
||||||
|
$route = new route ();
|
||||||
|
echo $route->baseURL ();
|
||||||
|
$this->expectOutputString("./");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Port 80 and HTTP with module */
|
||||||
|
public function test_baseURL_2_module_relative ()
|
||||||
|
{
|
||||||
|
unset ($_SERVER["HTTPS"]);
|
||||||
|
$_SERVER["SERVER_NAME"] = "localhost";
|
||||||
|
$_SERVER["SERVER_PORT"] = "80";
|
||||||
|
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
|
||||||
|
$route = new route ();
|
||||||
|
echo $route->baseURL ("module");
|
||||||
|
$this->expectOutputString("./");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Port 443 and HTTPS with module */
|
||||||
|
public function test_baseURL_3_module_relative ()
|
||||||
|
{
|
||||||
|
$_SERVER["SERVER_NAME"] = "localhost";
|
||||||
|
$_SERVER["SERVER_PORT"] = "443";
|
||||||
|
$_SERVER["HTTPS"] = true;
|
||||||
|
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
|
||||||
|
$route = new route ();
|
||||||
|
echo $route->baseURL ("module");
|
||||||
|
$this->expectOutputString("./");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Port 888 and HTTP with module */
|
||||||
|
public function test_baseURL_4_module_relative ()
|
||||||
|
{
|
||||||
|
unset ($_SERVER["HTTPS"]);
|
||||||
|
$_SERVER["SERVER_NAME"] = "localhost";
|
||||||
|
$_SERVER["SERVER_PORT"] = "888";
|
||||||
|
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
|
||||||
|
$route = new route ();
|
||||||
|
echo $route->baseURL ("module");
|
||||||
|
$this->expectOutputString("./");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Port 888 and HTTPS with module */
|
||||||
|
public function test_baseURL_5_module_relative ()
|
||||||
|
{
|
||||||
|
$_SERVER["SERVER_NAME"] = "localhost";
|
||||||
|
$_SERVER["SERVER_PORT"] = "888";
|
||||||
|
$_SERVER["HTTPS"] = true;
|
||||||
|
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
|
||||||
|
$route = new route ();
|
||||||
|
echo $route->baseURL ("module");
|
||||||
|
$this->expectOutputString("./");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// ABSOLUTE ///
|
||||||
|
/** Entry null */
|
||||||
|
public function test_baseURL_1_absolute ()
|
||||||
|
{
|
||||||
|
$route = new route ();
|
||||||
|
$route->baseURL (false, true);
|
||||||
|
$this->expectOutputString("");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Port 80 and HTTP without module */
|
||||||
|
public function test_baseURL_2_absolute ()
|
||||||
|
{
|
||||||
|
$_SERVER["SERVER_NAME"] = "localhost";
|
||||||
|
$_SERVER["SERVER_PORT"] = "80";
|
||||||
|
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
||||||
|
$route = new route ();
|
||||||
|
echo $route->baseURL (false, true);
|
||||||
|
$this->expectOutputString("https://localhost:80/");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Port 443 and HTTPS without module */
|
||||||
|
public function test_baseURL_3_absolute ()
|
||||||
|
{
|
||||||
|
unset ($_SERVER["HTTPS"]);
|
||||||
|
$_SERVER["SERVER_NAME"] = "localhost";
|
||||||
|
$_SERVER["SERVER_PORT"] = "443";
|
||||||
|
$_SERVER["HTTPS"] = true;
|
||||||
|
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
||||||
|
$route = new route ();
|
||||||
|
echo $route->baseURL (false, true);
|
||||||
$this->expectOutputString("https://localhost/");
|
$this->expectOutputString("https://localhost/");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Port 888 and HTTP without module */
|
/** Port 888 and HTTP without module */
|
||||||
public function test_baseURL_4 ()
|
public function test_baseURL_4_absolute ()
|
||||||
{
|
{
|
||||||
unset ($_SERVER["HTTPS"]);
|
unset ($_SERVER["HTTPS"]);
|
||||||
$_SERVER["SERVER_NAME"] = "localhost";
|
$_SERVER["SERVER_NAME"] = "localhost";
|
||||||
$_SERVER["SERVER_PORT"] = "888";
|
$_SERVER["SERVER_PORT"] = "888";
|
||||||
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
||||||
$route = new route ();
|
$route = new route ();
|
||||||
echo $route->baseURL ();
|
echo $route->baseURL (false, true);
|
||||||
$this->expectOutputString("http://localhost:888/");
|
$this->expectOutputString("http://localhost:888/");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Port 888 and HTTPS without module */
|
/** Port 888 and HTTPS without module */
|
||||||
public function test_baseURL_5 ()
|
public function test_baseURL_5_absolute ()
|
||||||
{
|
{
|
||||||
$_SERVER["SERVER_NAME"] = "localhost";
|
$_SERVER["SERVER_NAME"] = "localhost";
|
||||||
$_SERVER["SERVER_PORT"] = "888";
|
$_SERVER["SERVER_PORT"] = "888";
|
||||||
$_SERVER["HTTPS"] = true;
|
$_SERVER["HTTPS"] = true;
|
||||||
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
||||||
$route = new route ();
|
$route = new route ();
|
||||||
echo $route->baseURL ();
|
echo $route->baseURL (false, true);
|
||||||
$this->expectOutputString("https://localhost:888/");
|
$this->expectOutputString("https://localhost:888/");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Port 80 and HTTP with module */
|
/** Port 80 and HTTP with module */
|
||||||
public function test_baseURL_2_module ()
|
public function test_baseURL_2_module_absolute ()
|
||||||
{
|
{
|
||||||
unset ($_SERVER["HTTPS"]);
|
unset ($_SERVER["HTTPS"]);
|
||||||
$_SERVER["SERVER_NAME"] = "localhost";
|
$_SERVER["SERVER_NAME"] = "localhost";
|
||||||
$_SERVER["SERVER_PORT"] = "80";
|
$_SERVER["SERVER_PORT"] = "80";
|
||||||
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
|
||||||
$route = new route ();
|
$route = new route ();
|
||||||
echo $route->baseURL ("module");
|
echo $route->baseURL ("module", true);
|
||||||
$this->expectOutputString("http://localhost/");
|
$this->expectOutputString("http://localhost/");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Port 443 and HTTPS with module */
|
/** Port 443 and HTTPS with module */
|
||||||
public function test_baseURL_3_module ()
|
public function test_baseURL_3_module_absolute ()
|
||||||
{
|
{
|
||||||
$_SERVER["SERVER_NAME"] = "localhost";
|
$_SERVER["SERVER_NAME"] = "localhost";
|
||||||
$_SERVER["SERVER_PORT"] = "443";
|
$_SERVER["SERVER_PORT"] = "443";
|
||||||
$_SERVER["HTTPS"] = true;
|
$_SERVER["HTTPS"] = true;
|
||||||
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
|
||||||
$route = new route ();
|
$route = new route ();
|
||||||
echo $route->baseURL ("module");
|
echo $route->baseURL ("module", true);
|
||||||
$this->expectOutputString("https://localhost/");
|
$this->expectOutputString("https://localhost/");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Port 888 and HTTP with module */
|
/** Port 888 and HTTP with module */
|
||||||
public function test_baseURL_4_module ()
|
public function test_baseURL_4_module_absolute ()
|
||||||
{
|
{
|
||||||
unset ($_SERVER["HTTPS"]);
|
unset ($_SERVER["HTTPS"]);
|
||||||
$_SERVER["SERVER_NAME"] = "localhost";
|
$_SERVER["SERVER_NAME"] = "localhost";
|
||||||
$_SERVER["SERVER_PORT"] = "888";
|
$_SERVER["SERVER_PORT"] = "888";
|
||||||
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
|
||||||
$route = new route ();
|
$route = new route ();
|
||||||
echo $route->baseURL ("module");
|
echo $route->baseURL ("module", true);
|
||||||
$this->expectOutputString("http://localhost:888/");
|
$this->expectOutputString("http://localhost:888/");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Port 888 and HTTPS with module */
|
/** Port 888 and HTTPS with module */
|
||||||
public function test_baseURL_5_module ()
|
public function test_baseURL_5_module_absolute ()
|
||||||
{
|
{
|
||||||
$_SERVER["SERVER_NAME"] = "localhost";
|
$_SERVER["SERVER_NAME"] = "localhost";
|
||||||
$_SERVER["SERVER_PORT"] = "888";
|
$_SERVER["SERVER_PORT"] = "888";
|
||||||
$_SERVER["HTTPS"] = true;
|
$_SERVER["HTTPS"] = true;
|
||||||
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
|
||||||
$route = new route ();
|
$route = new route ();
|
||||||
echo $route->baseURL ("module");
|
echo $route->baseURL ("module", true);
|
||||||
$this->expectOutputString("https://localhost:888/");
|
$this->expectOutputString("https://localhost:888/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// REQUESTURL ///
|
||||||
/** Port 80 and HTTP requestURL */
|
/** Port 80 and HTTP requestURL */
|
||||||
public function test_requestURL_2 ()
|
public function test_requestURL_2_direct ()
|
||||||
{
|
{
|
||||||
unset ($_SERVER["HTTPS"]);
|
unset ($_SERVER["HTTPS"]);
|
||||||
$_SERVER["SERVER_NAME"] = "localhost";
|
$_SERVER["SERVER_NAME"] = "localhost";
|
||||||
$_SERVER["SERVER_PORT"] = "80";
|
$_SERVER["SERVER_PORT"] = "80";
|
||||||
$_SERVER["REQUEST_URI"] = "/index.php?var=1";
|
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
||||||
|
$_SERVER["REQUEST_URI"] = "/index.php?url=bla";
|
||||||
$route = new route ();
|
$route = new route ();
|
||||||
echo $route->requestURL ();
|
echo $route->requestURL ();
|
||||||
$this->expectOutputString("http://localhost/index.php?var=1");
|
$this->expectOutputString("index.php?url=bla");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Port 443 and HTTPS requestURL */
|
/** Port 443 and HTTPS requestURL */
|
||||||
public function test_requestURL_3 ()
|
public function test_requestURL_3_direct ()
|
||||||
{
|
{
|
||||||
$_SERVER["SERVER_NAME"] = "localhost";
|
$_SERVER["SERVER_NAME"] = "localhost";
|
||||||
$_SERVER["SERVER_PORT"] = "443";
|
$_SERVER["SERVER_PORT"] = "443";
|
||||||
$_SERVER["HTTPS"] = true;
|
$_SERVER["HTTPS"] = true;
|
||||||
|
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
||||||
$_SERVER["REQUEST_URI"] = "/index.php?var=1";
|
$_SERVER["REQUEST_URI"] = "/index.php?var=1";
|
||||||
$route = new route ();
|
$route = new route ();
|
||||||
echo $route->requestURL ();
|
echo $route->requestURL ();
|
||||||
$this->expectOutputString("https://localhost/index.php?var=1");
|
$this->expectOutputString("index.php?var=1");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Port 888 and HTTP requestURL */
|
/** Port 888 and HTTP requestURL */
|
||||||
public function test_requestURL_4 ()
|
public function test_requestURL_4_direct ()
|
||||||
{
|
{
|
||||||
unset ($_SERVER["HTTPS"]);
|
unset ($_SERVER["HTTPS"]);
|
||||||
$_SERVER["SERVER_NAME"] = "localhost";
|
$_SERVER["SERVER_NAME"] = "localhost";
|
||||||
$_SERVER["SERVER_PORT"] = "888";
|
$_SERVER["SERVER_PORT"] = "888";
|
||||||
|
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
||||||
$_SERVER["REQUEST_URI"] = "/index.php?var=1";
|
$_SERVER["REQUEST_URI"] = "/index.php?var=1";
|
||||||
$route = new route ();
|
$route = new route ();
|
||||||
echo $route->requestURL ();
|
echo $route->requestURL ();
|
||||||
$this->expectOutputString("http://localhost:888/index.php?var=1");
|
$this->expectOutputString("index.php?var=1");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Port 888 and HTTPS requestURL */
|
/** Port 888 and HTTPS requestURL */
|
||||||
public function test_requestURL_5 ()
|
public function test_requestURL_5_direct ()
|
||||||
{
|
{
|
||||||
$_SERVER["SERVER_NAME"] = "localhost";
|
$_SERVER["SERVER_NAME"] = "localhost";
|
||||||
$_SERVER["SERVER_PORT"] = "888";
|
$_SERVER["SERVER_PORT"] = "888";
|
||||||
$_SERVER["HTTPS"] = true;
|
$_SERVER["HTTPS"] = true;
|
||||||
|
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
||||||
$_SERVER["REQUEST_URI"] = "/index.php?var=1";
|
$_SERVER["REQUEST_URI"] = "/index.php?var=1";
|
||||||
$route = new route ();
|
$route = new route ();
|
||||||
echo $route->requestURL ();
|
echo $route->requestURL ();
|
||||||
$this->expectOutputString("https://localhost:888/index.php?var=1");
|
$this->expectOutputString("index.php?var=1");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Port 80 and HTTP requestURL */
|
||||||
|
public function test_requestURL_2_rewrite ()
|
||||||
|
{
|
||||||
|
unset ($_SERVER["HTTPS"]);
|
||||||
|
$_SERVER["SERVER_NAME"] = "localhost";
|
||||||
|
$_SERVER["SERVER_PORT"] = "80";
|
||||||
|
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
||||||
|
$_SERVER["REQUEST_URI"] = "/bla";
|
||||||
|
$route = new route ();
|
||||||
|
echo $route->requestURL ();
|
||||||
|
$this->expectOutputString("bla");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Port 443 and HTTPS requestURL */
|
||||||
|
public function test_requestURL_3_rewrite ()
|
||||||
|
{
|
||||||
|
$_SERVER["SERVER_NAME"] = "localhost";
|
||||||
|
$_SERVER["SERVER_PORT"] = "443";
|
||||||
|
$_SERVER["HTTPS"] = true;
|
||||||
|
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
||||||
|
$_SERVER["REQUEST_URI"] = "/var=1";
|
||||||
|
$route = new route ();
|
||||||
|
echo $route->requestURL ();
|
||||||
|
$this->expectOutputString("var=1");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Port 888 and HTTP requestURL */
|
||||||
|
public function test_requestURL_4_rewrite ()
|
||||||
|
{
|
||||||
|
unset ($_SERVER["HTTPS"]);
|
||||||
|
$_SERVER["SERVER_NAME"] = "localhost";
|
||||||
|
$_SERVER["SERVER_PORT"] = "888";
|
||||||
|
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
||||||
|
$_SERVER["REQUEST_URI"] = "/var=1";
|
||||||
|
$route = new route ();
|
||||||
|
echo $route->requestURL ();
|
||||||
|
$this->expectOutputString("var=1");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Port 888 and HTTPS requestURL */
|
||||||
|
public function test_requestURL_5_rewrite ()
|
||||||
|
{
|
||||||
|
$_SERVER["SERVER_NAME"] = "localhost";
|
||||||
|
$_SERVER["SERVER_PORT"] = "888";
|
||||||
|
$_SERVER["HTTPS"] = true;
|
||||||
|
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
||||||
|
$_SERVER["REQUEST_URI"] = "/var=1";
|
||||||
|
$route = new route ();
|
||||||
|
echo $route->requestURL ();
|
||||||
|
$this->expectOutputString("var=1");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user