From 86e726005d3377b1f23a97966ed55dcebc622b12 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Fri, 12 Feb 2016 23:34:52 +0100 Subject: [PATCH] - [x] [autoloader][phpunit/bootstrap.php] Correction des bugs de $_SERVER avec PHPUnit -> autoloader + bootstrap personnalise --- manager/autoloader.php | 9 +- phpunit/bootstrap.php | 12 +++ phpunit/coverage/Database.php.html | 2 +- phpunit/coverage/ManagerError.php.html | 2 +- phpunit/coverage/ResourceDispatcher.php.html | 2 +- phpunit/coverage/autoloader.php.html | 93 ++++++++++---------- phpunit/coverage/index.dashboard.html | 2 +- phpunit/coverage/index.html | 2 +- phpunit/coverage/sessionManager.php.html | 2 +- phpunit/phpunit.xml | 2 +- phpunit/tests/Database_construct.php | 1 - todo.md | 1 + 12 files changed, 72 insertions(+), 58 deletions(-) create mode 100644 phpunit/bootstrap.php diff --git a/manager/autoloader.php b/manager/autoloader.php index 7e8f94e..87a2451 100755 --- a/manager/autoloader.php +++ b/manager/autoloader.php @@ -1,4 +1,7 @@ - \ No newline at end of file diff --git a/phpunit/bootstrap.php b/phpunit/bootstrap.php new file mode 100644 index 0000000..e2d4567 --- /dev/null +++ b/phpunit/bootstrap.php @@ -0,0 +1,12 @@ + \ No newline at end of file diff --git a/phpunit/coverage/Database.php.html b/phpunit/coverage/Database.php.html index f1a3610..05a6439 100755 --- a/phpunit/coverage/Database.php.html +++ b/phpunit/coverage/Database.php.html @@ -431,7 +431,7 @@ Dead Code

- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.9-1ubuntu4.14 and PHPUnit 3.7.28 at Fri Feb 12 23:21:09 CET 2016. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.9-1ubuntu4.14 and PHPUnit 3.7.28 at Fri Feb 12 23:33:48 CET 2016.

diff --git a/phpunit/coverage/ManagerError.php.html b/phpunit/coverage/ManagerError.php.html index 32bc08c..57c1c12 100644 --- a/phpunit/coverage/ManagerError.php.html +++ b/phpunit/coverage/ManagerError.php.html @@ -203,7 +203,7 @@ Dead Code

- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.9-1ubuntu4.14 and PHPUnit 3.7.28 at Fri Feb 12 23:21:09 CET 2016. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.9-1ubuntu4.14 and PHPUnit 3.7.28 at Fri Feb 12 23:33:48 CET 2016.

diff --git a/phpunit/coverage/ResourceDispatcher.php.html b/phpunit/coverage/ResourceDispatcher.php.html index 5cb940c..1bf9c1d 100644 --- a/phpunit/coverage/ResourceDispatcher.php.html +++ b/phpunit/coverage/ResourceDispatcher.php.html @@ -450,7 +450,7 @@ Dead Code

- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.9-1ubuntu4.14 and PHPUnit 3.7.28 at Fri Feb 12 23:21:09 CET 2016. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.9-1ubuntu4.14 and PHPUnit 3.7.28 at Fri Feb 12 23:33:48 CET 2016.

