- [x] [ModuleAnswer] Gestion des erreurs au niveau interne des Modules
This commit is contained in:
parent
86e726005d
commit
d5f0297c3a
38
automate.php
38
automate.php
|
@ -236,7 +236,7 @@
|
||||||
function insertUsersComposite(){
|
function insertUsersComposite(){
|
||||||
|
|
||||||
// Creation de la requete
|
// Creation de la requete
|
||||||
$request = new \manager\ModuleRequest('userDefault/create', array('92-55-B9-B3', 'b', 'c', 'd', 'e', 'f', 'g') );
|
$request = new \manager\ModuleRequest('userDefault/create', array('92-55-B9-B3', 'b', 'bla', 'bla', 'bla@test.com', 'sadas', '1') );
|
||||||
$answer = $request->dispatch();
|
$answer = $request->dispatch();
|
||||||
// Debug error
|
// Debug error
|
||||||
var_dump( $answer->error );
|
var_dump( $answer->error );
|
||||||
|
@ -246,41 +246,7 @@
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}//insertUsersComposite();
|
}insertUsersComposite();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* TEST DU CHECKER
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @return status<Boolean> TRUE si aucune erreur, sinon FALSE
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function testDatabaseChecker(){
|
|
||||||
|
|
||||||
/* (1) Code RFID */
|
|
||||||
var_dump('user.code');
|
|
||||||
var_dump( \manager\Database::check('user.code', '01-23-AB-CD' ) );
|
|
||||||
var_dump( \manager\Database::check('user.code', '01-23-45-67-89-AB' ) );
|
|
||||||
var_dump( \manager\Database::check('user.code', '01-23-AB-CG' ) );
|
|
||||||
var_dump( \manager\Database::check('user.code', '01-23-45-67-89-AB-CD' ) );
|
|
||||||
|
|
||||||
/* (2) Username / FirstName / Lastname */
|
|
||||||
var_dump('user.username ; user.firstname ; user.lastname');
|
|
||||||
|
|
||||||
/* (3) Adresse mail */
|
|
||||||
var_dump('user.mail');
|
|
||||||
|
|
||||||
/* (4) Password sha1 hash */
|
|
||||||
var_dump('user.password');
|
|
||||||
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}//testDatabaseChecker();
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -41,10 +41,9 @@
|
||||||
|
|
||||||
// Api
|
// Api
|
||||||
$R->post('api/?', function(){
|
$R->post('api/?', function(){
|
||||||
$request = \manager\ModuleRequest::fromURL($_POST);
|
$request = \manager\ModuleRequest::fromPost($_POST);
|
||||||
$answer = $request->dispatch();
|
$answer = $request->dispatch();
|
||||||
|
|
||||||
|
|
||||||
echo $answer->serialize();
|
echo $answer->serialize();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -38,18 +38,21 @@
|
||||||
// Methode inamorcable
|
// Methode inamorcable
|
||||||
const UncallableMethod = 8;
|
const UncallableMethod = 8;
|
||||||
|
|
||||||
|
// Erreur de parametre(s)
|
||||||
|
const ParamError = 9;
|
||||||
|
|
||||||
/* Repo */
|
/* Repo */
|
||||||
|
|
||||||
// Verification de la coherence du chemin (existe dans la conf)
|
// Verification de la coherence du chemin (existe dans la conf)
|
||||||
const WrongPathRepo = 9;
|
const WrongPathRepo = 10;
|
||||||
|
|
||||||
// Module non specifie dans la conf
|
// Module non specifie dans la conf
|
||||||
const UnknownRepo = 10;
|
const UnknownRepo = 11;
|
||||||
|
|
||||||
/* Database */
|
/* Database */
|
||||||
|
|
||||||
// Erreur lors de la creation d'un objet PDO (connection)
|
// Erreur lors de la creation d'un objet PDO (connection)
|
||||||
const PDOConnection = 11;
|
const PDOConnection = 12;
|
||||||
|
|
||||||
|
|
||||||
/* EXPLICITE UN CODE D'ERREUR
|
/* EXPLICITE UN CODE D'ERREUR
|
||||||
|
@ -72,6 +75,7 @@
|
||||||
case self::UnknownRepo: return "Le repo n'existe pas"; break;
|
case self::UnknownRepo: return "Le repo n'existe pas"; break;
|
||||||
case self::UnknownMethod: return "Le methode n'existe pas"; break;
|
case self::UnknownMethod: return "Le methode n'existe pas"; break;
|
||||||
case self::UncallableMethod: return "Le methode n'est pas amorcable"; break;
|
case self::UncallableMethod: return "Le methode n'est pas amorcable"; break;
|
||||||
|
case self::ParamError: return "Un ou plusieurs parametres sont manquants ou incorrects"; break;
|
||||||
case self::PDOConnection: return "La connexion avec la base de donnees a echoue"; break;
|
case self::PDOConnection: return "La connexion avec la base de donnees a echoue"; break;
|
||||||
|
|
||||||
default: return "Erreur inconnue..."; break;
|
default: return "Erreur inconnue..."; break;
|
||||||
|
|
|
@ -67,6 +67,17 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function appendAll($dataset){
|
public function appendAll($dataset){
|
||||||
|
// Si ce n'est pas un tableau, on ne fais rien
|
||||||
|
if( !is_array($dataset) ) return $this;
|
||||||
|
|
||||||
|
// Si une valeur contient une erreur
|
||||||
|
if( array_key_exists('ModuleError', $dataset) ){
|
||||||
|
// On definit cette erreur
|
||||||
|
$this->error = $dataset['ModuleError'];
|
||||||
|
// On enleve cette entree des donnees
|
||||||
|
unset($dataset['ModuleError']);
|
||||||
|
}
|
||||||
|
|
||||||
// Ajoute une entree pour la cle @key et de valeur @value
|
// Ajoute une entree pour la cle @key et de valeur @value
|
||||||
$this->data = $dataset;
|
$this->data = $dataset;
|
||||||
|
|
||||||
|
|
|
@ -167,7 +167,7 @@
|
||||||
* @return instance<ModuleRequest> Retourne un objet de type <ModuleRequest>
|
* @return instance<ModuleRequest> Retourne un objet de type <ModuleRequest>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static function fromURL($post){
|
public static function fromPost($post){
|
||||||
/* [1] On verifie que le @path est renseigne
|
/* [1] On verifie que le @path est renseigne
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
if( !isset($post['path']) )
|
if( !isset($post['path']) )
|
||||||
|
@ -175,8 +175,15 @@
|
||||||
|
|
||||||
/* [2] On verifie que @data est renseigne
|
/* [2] On verifie que @data est renseigne
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
|
// Si variable n'existe pas, on cree un tableau vide
|
||||||
$data = (isset($post['data'])) ? $post['data'] : array();
|
$data = (isset($post['data'])) ? $post['data'] : array();
|
||||||
|
|
||||||
|
// Si c'est toujours pas un tableau, on essaie de voir si c'est un json
|
||||||
|
$data = (!is_array($data)) ? json_decode($data, true) : $data;
|
||||||
|
|
||||||
|
// Si toujours pas de tableau, on cree un tableau vide
|
||||||
|
$data = (!is_array($data)) ? array() : $data;
|
||||||
|
|
||||||
|
|
||||||
/* [3] On retourne une instance de <ModuleRequest>
|
/* [3] On retourne une instance de <ModuleRequest>
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
* @return status<Boolean> Retourne si oui ou non, tout s'est bien passe
|
* @return status<Boolean> Retourne si oui ou non, tout s'est bien passe
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static function create($code, $username, $firstname, $lastname, $mail, $password, $status){
|
public static function create($code=null, $username=null, $firstname=null, $lastname=null, $mail=null, $password=null, $status=null){
|
||||||
/* [1] Normalisation + verification des donnees
|
/* [1] Normalisation + verification des donnees
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$password_hash = \manager\sessionManager::secure_sha1($password);
|
$password_hash = \manager\sessionManager::secure_sha1($password);
|
||||||
|
@ -47,10 +47,15 @@
|
||||||
$correct_param = $correct_param && \manager\Database::check('user.password', $password_hash);
|
$correct_param = $correct_param && \manager\Database::check('user.password', $password_hash);
|
||||||
$correct_param = $correct_param && \manager\Database::check('user.status', $status);
|
$correct_param = $correct_param && \manager\Database::check('user.status', $status);
|
||||||
|
|
||||||
|
// Si les parametres ne sont pas corrects, on retourne une erreur
|
||||||
|
if( !$correct_param )
|
||||||
|
return array('ModuleError' => \manager\ManagerError::ParamError);
|
||||||
|
|
||||||
$request = new \manager\Repo('user/create', array($code, $username, $firstname, $lastname, $mail, $password, $status) );
|
|
||||||
|
|
||||||
return $request->answer();
|
// $request = new \manager\Repo('user/create', array($code, $username, $firstname, $lastname, $mail, $password, $status) );
|
||||||
|
|
||||||
|
// return $request->answer();
|
||||||
|
return array('ModuleError' => \manager\ManagerError::Success);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -431,7 +431,7 @@
|
||||||
<span class="warning"><strong>Dead Code</strong></span>
|
<span class="warning"><strong>Dead Code</strong></span>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 1.2.13</a> using <a href="http://www.php.net/" target="_top">PHP 5.5.9-1ubuntu4.14</a> and <a href="http://phpunit.de/">PHPUnit 3.7.28</a> at Fri Feb 12 23:33:48 CET 2016.</small>
|
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 1.2.13</a> using <a href="http://www.php.net/" target="_top">PHP 5.5.9-1ubuntu4.14</a> and <a href="http://phpunit.de/">PHPUnit 3.7.28</a> at Fri Feb 12 23:40:08 CET 2016.</small>
|
||||||
</p>
|
</p>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -203,7 +203,7 @@
|
||||||
<span class="warning"><strong>Dead Code</strong></span>
|
<span class="warning"><strong>Dead Code</strong></span>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 1.2.13</a> using <a href="http://www.php.net/" target="_top">PHP 5.5.9-1ubuntu4.14</a> and <a href="http://phpunit.de/">PHPUnit 3.7.28</a> at Fri Feb 12 23:33:48 CET 2016.</small>
|
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 1.2.13</a> using <a href="http://www.php.net/" target="_top">PHP 5.5.9-1ubuntu4.14</a> and <a href="http://phpunit.de/">PHPUnit 3.7.28</a> at Fri Feb 12 23:40:08 CET 2016.</small>
|
||||||
</p>
|
</p>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -450,7 +450,7 @@
|
||||||
<span class="warning"><strong>Dead Code</strong></span>
|
<span class="warning"><strong>Dead Code</strong></span>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 1.2.13</a> using <a href="http://www.php.net/" target="_top">PHP 5.5.9-1ubuntu4.14</a> and <a href="http://phpunit.de/">PHPUnit 3.7.28</a> at Fri Feb 12 23:33:48 CET 2016.</small>
|
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 1.2.13</a> using <a href="http://www.php.net/" target="_top">PHP 5.5.9-1ubuntu4.14</a> and <a href="http://phpunit.de/">PHPUnit 3.7.28</a> at Fri Feb 12 23:40:08 CET 2016.</small>
|
||||||
</p>
|
</p>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -153,7 +153,7 @@
|
||||||
<span class="warning"><strong>Dead Code</strong></span>
|
<span class="warning"><strong>Dead Code</strong></span>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 1.2.13</a> using <a href="http://www.php.net/" target="_top">PHP 5.5.9-1ubuntu4.14</a> and <a href="http://phpunit.de/">PHPUnit 3.7.28</a> at Fri Feb 12 23:33:48 CET 2016.</small>
|
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 1.2.13</a> using <a href="http://www.php.net/" target="_top">PHP 5.5.9-1ubuntu4.14</a> and <a href="http://phpunit.de/">PHPUnit 3.7.28</a> at Fri Feb 12 23:40:08 CET 2016.</small>
|
||||||
</p>
|
</p>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -65,7 +65,7 @@
|
||||||
</div>
|
</div>
|
||||||
<footer>
|
<footer>
|
||||||
<p>
|
<p>
|
||||||
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 1.2.13</a> using <a href="http://www.php.net/" target="_top">PHP 5.5.9-1ubuntu4.14</a> and <a href="http://phpunit.de/">PHPUnit 3.7.28</a> at Fri Feb 12 23:33:48 CET 2016.</small>
|
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 1.2.13</a> using <a href="http://www.php.net/" target="_top">PHP 5.5.9-1ubuntu4.14</a> and <a href="http://phpunit.de/">PHPUnit 3.7.28</a> at Fri Feb 12 23:40:08 CET 2016.</small>
|
||||||
</p>
|
</p>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -177,7 +177,7 @@
|
||||||
<span class="success"><strong>High</strong>: 70% to 100%</span>
|
<span class="success"><strong>High</strong>: 70% to 100%</span>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 1.2.13</a> using <a href="http://www.php.net/" target="_top">PHP 5.5.9-1ubuntu4.14</a> and <a href="http://phpunit.de/">PHPUnit 3.7.28</a> at Fri Feb 12 23:33:48 CET 2016.</small>
|
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 1.2.13</a> using <a href="http://www.php.net/" target="_top">PHP 5.5.9-1ubuntu4.14</a> and <a href="http://phpunit.de/">PHPUnit 3.7.28</a> at Fri Feb 12 23:40:08 CET 2016.</small>
|
||||||
</p>
|
</p>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -284,7 +284,7 @@
|
||||||
<span class="warning"><strong>Dead Code</strong></span>
|
<span class="warning"><strong>Dead Code</strong></span>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 1.2.13</a> using <a href="http://www.php.net/" target="_top">PHP 5.5.9-1ubuntu4.14</a> and <a href="http://phpunit.de/">PHPUnit 3.7.28</a> at Fri Feb 12 23:33:48 CET 2016.</small>
|
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 1.2.13</a> using <a href="http://www.php.net/" target="_top">PHP 5.5.9-1ubuntu4.14</a> and <a href="http://phpunit.de/">PHPUnit 3.7.28</a> at Fri Feb 12 23:40:08 CET 2016.</small>
|
||||||
</p>
|
</p>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
<phpunit bootstrap="./bootstrap.php">
|
<phpunit bootstrap="./bootstrap.php">
|
||||||
|
|
||||||
<testsuites>
|
<testsuites>
|
||||||
|
|
||||||
<testsuite name="\manager\Database">
|
<testsuite name="\manager\Database">
|
||||||
<directory suffix=".php">./tests/</directory>
|
<directory prefix="Database_" suffix=".php">./tests/</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
|
|
||||||
</testsuites>
|
</testsuites>
|
||||||
|
|
||||||
|
|
||||||
|
|
1
todo.md
1
todo.md
|
@ -39,6 +39,7 @@
|
||||||
########
|
########
|
||||||
# FAIT #
|
# FAIT #
|
||||||
########
|
########
|
||||||
|
- [x] [ModuleAnswer] Gestion des erreurs au niveau interne des Modules
|
||||||
- [x] [autoloader][phpunit/bootstrap.php] Correction des bugs de $_SERVER avec PHPUnit -> autoloader + bootstrap personnalise
|
- [x] [autoloader][phpunit/bootstrap.php] Correction des bugs de $_SERVER avec PHPUnit -> autoloader + bootstrap personnalise
|
||||||
- [x] [sessionManager] Import de sessionManager
|
- [x] [sessionManager] Import de sessionManager
|
||||||
- [x] [phpunit/tests/Database_*] Tests unitaire de delNumeric()
|
- [x] [phpunit/tests/Database_*] Tests unitaire de delNumeric()
|
||||||
|
|
Loading…
Reference in New Issue