Tests are now compliant with php-cs-fixer (CamelCase for method, phpdoc valid)

This commit is contained in:
2023-04-13 22:22:46 +02:00
parent b017700d0a
commit 273db5f183
51 changed files with 3926 additions and 3637 deletions

View File

@@ -1,29 +1,36 @@
<?php
/** DomFramework - Tests
* @package domframework
* @author Dominique Fournier <dominique@fournier38.fr>
* @license BSD
*/
/**
* DomFramework - Tests
* @package domframework
* @author Dominique Fournier <dominique@fournier38.fr>
* @license BSD
*/
namespace Domframework\Tests;
use Domframework\Route;
/** Test the Route.php file */
/**
* Test the Route.php file
*/
class RouteTest extends \PHPUnit_Framework_TestCase
{
/// RELATIVE ///
/** Entry null */
public function test_baseURL_1_relative()
/// RELATIVE ///
/**
* Entry null
*/
public function testBaseURL1Relative()
{
$route = new Route();
$route->baseURL();
$this->expectOutputString("");
}
/** Port 80 and HTTP without module */
public function test_baseURL_2_relative()
/**
* Port 80 and HTTP without module
*/
public function testBaseURL2Relative()
{
$_SERVER["SERVER_NAME"] = "localhost";
$_SERVER["SERVER_PORT"] = "80";
@@ -33,8 +40,10 @@ class RouteTest extends \PHPUnit_Framework_TestCase
$this->expectOutputString("/");
}
/** Port 443 and HTTPS without module */
public function test_baseURL_3_relative()
/**
* Port 443 and HTTPS without module
*/
public function testBaseURL3Relative()
{
unset($_SERVER["HTTPS"]);
$_SERVER["SERVER_NAME"] = "localhost";
@@ -46,8 +55,10 @@ class RouteTest extends \PHPUnit_Framework_TestCase
$this->expectOutputString("/");
}
/** Port 888 and HTTP without module */
public function test_baseURL_4_relative()
/**
* Port 888 and HTTP without module
*/
public function testBaseURL4Relative()
{
unset($_SERVER["HTTPS"]);
$_SERVER["SERVER_NAME"] = "localhost";
@@ -58,8 +69,10 @@ class RouteTest extends \PHPUnit_Framework_TestCase
$this->expectOutputString("/");
}
/** Port 888 and HTTPS without module */
public function test_baseURL_5_relative()
/**
* Port 888 and HTTPS without module
*/
public function testBaseURL5Relative()
{
$_SERVER["SERVER_NAME"] = "localhost";
$_SERVER["SERVER_PORT"] = "888";
@@ -70,8 +83,10 @@ class RouteTest extends \PHPUnit_Framework_TestCase
$this->expectOutputString("/");
}
/** Port 80 and HTTP with module */
public function test_baseURL_2_module_relative()
/**
* Port 80 and HTTP with module
*/
public function testBaseURL2ModuleRelative()
{
unset($_SERVER["HTTPS"]);
$_SERVER["SERVER_NAME"] = "localhost";
@@ -82,8 +97,10 @@ class RouteTest extends \PHPUnit_Framework_TestCase
$this->expectOutputString("/");
}
/** Port 443 and HTTPS with module */
public function test_baseURL_3_module_relative()
/**
* Port 443 and HTTPS with module
*/
public function testBaseURL3ModuleRelative()
{
$_SERVER["SERVER_NAME"] = "localhost";
$_SERVER["SERVER_PORT"] = "443";
@@ -94,8 +111,10 @@ class RouteTest extends \PHPUnit_Framework_TestCase
$this->expectOutputString("/");
}
/** Port 888 and HTTP with module */
public function test_baseURL_4_module_relative()
/**
* Port 888 and HTTP with module
*/
public function testBaseURL4ModuleRelative()
{
unset($_SERVER["HTTPS"]);
$_SERVER["SERVER_NAME"] = "localhost";
@@ -106,8 +125,10 @@ class RouteTest extends \PHPUnit_Framework_TestCase
$this->expectOutputString("/");
}
/** Port 888 and HTTPS with module */
public function test_baseURL_5_module_relative()
/**
* Port 888 and HTTPS with module
*/
public function testBaseURL5ModuleRelative()
{
$_SERVER["SERVER_NAME"] = "localhost";
$_SERVER["SERVER_PORT"] = "888";
@@ -119,16 +140,20 @@ class RouteTest extends \PHPUnit_Framework_TestCase
}
/// ABSOLUTE ///
/** Entry null */
public function test_baseURL_1_absolute()
/**
* Entry null
*/
public function testBaseURL1Absolute()
{
$route = new Route();
$route->baseURL(false, true);
$this->expectOutputString("");
}
/** Port 80 and HTTP without module */
public function test_baseURL_2_absolute()
/**
* Port 80 and HTTP without module
*/
public function testBaseURL2Absolute()
{
$_SERVER["SERVER_NAME"] = "localhost";
$_SERVER["SERVER_PORT"] = "80";
@@ -138,8 +163,10 @@ class RouteTest extends \PHPUnit_Framework_TestCase
$this->expectOutputString("https://localhost:80/");
}
/** Port 443 and HTTPS without module */
public function test_baseURL_3_absolute()
/**
* Port 443 and HTTPS without module
*/
public function testBaseURL3Absolute()
{
unset($_SERVER["HTTPS"]);
$_SERVER["SERVER_NAME"] = "localhost";
@@ -151,8 +178,10 @@ class RouteTest extends \PHPUnit_Framework_TestCase
$this->expectOutputString("https://localhost/");
}
/** Port 888 and HTTP without module */
public function test_baseURL_4_absolute()
/**
* Port 888 and HTTP without module
*/
public function testBaseURL4Absolute()
{
unset($_SERVER["HTTPS"]);
$_SERVER["SERVER_NAME"] = "localhost";
@@ -163,8 +192,10 @@ class RouteTest extends \PHPUnit_Framework_TestCase
$this->expectOutputString("http://localhost:888/");
}
/** Port 888 and HTTPS without module */
public function test_baseURL_5_absolute()
/**
* Port 888 and HTTPS without module
*/
public function testBaseURL5Absolute()
{
$_SERVER["SERVER_NAME"] = "localhost";
$_SERVER["SERVER_PORT"] = "888";
@@ -175,8 +206,10 @@ class RouteTest extends \PHPUnit_Framework_TestCase
$this->expectOutputString("https://localhost:888/");
}
/** Port 80 and HTTP with module */
public function test_baseURL_2_module_absolute()
/**
* Port 80 and HTTP with module
*/
public function testBaseURL2ModuleAbsolute()
{
unset($_SERVER["HTTPS"]);
$_SERVER["SERVER_NAME"] = "localhost";
@@ -187,8 +220,10 @@ class RouteTest extends \PHPUnit_Framework_TestCase
$this->expectOutputString("http://localhost/");
}
/** Port 443 and HTTPS with module */
public function test_baseURL_3_module_absolute()
/**
* Port 443 and HTTPS with module
*/
public function testBaseURL3ModuleAbsolute()
{
$_SERVER["SERVER_NAME"] = "localhost";
$_SERVER["SERVER_PORT"] = "443";
@@ -199,8 +234,10 @@ class RouteTest extends \PHPUnit_Framework_TestCase
$this->expectOutputString("https://localhost/");
}
/** Port 888 and HTTP with module */
public function test_baseURL_4_module_absolute()
/**
* Port 888 and HTTP with module
*/
public function testBaseURL4ModuleAbsolute()
{
unset($_SERVER["HTTPS"]);
$_SERVER["SERVER_NAME"] = "localhost";
@@ -211,8 +248,10 @@ class RouteTest extends \PHPUnit_Framework_TestCase
$this->expectOutputString("http://localhost:888/");
}
/** Port 888 and HTTPS with module */
public function test_baseURL_5_module_absolute()
/**
* Port 888 and HTTPS with module
*/
public function testBaseURL5ModuleAbsolute()
{
$_SERVER["SERVER_NAME"] = "localhost";
$_SERVER["SERVER_PORT"] = "888";
@@ -224,8 +263,10 @@ class RouteTest extends \PHPUnit_Framework_TestCase
}
/// REQUESTURL ///
/** Port 80 and HTTP requestURL */
public function test_requestURL_2_direct()
/**
* Port 80 and HTTP requestURL
*/
public function testRequestURL2Direct()
{
unset($_SERVER["HTTPS"]);
$_SERVER["SERVER_NAME"] = "localhost";
@@ -237,8 +278,10 @@ class RouteTest extends \PHPUnit_Framework_TestCase
$this->expectOutputString("index.php?url=bla");
}
/** Port 443 and HTTPS requestURL */
public function test_requestURL_3_direct()
/**
* Port 443 and HTTPS requestURL
*/
public function testRequestURL3Direct()
{
$_SERVER["SERVER_NAME"] = "localhost";
$_SERVER["SERVER_PORT"] = "443";
@@ -250,8 +293,10 @@ class RouteTest extends \PHPUnit_Framework_TestCase
$this->expectOutputString("index.php?var=1");
}
/** Port 888 and HTTP requestURL */
public function test_requestURL_4_direct()
/**
* Port 888 and HTTP requestURL
*/
public function testRequestURL4Direct()
{
unset($_SERVER["HTTPS"]);
$_SERVER["SERVER_NAME"] = "localhost";
@@ -263,8 +308,10 @@ class RouteTest extends \PHPUnit_Framework_TestCase
$this->expectOutputString("index.php?var=1");
}
/** Port 888 and HTTPS requestURL */
public function test_requestURL_5_direct()
/**
* Port 888 and HTTPS requestURL
*/
public function testRequestURL5Direct()
{
$_SERVER["SERVER_NAME"] = "localhost";
$_SERVER["SERVER_PORT"] = "888";
@@ -276,8 +323,10 @@ class RouteTest extends \PHPUnit_Framework_TestCase
$this->expectOutputString("index.php?var=1");
}
/** Port 80 and HTTP requestURL */
public function test_requestURL_2_rewrite()
/**
* Port 80 and HTTP requestURL
*/
public function testRequestURL2Rewrite()
{
unset($_SERVER["HTTPS"]);
$_SERVER["SERVER_NAME"] = "localhost";
@@ -289,8 +338,10 @@ class RouteTest extends \PHPUnit_Framework_TestCase
$this->expectOutputString("bla");
}
/** Port 443 and HTTPS requestURL */
public function test_requestURL_3_rewrite()
/**
* Port 443 and HTTPS requestURL
*/
public function testRequestURL3Rewrite()
{
$_SERVER["SERVER_NAME"] = "localhost";
$_SERVER["SERVER_PORT"] = "443";
@@ -302,8 +353,10 @@ class RouteTest extends \PHPUnit_Framework_TestCase
$this->expectOutputString("var=1");
}
/** Port 888 and HTTP requestURL */
public function test_requestURL_4_rewrite()
/**
* Port 888 and HTTP requestURL
*/
public function testRequestURL4Rewrite()
{
unset($_SERVER["HTTPS"]);
$_SERVER["SERVER_NAME"] = "localhost";
@@ -315,8 +368,10 @@ class RouteTest extends \PHPUnit_Framework_TestCase
$this->expectOutputString("var=1");
}
/** Port 888 and HTTPS requestURL */
public function test_requestURL_5_rewrite()
/**
* Port 888 and HTTPS requestURL
*/
public function testRequestURL5Rewrite()
{
$_SERVER["SERVER_NAME"] = "localhost";
$_SERVER["SERVER_PORT"] = "888";
@@ -328,8 +383,10 @@ class RouteTest extends \PHPUnit_Framework_TestCase
$this->expectOutputString("var=1");
}
/** Ratelimiting in errors */
public function test_errorRateLimit1()
/**
* Ratelimiting in errors
*/
public function testErrorRateLimit1()
{
$route = new Route();
$route->ratelimiter->storageDir = "/tmp/ratelimit-" . time();