diff --git a/phpunit/coverage/autoloader.php.html b/phpunit/coverage/autoloader.php.html index 1e5c090..6317d90 100755 --- a/phpunit/coverage/autoloader.php.html +++ b/phpunit/coverage/autoloader.php.html @@ -58,7 +58,7 @@ - debug() + debug()
@@ -75,7 +75,7 @@ - autoloader($className) + autoloader($className)
@@ -96,51 +96,52 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - - - - + + + + + +
<?php define('__ROOT__', dirname(dirname(__FILE__)) );
/* ACTIVE LE DEBUGGAGE (WARNING + EXCEPTION)
*
*/
function debug(){
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);
}
/* AUTOLOADER
*
* @className<String> Nom de la classe appelee
*
*/
function autoloader($className){
$path = '';
/* [1] On utilise le namespace pour localiser
===============================================*/
// On remplace les '\' par des '/'
$path = str_replace('\\', '/', $className) . '.php';
$path = __ROOT__.'/'.$path;
// Si le fichier existe, on l'inclut
if( file_exists($path) )
require_once $path;
}
// On definit l'autoloader comme autoloader (obvious)
spl_autoload_register('autoloader', false, true);
<?php
// On definit la racine __ROOT__ si c'est pas deja fait
if( !defined('__ROOT__') )
define('__ROOT__', dirname(dirname(__FILE__)) );
/* ACTIVE LE DEBUGGAGE (WARNING + EXCEPTION)
*
*/
function debug(){
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);
}
/* AUTOLOADER
*
* @className<String> Nom de la classe appelee
*
*/
function autoloader($className){
$path = '';
/* [1] On utilise le namespace pour localiser
===============================================*/
// On remplace les '\' par des '/'
$path = str_replace('\\', '/', $className) . '.php';
$path = __ROOT__.'/'.$path;
// Si le fichier existe, on l'inclut
if( file_exists($path) )
require_once $path;
}
// On definit l'autoloader comme autoloader (obvious)
spl_autoload_register('autoloader', false, true);
/* On demarre la session securisee PHP
=========================================================*/
// Condition ajoutee pour PHPUNIT
if( isset($_SERVER['REMOTE_ADDR']) )
\manager\sessionManager::session_start();
/* On demarre la session securisee PHP
=========================================================*/
\manager\sessionManager::session_start();
@@ -152,7 +153,7 @@ Dead Code

- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.9-1ubuntu4.14 and PHPUnit 3.7.28 at Fri Feb 12 23:21:09 CET 2016. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.9-1ubuntu4.14 and PHPUnit 3.7.28 at Fri Feb 12 23:33:48 CET 2016.

diff --git a/phpunit/coverage/index.dashboard.html b/phpunit/coverage/index.dashboard.html index 4f9b37f..8951ca5 100755 --- a/phpunit/coverage/index.dashboard.html +++ b/phpunit/coverage/index.dashboard.html @@ -65,7 +65,7 @@ diff --git a/phpunit/coverage/index.html b/phpunit/coverage/index.html index d37c6b2..f01aa19 100755 --- a/phpunit/coverage/index.html +++ b/phpunit/coverage/index.html @@ -177,7 +177,7 @@ High: 70% to 100%

- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.9-1ubuntu4.14 and PHPUnit 3.7.28 at Fri Feb 12 23:21:09 CET 2016. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.9-1ubuntu4.14 and PHPUnit 3.7.28 at Fri Feb 12 23:33:48 CET 2016.

diff --git a/phpunit/coverage/sessionManager.php.html b/phpunit/coverage/sessionManager.php.html index 695f607..389531d 100644 --- a/phpunit/coverage/sessionManager.php.html +++ b/phpunit/coverage/sessionManager.php.html @@ -284,7 +284,7 @@ Dead Code

- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.9-1ubuntu4.14 and PHPUnit 3.7.28 at Fri Feb 12 23:21:09 CET 2016. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.9-1ubuntu4.14 and PHPUnit 3.7.28 at Fri Feb 12 23:33:48 CET 2016.

diff --git a/phpunit/phpunit.xml b/phpunit/phpunit.xml index 8a984d4..b316503 100755 --- a/phpunit/phpunit.xml +++ b/phpunit/phpunit.xml @@ -1,4 +1,4 @@ - + diff --git a/phpunit/tests/Database_construct.php b/phpunit/tests/Database_construct.php index 827a58f..10f0be6 100755 --- a/phpunit/tests/Database_construct.php +++ b/phpunit/tests/Database_construct.php @@ -15,7 +15,6 @@ \manager\Database::$error = \manager\ManagerError::PDOConnection; - $_SERVER['HTTP_HOST'] = 'stefproject'; $instance = \manager\Database::getInstance(); $this->assertEquals( 'localhost', $instance->getConfig()['host'] ); diff --git a/todo.md b/todo.md index 08cb501..9073064 100755 --- a/todo.md +++ b/todo.md @@ -39,6 +39,7 @@ ######## # FAIT # ######## +- [x] [autoloader][phpunit/bootstrap.php] Correction des bugs de $_SERVER avec PHPUnit -> autoloader + bootstrap personnalise - [x] [sessionManager] Import de sessionManager - [x] [phpunit/tests/Database_*] Tests unitaire de delNumeric() - [x] [Database] Mise a jour des methodes de Database