From 7c1989eb2d125083bdb03eefbe4d415d10478180 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Sun, 17 Apr 2016 12:49:40 +0200 Subject: [PATCH] Correction des anciens tests. --- phpunit/bootstrap.php | 2 +- phpunit/coverage/Database.php.html | 230 +++++++++---------- phpunit/coverage/ManagerError.php.html | 2 +- phpunit/coverage/ResourceDispatcher.php.html | 94 ++++---- phpunit/coverage/autoloader.php.html | 14 +- phpunit/coverage/index.html | 52 ++--- phpunit/coverage/sessionManager.php.html | 66 +++--- phpunit/phpunit.xml | 4 +- phpunit/run.sh | 2 +- phpunit/tests/Database_check.php | 43 +++- phpunit/tests/Database_construct.php | 2 +- 11 files changed, 276 insertions(+), 235 deletions(-) diff --git a/phpunit/bootstrap.php b/phpunit/bootstrap.php index e2d4567..bdac929 100755 --- a/phpunit/bootstrap.php +++ b/phpunit/bootstrap.php @@ -1,7 +1,7 @@
0.00%
0 / 1
-
-
- 14.29% covered (danger) -
-
- -
14.29%
-
1 / 7
- CRAP
-
- 62.20% covered (warning) +
+ 57.14% covered (warning)
-
62.20%
-
51 / 82
+
57.14%
+
4 / 7
+ CRAP +
+
+ 84.15% covered (warning) +
+
+ +
84.15%
+
69 / 82
@@ -79,23 +79,23 @@
0.00%
0 / 1
-
-
- 14.29% covered (danger) -
-
- -
14.29%
-
1 / 7
- 172.49
-
- 62.20% covered (warning) +
+ 57.14% covered (warning)
-
62.20%
-
51 / 82
+
57.14%
+
4 / 7
+ 57.18 +
+
+ 84.15% covered (warning) +
+
+ +
84.15%
+
69 / 82
@@ -108,15 +108,15 @@
0.00%
0 / 1
- 2.15 + 2.01
-
- 66.67% covered (warning) +
+ 88.89% covered (warning)
-
66.67%
-
6 / 9
+
88.89%
+
8 / 9
@@ -129,57 +129,57 @@
0.00%
0 / 1
- 6.84 + 6.10
-
- 71.43% covered (warning) +
+ 85.71% covered (warning)
-
71.43%
-
5 / 7
+
85.71%
+
6 / 7
-  getPDO -
-
- 0.00% covered (danger) +  getPDO +
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
- 1.12 -
-
- 50.00% covered (danger) +
100.00%
+
1 / 1
+ 1 +
+
+ 100.00% covered (success)
-
50.00%
-
1 / 2
+
100.00%
+
2 / 2
-  getConfig -
-
- 0.00% covered (danger) +  getConfig +
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
- 2 -
-
- 0.00% covered (danger) +
100.00%
+
1 / 1
+ 1 +
+
+ 100.00% covered (success)
-
0.00%
-
0 / 3
+
100.00%
+
3 / 3
@@ -204,24 +204,24 @@ -  check -
-
- 0.00% covered (danger) +  check +
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
- 68.06 -
-
- 56.00% covered (warning) +
100.00%
+
1 / 1
+ 23 +
+
+ 100.00% covered (success)
-
56.00%
-
14 / 25
+
100.00%
+
25 / 25
@@ -277,47 +277,47 @@         public function __construct($host, $dbname, $username, $password){ -             $this->host     = $host; -             $this->dbname   = $dbname; -             $this->username = $username; -             $this->password = $password; +             $this->host     = $host; +             $this->dbname   = $dbname; +             $this->username = $username; +             $this->password = $password;                          try{             -                 self::$pdo = new \PDO('mysql:host='.$this->host.';dbname='.$this->dbname, $this->username, $this->password); +                 self::$pdo = new \PDO('mysql:host='.$this->host.';dbname='.$this->dbname, $this->username, $this->password);                 // On signale que tout s'est bien passe -                 self::$error = ManagerError::Success; +                 self::$error = ManagerError::Success; -             }catch(Exception $e){ +             }catch(Exception $e){                 // On signale qu'il y a une erreur                 self::$error = ManagerError::PDOConnection;             } -         } +         }         /* retourne une instance de la classe */         public static function getInstance(){ -             if( self::$instance == null || self::$error != ManagerError::Success ){ // Si aucune instance existante OU erreur de connection +             if( self::$instance == null || self::$error != ManagerError::Success ){ // Si aucune instance existante OU erreur de connection                 // chargement de la configuration du server SQL -                 if( !isset($_SERVER['HTTP_HOST']) || isset($_SERVER['HTTP_HOST']) && $_SERVER['HTTP_HOST'] == 'socioview' ) -                     $conf = json_decode( ResourceDispatcher::getResource(self::$config_path['local']), true ); +                 if( !isset($_SERVER['HTTP_HOST']) || isset($_SERVER['HTTP_HOST']) && $_SERVER['HTTP_HOST'] == 'socioview' ) +                     $conf = json_decode( ResourceDispatcher::getResource(self::$config_path['local']), true );                 else -                     $conf = json_decode( ResourceDispatcher::getResource(self::$config_path['remote']), true ); +                     $conf = json_decode( ResourceDispatcher::getResource(self::$config_path['remote']), true );                 // creation de l'instance en fonction des parametres -                 self::$instance = new DataBase($conf['host'], $conf['dbname'], $conf['user'], $conf['password']); +                 self::$instance = new DataBase($conf['host'], $conf['dbname'], $conf['user'], $conf['password']); -             } +             }              -             return self::$instance; +             return self::$instance;         }         /* retourne la connection statique */         public static function getPDO(){ -             $instance = self::getInstance(); +             $instance = self::getInstance(); -             return self::$pdo; +             return self::$pdo;         } @@ -330,9 +330,9 @@         public function getConfig(){             return array( -                 'host' => $this->host, -                 'username' => $this->username -             ); +                 'host' => $this->host, +                 'username' => $this->username +             );         } @@ -435,44 +435,44 @@         *         */         public static function check($type, $value){ -             $checker = true; +             $checker = true;             /* [0] On verifie que $value n'est pas nul             =========================================================*/ -             if( is_null($value) ) return false; +             if( is_null($value) ) return false;             /* [1] Si de type VARCHAR(min, max)             =========================================================*/ -             if( preg_match('/^varchar\((\d+), ?(\d+)\)$/', $type, $match) ){ +             if( preg_match('/^varchar\((\d+), ?(\d+)\)$/', $type, $match) ){                 // On recupere la taille min -                 $min = (int) $match[1]; +                 $min = (int) $match[1];                 // On recupere la taille max -                 $max = (int) $match[2]; +                 $max = (int) $match[2];                 // On effectue la verification -                 return $checker && is_string($value) && strlen($value) <= $max && strlen($value) >= $min; +                 return $checker && is_string($value) && strlen($value) <= $max && strlen($value) >= $min;             }             /* [2] Si de type ARRAY(type_elements)             =========================================================*/ -             if( preg_match('/^array<(.+)>$/', $type, $match) ){ +             if( preg_match('/^array<(.+)>$/', $type, $match) ){                 // Si c'est pas un tableau on retourne une erreur -                 if( !is_array($value) ) -                     return false; +                 if( !is_array($value) ) +                     return false; -                 $elements_type = $match[1]; +                 $elements_type = $match[1];                 // On verifie le type pour chaque element -                 foreach($value as $element) +                 foreach($value as $element)                     // Si erreur dans au moins 1 element, on retourne que c'est incorrect -                     if( !self::check($elements_type, $element) ) -                         return false; +                     if( !self::check($elements_type, $element) ) +                         return false;                 // Si aucune erreur, on retourne que tout est bon -                 return true; +                 return true;             }              @@ -480,28 +480,28 @@             =========================================================*/                         switch($type){                 // Entier positif (id dans BDD) -                 case 'id': +                 case 'id':                     return $checker && is_numeric($value) && $value <= 2147483647 && $value >= 0;                     break;                 // String quelconque (peut etre vide) -                 case 'text': -                     return $checker && is_string($value); +                 case 'text': +                     return $checker && is_string($value);                 // Adresse mail (255 caracteres max) -                 case 'mail': +                 case 'mail':                     return $checker && is_string($value) && strlen($value) <= 50 && preg_match('/^[\w\.-]+@[\w\.-]+\.[a-z]{2,4}$/i', $value);                     break;                                  // Hash sha1 -                 case 'sha1': +                 case 'sha1':                     return $checker && is_string($value) && preg_match('/^[\da-f]{40}$/i', $value);                     break;                  -                 default: -                 return false; +                 default: +                 return false; -             } +             }             return $checker; @@ -559,7 +559,7 @@ Dead Code

- Generated by PHP_CodeCoverage 2.1.7 using PHP 5.6.11-1ubuntu3.1 and PHPUnit 4.7.6 at Sun Apr 17 10:22:22 UTC 2016. + Generated by PHP_CodeCoverage 2.1.7 using PHP 5.6.11-1ubuntu3.1 and PHPUnit 4.7.6 at Sun Apr 17 10:48:24 UTC 2016.

diff --git a/phpunit/coverage/ManagerError.php.html b/phpunit/coverage/ManagerError.php.html index c81b112..60b50b6 100755 --- a/phpunit/coverage/ManagerError.php.html +++ b/phpunit/coverage/ManagerError.php.html @@ -247,7 +247,7 @@ Dead Code

- Generated by PHP_CodeCoverage 2.1.7 using PHP 5.6.11-1ubuntu3.1 and PHPUnit 4.7.6 at Sun Apr 17 10:22:22 UTC 2016. + Generated by PHP_CodeCoverage 2.1.7 using PHP 5.6.11-1ubuntu3.1 and PHPUnit 4.7.6 at Sun Apr 17 10:48:24 UTC 2016.

diff --git a/phpunit/coverage/ResourceDispatcher.php.html b/phpunit/coverage/ResourceDispatcher.php.html index 2a0dd9e..6289f3c 100755 --- a/phpunit/coverage/ResourceDispatcher.php.html +++ b/phpunit/coverage/ResourceDispatcher.php.html @@ -262,49 +262,49 @@         *         */         public function __construct($url, $view=false){ -             $this->error = ManagerError::Success; +             $this->error = ManagerError::Success;             /* [0] On met a jour la configuration             =====================================================*/             // Extensions supportees -             $extensions_conf = json_decode( file_get_contents(__ROOT__.self::$extension_config_path), true ); +             $extensions_conf = json_decode( file_get_contents(__ROOT__.self::$extension_config_path), true );             // Gestion de l'erreur de parsage -             if( $extensions_conf == null ){ +             if( $extensions_conf == null ){                 $this->error = ManagerError::ParsingFailed;                 return false;             } -             self::$supported_extensions = $extensions_conf; +             self::$supported_extensions = $extensions_conf;             // Dossiers supportes -             $parents_conf = json_decode( file_get_contents(__ROOT__.self::$parents_config_path), true ); +             $parents_conf = json_decode( file_get_contents(__ROOT__.self::$parents_config_path), true );                          // Gestion de l'erreur de parsage -             if( $parents_conf == null ){ +             if( $parents_conf == null ){                 $this->error = ManagerError::ParsingFailed;                 return false;             } -             self::$supported_parents = $parents_conf; +             self::$supported_parents = $parents_conf;             /* [1] On recupere les donnees de l'URL             ==================================================*/ -             $serialFlags = array_slice( explode('/',$url), 1 ); +             $serialFlags = array_slice( explode('/',$url), 1 );             /* [2] On check/cree les drapeaux avec ces donnees             ==================================================*/ -             if( !$this->createFlags($serialFlags) ){ // Creation des drapeaux +             if( !$this->createFlags($serialFlags) ){ // Creation des drapeaux                 $this->error = ManagerError::InvalidFlags;                 return false;             }             /* [3] On construit le chemin a partir des tags             ==================================================*/ -             if( !$this->buildPath() ){ // Construction du chemin +             if( !$this->buildPath() ){ // Construction du chemin                 $this->error = ManagerError::UnreachableResource;                 return false;             } @@ -312,10 +312,10 @@             /* [4] On gere l'affichage pour l'appel externe/interne             ==================================================*/             if( $view ) // Appel externe -                 $this->view(); +                 $this->view();              -             return true; +             return true;         } @@ -328,8 +328,8 @@         *         */         public static function getResource($route){ -             $instance = new ResourceDispatcher($route); -             return $instance->getContent(); +             $instance = new ResourceDispatcher($route); +             return $instance->getContent();         } @@ -345,51 +345,51 @@             /* [1] Verification des flags (version serialisee)             ======================================================*/ -             $correct = true; +             $correct = true;             // Verification du nombre de drapeaux () au moins 3 -             $correct = $correct && count($serialFlags) >= 3; +             $correct = $correct && count($serialFlags) >= 3;             // Verification que l'extension est correcte -             $correct = $correct && array_key_exists($serialFlags[0], self::$supported_extensions); +             $correct = $correct && array_key_exists($serialFlags[0], self::$supported_extensions);             // Verification du filename -             $correct = $correct && preg_match('/^[\w_\.-]+$/i', $serialFlags[1]); +             $correct = $correct && preg_match('/^[\w_\.-]+$/i', $serialFlags[1]);             // Verification du parent -             $correct = $correct && array_key_exists($serialFlags[2], self::$supported_parents); +             $correct = $correct && array_key_exists($serialFlags[2], self::$supported_parents);             // Verification du sous-parent (optionnel) -             $opt_subParent = count($serialFlags) >= 4; +             $opt_subParent = count($serialFlags) >= 4;             if( $opt_subParent ) -                 $correct = $correct && preg_match('/^[\w_-]+$/i', $serialFlags[3]); +                 $correct = $correct && preg_match('/^[\w_-]+$/i', $serialFlags[3]);             // Verification de la couleur (optionnel) -             $opt_color = count($serialFlags) >= 5 && preg_match('/^[\da-f]{6,8}+$/i', $serialFlags[4]); +             $opt_color = count($serialFlags) >= 5 && preg_match('/^[\da-f]{6,8}+$/i', $serialFlags[4]); -             if( !$correct ) -                 return false; +             if( !$correct ) +                 return false;                              /* [2] Creation (non serialisee) des flags             ======================================================*/             // Si tout se deroule bien, on cree les flags -             $this->flags = array( -                 'extension' => $serialFlags[0], -                 'filename'  => $serialFlags[1], -                 'parent'    => $serialFlags[2] -             ); +             $this->flags = array( +                 'extension' => $serialFlags[0], +                 'filename'  => $serialFlags[1], +                 'parent'    => $serialFlags[2] +             );             // Ajout du sous-parent optionnel             if( $opt_subParent ) -                 $this->flags['subparent'] = $serialFlags[3]; +                 $this->flags['subparent'] = $serialFlags[3];             // Ajout du color optionnel             if( $opt_color ) -                 $this->flags['color'] = '#'.$serialFlags[4]; +                 $this->flags['color'] = '#'.$serialFlags[4]; -             return true; +             return true;         } @@ -408,10 +408,10 @@             /* [1] On recupere le HEADER associe a l'extension             ==========================================================*/             // Si aucun header pour cet cle, on retourne une erreur -             if( !isset(self::$supported_extensions[$this->flags['extension']]) ) return false; +             if( !isset(self::$supported_extensions[$this->flags['extension']]) ) return false;             // On recupere le header associe -             $header = self::$supported_extensions[$this->flags['extension']]; +             $header = self::$supported_extensions[$this->flags['extension']]; @@ -420,23 +420,23 @@             /* [2] On recupere le chemin associe au parent             ==========================================================*/             // Si aucun dossier pour cet indice, on retourne une erreur -             if( !isset(self::$supported_parents[$this->flags['parent']]) ) return false; +             if( !isset(self::$supported_parents[$this->flags['parent']]) ) return false;             // On recupere le dossier associe -             $parent = self::$supported_parents[$this->flags['parent']]; +             $parent = self::$supported_parents[$this->flags['parent']];             /* [3] Gestion du sous-parent optionnel             ==========================================================*/ -             $opt_subParent = (isset($this->flags['subparent'])) ? $this->flags['subparent'].'/' : ''; +             $opt_subParent = (isset($this->flags['subparent'])) ? $this->flags['subparent'].'/' : '';             /* [4] Gestion du color optionnel             =========================================================*/ -             $this->stylesheet = ""; +             $this->stylesheet = "";             // si le color est defini -             if( isset($this->flags['color']) ){ +             if( isset($this->flags['color']) ){                 $this->stylesheet = "\n<style type='text/css'>\n";                     $this->stylesheet .= "\t#stylisable{\n";                         $this->stylesheet .= "\t\tfill: ".$this->flags['color']." !important;\n"; @@ -449,15 +449,15 @@             /* [5] On definit le header             ==========================================================*/ -             $this->header = $header; +             $this->header = $header;             /* [6] On construit le chemin              ==========================================================*/ -             $this->path = __ROOT__.$parent.'/'.$opt_subParent.$this->flags['filename'].'.'.$this->flags['extension']; +             $this->path = __ROOT__.$parent.'/'.$opt_subParent.$this->flags['filename'].'.'.$this->flags['extension'];             /* [7] On retourne si le fichier existe ou non             ==========================================================*/ -             return @file_get_contents( $this->path ) != false; +             return @file_get_contents( $this->path ) != false;         } @@ -489,15 +489,15 @@         */         public function getContent(){             // S'il y a eu une erreur en amont -             if( $this->error != ManagerError::Success ) -                 return false; // on retourne faux +             if( $this->error != ManagerError::Success ) +                 return false; // on retourne faux             // On inclut le contenu -             $content = file_get_contents($this->path); +             $content = file_get_contents($this->path);             // On retourne tout -             return str_replace( '</svg>', $this->stylesheet.'</svg>', $content ); +             return str_replace( '</svg>', $this->stylesheet.'</svg>', $content );         } @@ -517,7 +517,7 @@ Dead Code

- Generated by PHP_CodeCoverage 2.1.7 using PHP 5.6.11-1ubuntu3.1 and PHPUnit 4.7.6 at Sun Apr 17 10:22:22 UTC 2016. + Generated by PHP_CodeCoverage 2.1.7 using PHP 5.6.11-1ubuntu3.1 and PHPUnit 4.7.6 at Sun Apr 17 10:48:24 UTC 2016.

diff --git a/phpunit/coverage/autoloader.php.html b/phpunit/coverage/autoloader.php.html index 26e7a23..3093c19 100755 --- a/phpunit/coverage/autoloader.php.html +++ b/phpunit/coverage/autoloader.php.html @@ -167,19 +167,19 @@     *     */     function autoloader($className){ -         $path = ''; +         $path = '';         /* [1] On utilise le namespace pour localiser         ===============================================*/         // On remplace les '\' par des '/' -         $path = str_replace('\\', '/', $className) . '.php'; -         $path = __ROOT__.'/'.$path; +         $path = str_replace('\\', '/', $className) . '.php'; +         $path = __ROOT__.'/'.$path;         // Si le fichier existe -         if( file_exists($path) ) -             require_once $path; // on inclue le fichier +         if( file_exists($path) ) +             require_once $path; // on inclue le fichier -     } +     }          // On definit l'autoloader comme autoloader (obvious)     spl_autoload_register('autoloader', false, true); @@ -214,7 +214,7 @@ Dead Code

- Generated by PHP_CodeCoverage 2.1.7 using PHP 5.6.11-1ubuntu3.1 and PHPUnit 4.7.6 at Sun Apr 17 10:22:22 UTC 2016. + Generated by PHP_CodeCoverage 2.1.7 using PHP 5.6.11-1ubuntu3.1 and PHPUnit 4.7.6 at Sun Apr 17 10:48:24 UTC 2016.

diff --git a/phpunit/coverage/index.html b/phpunit/coverage/index.html index 221999b..1394ca1 100755 --- a/phpunit/coverage/index.html +++ b/phpunit/coverage/index.html @@ -43,21 +43,21 @@ Total
-
- 64.25% covered (warning) +
+ 72.54% covered (warning)
-
64.25%
-
124 / 193
+
72.54%
+
140 / 193
-
- 38.89% covered (danger) +
+ 50.00% covered (danger)
-
38.89%
-
7 / 18
+
50.00%
+
9 / 18
25.00% covered (danger) @@ -71,21 +71,21 @@ Database.php
-
- 62.20% covered (warning) +
+ 84.15% covered (warning)
-
62.20%
-
51 / 82
-
-
- 14.29% covered (danger) +
84.15%
+
69 / 82
+
+
+ 57.14% covered (warning)
-
14.29%
-
1 / 7
+
57.14%
+
4 / 7
0.00% covered (danger) @@ -173,21 +173,21 @@ sessionManager.php
-
- 18.75% covered (danger) +
+ 6.25% covered (danger)
-
18.75%
-
3 / 16
+
6.25%
+
1 / 16
-
- 50.00% covered (danger) +
+ 25.00% covered (danger)
-
50.00%
-
2 / 4
+
25.00%
+
1 / 4
0.00% covered (danger) @@ -210,7 +210,7 @@ High: 90% to 100%

- Generated by PHP_CodeCoverage 2.1.7 using PHP 5.6.11-1ubuntu3.1 and PHPUnit 4.7.6 at Sun Apr 17 10:22:22 UTC 2016. + Generated by PHP_CodeCoverage 2.1.7 using PHP 5.6.11-1ubuntu3.1 and PHPUnit 4.7.6 at Sun Apr 17 10:48:24 UTC 2016.

diff --git a/phpunit/coverage/sessionManager.php.html b/phpunit/coverage/sessionManager.php.html index 1eec7f2..62e6983 100755 --- a/phpunit/coverage/sessionManager.php.html +++ b/phpunit/coverage/sessionManager.php.html @@ -51,22 +51,22 @@
0.00%
0 / 1
-
- 50.00% covered (danger) +
+ 25.00% covered (danger)
-
50.00%
-
2 / 4
+
25.00%
+
1 / 4
CRAP
-
- 18.75% covered (danger) +
+ 6.25% covered (danger)
-
18.75%
-
3 / 16
+
6.25%
+
1 / 16
@@ -80,22 +80,22 @@
0.00%
0 / 1
-
- 50.00% covered (danger) +
+ 25.00% covered (danger)
-
50.00%
-
2 / 4
- 75.90 +
25.00%
+
1 / 4
+ 110.70
-
- 18.75% covered (danger) +
+ 6.25% covered (danger)
-
18.75%
-
3 / 16
+
6.25%
+
1 / 16
@@ -162,24 +162,24 @@ -  session_start -
-
- 100.00% covered (success) +  session_start +
+
+ 0.00% covered (danger)
-
100.00%
-
1 / 1
- 7 -
-
- 100.00% covered (success) +
0.00%
+
0 / 1
+ 56 +
+
+ 0.00% covered (danger)
-
100.00%
-
2 / 2
+
0.00%
+
0 / 2
@@ -201,7 +201,7 @@         /* SECURE SHA1 ALGORITHM */         /*************************/         public static function sha1($data){ -             return sha1( '">\[..|{@#))'.sha1($data.'_)Q@#((%*_$%(@#') ); +             return sha1( '">\[..|{@#))'.sha1($data.'_)Q@#((%*_$%(@#') );         } @@ -247,8 +247,8 @@         /* AMORCEUR */         /************/         public static function session_start(){ -             \session_start(); -             return; +             \session_start(); +             return;             /* [1] Génération et Gestion des donnees a utiliser @@ -315,7 +315,7 @@ Dead Code

- Generated by PHP_CodeCoverage 2.1.7 using PHP 5.6.11-1ubuntu3.1 and PHPUnit 4.7.6 at Sun Apr 17 10:22:22 UTC 2016. + Generated by PHP_CodeCoverage 2.1.7 using PHP 5.6.11-1ubuntu3.1 and PHPUnit 4.7.6 at Sun Apr 17 10:48:24 UTC 2016.

diff --git a/phpunit/phpunit.xml b/phpunit/phpunit.xml index 2c2d7f8..c551a1b 100755 --- a/phpunit/phpunit.xml +++ b/phpunit/phpunit.xml @@ -10,9 +10,9 @@ ./tests/ManagerError.php - + diff --git a/phpunit/run.sh b/phpunit/run.sh index 92fe5d4..29714f9 100644 --- a/phpunit/run.sh +++ b/phpunit/run.sh @@ -1 +1 @@ -phpunit -c phpunit.xml --bootstrap bootstrap.php --coverage-html coverage \ No newline at end of file +phpunit -c phpunit.xml diff --git a/phpunit/tests/Database_check.php b/phpunit/tests/Database_check.php index b4a176c..a965f50 100755 --- a/phpunit/tests/Database_check.php +++ b/phpunit/tests/Database_check.php @@ -92,8 +92,49 @@ /* [3] Test des tableaux avec type des elements =========================================================*/ - + /* (1) Type */ + public function testArrayTypeCorrect(){ + $this->assertTrue( \manager\Database::check('array', array() ) ); + } + public function testArrayTypeIncorrect(){ + $this->assertFalse( \manager\Database::check('array', 10 ) ); + $this->assertFalse( \manager\Database::check('array', 'string' ) ); + } + /* (2) Tests divers */ + public function testArrayEmpty(){ + $arr = array(); + + $this->assertTrue( \manager\Database::check("array", $arr) ); + } + public function testArrayNotEmpty(){ + $arr = array('a', 'b'); + + $this->assertTrue( \manager\Database::check("array", $arr) ); + } + + public function testArrayAllRight(){ + $arr = array('a', 'aa', 'a', 'bb'); + + $this->assertTrue( \manager\Database::check("array", $arr) ); + } + public function testArrayOneWrong(){ + $arr = array('a', 'aa', 'a', 'bb', 'aaa'); + + $this->assertFalse( \manager\Database::check("array", $arr) ); + } + + + public function testArrayRecursive(){ + $arr = array( + array(1, 100), + array(1, 100), + array(1, 100), + array(1, 100) + ); + + $this->assertFalse( \manager\Database::check("array>", $arr) ); + } diff --git a/phpunit/tests/Database_construct.php b/phpunit/tests/Database_construct.php index 8a1ee18..65693a5 100755 --- a/phpunit/tests/Database_construct.php +++ b/phpunit/tests/Database_construct.php @@ -50,7 +50,7 @@ public function testPDO(){ $pdo = \manager\Database::getPDO(); - $this->assertGreaterThan( 10, count($pdo->query('SELECT * FROM user')->fetchAll()), '[!] Moins de 10 utilisateurs trouves.'); + $this->assertGreaterThan( 0, count($pdo->query('SELECT * FROM users')->fetchAll()), '[!] Aucun utilisateur trouve.'); }