Passage en Namespace et tous les tests fonctionnels OK

This commit is contained in:
2021-05-10 11:48:15 +02:00
parent 536dd0d56b
commit eb30d8ef97
56 changed files with 1091 additions and 964 deletions

View File

@@ -7,14 +7,16 @@
namespace Domframework\Tests;
/** Test the route.php file */
class routeTest extends \PHPUnit_Framework_TestCase
use Domframework\Route;
/** Test the Route.php file */
class RouteTest extends \PHPUnit_Framework_TestCase
{
/// RELATIVE ///
/** Entry null */
public function test_baseURL_1_relative ()
{
$route = new route ();
$route = new Route ();
$route->baseURL ();
$this->expectOutputString("");
}
@@ -25,7 +27,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_NAME"] = "localhost";
$_SERVER["SERVER_PORT"] = "80";
$_SERVER["SCRIPT_NAME"] = "/index.php";
$route = new route ();
$route = new Route ();
echo $route->baseURL ();
$this->expectOutputString("/");
}
@@ -38,7 +40,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_PORT"] = "443";
$_SERVER["HTTPS"] = true;
$_SERVER["SCRIPT_NAME"] = "/index.php";
$route = new route ();
$route = new Route ();
echo $route->baseURL ();
$this->expectOutputString("/");
}
@@ -50,7 +52,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_NAME"] = "localhost";
$_SERVER["SERVER_PORT"] = "888";
$_SERVER["SCRIPT_NAME"] = "/index.php";
$route = new route ();
$route = new Route ();
echo $route->baseURL ();
$this->expectOutputString("/");
}
@@ -62,7 +64,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_PORT"] = "888";
$_SERVER["HTTPS"] = true;
$_SERVER["SCRIPT_NAME"] = "/index.php";
$route = new route ();
$route = new Route ();
echo $route->baseURL ();
$this->expectOutputString("/");
}
@@ -74,7 +76,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_NAME"] = "localhost";
$_SERVER["SERVER_PORT"] = "80";
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
$route = new route ();
$route = new Route ();
echo $route->baseURL ("module");
$this->expectOutputString("/");
}
@@ -86,7 +88,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_PORT"] = "443";
$_SERVER["HTTPS"] = true;
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
$route = new route ();
$route = new Route ();
echo $route->baseURL ("module");
$this->expectOutputString("/");
}
@@ -98,7 +100,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_NAME"] = "localhost";
$_SERVER["SERVER_PORT"] = "888";
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
$route = new route ();
$route = new Route ();
echo $route->baseURL ("module");
$this->expectOutputString("/");
}
@@ -110,7 +112,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_PORT"] = "888";
$_SERVER["HTTPS"] = true;
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
$route = new route ();
$route = new Route ();
echo $route->baseURL ("module");
$this->expectOutputString("/");
}
@@ -119,7 +121,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
/** Entry null */
public function test_baseURL_1_absolute ()
{
$route = new route ();
$route = new Route ();
$route->baseURL (false, true);
$this->expectOutputString("");
}
@@ -130,7 +132,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_NAME"] = "localhost";
$_SERVER["SERVER_PORT"] = "80";
$_SERVER["SCRIPT_NAME"] = "/index.php";
$route = new route ();
$route = new Route ();
echo $route->baseURL (false, true);
$this->expectOutputString("https://localhost:80/");
}
@@ -143,7 +145,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_PORT"] = "443";
$_SERVER["HTTPS"] = true;
$_SERVER["SCRIPT_NAME"] = "/index.php";
$route = new route ();
$route = new Route ();
echo $route->baseURL (false, true);
$this->expectOutputString("https://localhost/");
}
@@ -155,7 +157,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_NAME"] = "localhost";
$_SERVER["SERVER_PORT"] = "888";
$_SERVER["SCRIPT_NAME"] = "/index.php";
$route = new route ();
$route = new Route ();
echo $route->baseURL (false, true);
$this->expectOutputString("http://localhost:888/");
}
@@ -167,7 +169,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_PORT"] = "888";
$_SERVER["HTTPS"] = true;
$_SERVER["SCRIPT_NAME"] = "/index.php";
$route = new route ();
$route = new Route ();
echo $route->baseURL (false, true);
$this->expectOutputString("https://localhost:888/");
}
@@ -179,7 +181,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_NAME"] = "localhost";
$_SERVER["SERVER_PORT"] = "80";
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
$route = new route ();
$route = new Route ();
echo $route->baseURL ("module", true);
$this->expectOutputString("http://localhost/");
}
@@ -191,7 +193,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_PORT"] = "443";
$_SERVER["HTTPS"] = true;
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
$route = new route ();
$route = new Route ();
echo $route->baseURL ("module", true);
$this->expectOutputString("https://localhost/");
}
@@ -203,7 +205,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_NAME"] = "localhost";
$_SERVER["SERVER_PORT"] = "888";
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
$route = new route ();
$route = new Route ();
echo $route->baseURL ("module", true);
$this->expectOutputString("http://localhost:888/");
}
@@ -215,7 +217,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_PORT"] = "888";
$_SERVER["HTTPS"] = true;
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
$route = new route ();
$route = new Route ();
echo $route->baseURL ("module", true);
$this->expectOutputString("https://localhost:888/");
}
@@ -229,7 +231,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_PORT"] = "80";
$_SERVER["SCRIPT_NAME"] = "/index.php";
$_SERVER["REQUEST_URI"] = "/index.php?url=bla";
$route = new route ();
$route = new Route ();
echo $route->requestURL ();
$this->expectOutputString("index.php?url=bla");
}
@@ -242,7 +244,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["HTTPS"] = true;
$_SERVER["SCRIPT_NAME"] = "/index.php";
$_SERVER["REQUEST_URI"] = "/index.php?var=1";
$route = new route ();
$route = new Route ();
echo $route->requestURL ();
$this->expectOutputString("index.php?var=1");
}
@@ -255,7 +257,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_PORT"] = "888";
$_SERVER["SCRIPT_NAME"] = "/index.php";
$_SERVER["REQUEST_URI"] = "/index.php?var=1";
$route = new route ();
$route = new Route ();
echo $route->requestURL ();
$this->expectOutputString("index.php?var=1");
}
@@ -268,7 +270,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["HTTPS"] = true;
$_SERVER["SCRIPT_NAME"] = "/index.php";
$_SERVER["REQUEST_URI"] = "/index.php?var=1";
$route = new route ();
$route = new Route ();
echo $route->requestURL ();
$this->expectOutputString("index.php?var=1");
}
@@ -281,7 +283,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_PORT"] = "80";
$_SERVER["SCRIPT_NAME"] = "/index.php";
$_SERVER["REQUEST_URI"] = "/bla";
$route = new route ();
$route = new Route ();
echo $route->requestURL ();
$this->expectOutputString("bla");
}
@@ -294,7 +296,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["HTTPS"] = true;
$_SERVER["SCRIPT_NAME"] = "/index.php";
$_SERVER["REQUEST_URI"] = "/var=1";
$route = new route ();
$route = new Route ();
echo $route->requestURL ();
$this->expectOutputString("var=1");
}
@@ -307,7 +309,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_PORT"] = "888";
$_SERVER["SCRIPT_NAME"] = "/index.php";
$_SERVER["REQUEST_URI"] = "/var=1";
$route = new route ();
$route = new Route ();
echo $route->requestURL ();
$this->expectOutputString("var=1");
}
@@ -320,7 +322,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["HTTPS"] = true;
$_SERVER["SCRIPT_NAME"] = "/index.php";
$_SERVER["REQUEST_URI"] = "/var=1";
$route = new route ();
$route = new Route ();
echo $route->requestURL ();
$this->expectOutputString("var=1");
}
@@ -328,7 +330,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
/** Ratelimiting in errors */
public function test_errorRateLimit1 ()
{
$route = new route ();
$route = new Route ();
$route->ratelimiter->storageDir = "/tmp/ratelimit-".time();
$route->error (new \Exception ("test1", 500));
$route->error (new \Exception ("test2", 500));