From 19ffb0786054a3fa20891754230fe3940068a370 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Wed, 20 Apr 2016 15:45:31 +0200 Subject: [PATCH] Tests unitaires du fichier de configuration /config/upload-auth.json --- phpunit/coverage/Database.php.html | 2 +- phpunit/coverage/ManagerError.php.html | 100 ++++++++++--------- phpunit/coverage/ResourceDispatcher.php.html | 16 +-- phpunit/coverage/autoloader.php.html | 2 +- phpunit/coverage/index.html | 20 ++-- phpunit/coverage/sessionManager.php.html | 2 +- phpunit/tests/config.php | 26 ++++- 7 files changed, 96 insertions(+), 72 deletions(-) diff --git a/phpunit/coverage/Database.php.html b/phpunit/coverage/Database.php.html index 177a9f5..9e875c5 100755 --- a/phpunit/coverage/Database.php.html +++ b/phpunit/coverage/Database.php.html @@ -645,7 +645,7 @@ Dead Code

- Generated by PHP_CodeCoverage 2.1.7 using PHP 5.6.11-1ubuntu3.1 and PHPUnit 4.7.6 at Wed Apr 20 9:10:21 UTC 2016. + Generated by PHP_CodeCoverage 2.1.7 using PHP 5.6.11-1ubuntu3.1 and PHPUnit 4.7.6 at Wed Apr 20 13:45:11 UTC 2016.

diff --git a/phpunit/coverage/ManagerError.php.html b/phpunit/coverage/ManagerError.php.html index aa77299..0ff813d 100755 --- a/phpunit/coverage/ManagerError.php.html +++ b/phpunit/coverage/ManagerError.php.html @@ -66,7 +66,7 @@
100.00%
-
18 / 18
+
19 / 19
@@ -87,7 +87,7 @@
100.00%
1 / 1
- 18 + 19
100.00% covered (success) @@ -95,11 +95,11 @@
100.00%
-
18 / 18
+
19 / 19
-  explicit +  explicit
100.00% covered (success) @@ -108,7 +108,7 @@
100.00%
1 / 1
- 18 + 19
100.00% covered (success) @@ -116,7 +116,7 @@
100.00%
-
18 / 18
+
19 / 19
@@ -192,49 +192,53 @@             const PermissionError     = 16; - -         /* EXPLICITE UN CODE D'ERREUR -         * -         * @error<Integer>                                     Code d'erreur -         * -         * @return explicit<String>                             Description explicite du code d'erreur -         * -         */ -         public static function explicit($error){ -             switch($error){ -                 case self::Success:             return "Tout s'est bien deroule";                                             break; - -                 case self::ParsingFailed:       return "La lecture du fichier JSON ou XML a echoue";                          break; - -                 case self::InvalidFlags:        return "Les specifications (drapeaux) sont incorrects";                       break; -                 case self::UnreachableResource: return "La ressource n'existe pas (404)";                                     break; -                 case self::MissingPath:         return "Le chemin de delegation n'a pas ete renseigne";                       break; -                 case self::WrongPathModule:     return "Le chemin de delegation est incorrect ('nomModule/nomMethode')";      break; -                 case self::WrongPathRepo:       return "Le chemin de delegation est incorrect ('nomRepo/nomMethode')";        break; -                 case self::UnknownModule:       return "Le module 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::UncallableMethod:    return "Le methode n'est pas amorcable";                                      break; - -                 case self::ParamError:          return "Un ou plusieurs parametres sont manquants ou incorrects";             break; -                 case self::ModuleError:         return "Erreur lors du traitement du module";                                 break; -                 case self::RepoError:           return "Erreur lors du traitement du repo";                                   break; - -                 case self::PDOConnection:       return "La connexion avec la base de donnees a echoue";                       break; - -                 case self::TokenError:          return "Le token de connection est absent ou errone";                         break; -                 case self::PermissionError:     return "Vous n'avez pas la permission d'effectuer cette action";              break; +         /* Erreur d'UPLOAD */ +             const UploadError         = 17; + + +         /* EXPLICITE UN CODE D'ERREUR +         * +         * @error<Integer>                                     Code d'erreur +         * +         * @return explicit<String>                             Description explicite du code d'erreur +         * +         */ +         public static function explicit($error){ +             switch($error){ +                 case self::Success:             return "Tout s'est bien deroulé.";                                             break; + +                 case self::ParsingFailed:       return "La lecture du fichier JSON ou XML a echouée.";                         break; + +                 case self::InvalidFlags:        return "Les spécifications (drapeaux) sont incorrects.";                       break; +                 case self::UnreachableResource: return "La ressource n'existe pas (404).";                                     break; +                 case self::MissingPath:         return "Le chemin de délégation n'a pas été renseigné.";                       break; +                 case self::WrongPathModule:     return "Le chemin de délégation est incorrect ('nomModule/nomMethode').";      break; +                 case self::WrongPathRepo:       return "Le chemin de délégation est incorrect ('nomRepo/nomMethode').";        break; +                 case self::UnknownModule:       return "Le module 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::UncallableMethod:    return "Le methode n'est pas amorçable.";                                      break; + +                 case self::ParamError:          return "Un ou plusieurs paramètres sont manquants ou incorrects.";             break; +                 case self::ModuleError:         return "Erreur lors du traitement du module.";                                 break; +                 case self::RepoError:           return "Erreur lors du traitement du repo.";                                   break; + +                 case self::PDOConnection:       return "La connexion avec la base de données a echouée.";                      break; -                 // default:                        return "Erreur inconnue...";                                                  break; -             } - -             // Erreur inconnue -             return null; -         } +                 case self::TokenError:          return "Le token de connection est absent, érroné ou expiré.";                 break; +                 case self::PermissionError:     return "Vous n'avez pas la permission d'effectuer cette action.";              break; +                 case self::UploadError:         return "Une erreur d'upload est survenue.";                                   break; + +                 // default:                        return "Erreur inconnue...";                                                  break; +             } -     } - - ?> +             // Erreur inconnue +             return null; +         } + +     } + + ?> @@ -247,7 +251,7 @@ Dead Code

- Generated by PHP_CodeCoverage 2.1.7 using PHP 5.6.11-1ubuntu3.1 and PHPUnit 4.7.6 at Wed Apr 20 9:10:21 UTC 2016. + Generated by PHP_CodeCoverage 2.1.7 using PHP 5.6.11-1ubuntu3.1 and PHPUnit 4.7.6 at Wed Apr 20 13:45:11 UTC 2016.

diff --git a/phpunit/coverage/ResourceDispatcher.php.html b/phpunit/coverage/ResourceDispatcher.php.html index 64cd4fc..286a147 100755 --- a/phpunit/coverage/ResourceDispatcher.php.html +++ b/phpunit/coverage/ResourceDispatcher.php.html @@ -229,12 +229,12 @@ - + - + @@ -280,7 +280,7 @@ - + @@ -314,7 +314,7 @@ - + @@ -371,7 +371,7 @@ - + @@ -444,14 +444,14 @@ - + - + @@ -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 Wed Apr 20 9:10:21 UTC 2016. + Generated by PHP_CodeCoverage 2.1.7 using PHP 5.6.11-1ubuntu3.1 and PHPUnit 4.7.6 at Wed Apr 20 13:45:11 UTC 2016.

diff --git a/phpunit/coverage/autoloader.php.html b/phpunit/coverage/autoloader.php.html index 11c303d..5daa646 100755 --- a/phpunit/coverage/autoloader.php.html +++ b/phpunit/coverage/autoloader.php.html @@ -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 Wed Apr 20 9:10:21 UTC 2016. + Generated by PHP_CodeCoverage 2.1.7 using PHP 5.6.11-1ubuntu3.1 and PHPUnit 4.7.6 at Wed Apr 20 13:45:11 UTC 2016.

diff --git a/phpunit/coverage/index.html b/phpunit/coverage/index.html index a6d40b9..2af40fd 100755 --- a/phpunit/coverage/index.html +++ b/phpunit/coverage/index.html @@ -43,13 +43,13 @@ - - + + - + - - + +
<?php 
<?php
    namespace manager;
    use \manager\Repo;
    use \manager\sessionManager;
    
    class ResourceDispatcher{
            // Dossiers supportes
            $parents_conf = json_decode( file_get_contents(__ROOT__.self::$parents_config_path), true );
            
            // Gestion de l'erreur de parsage
            if( $parents_conf == null ){
                $this->error = ManagerError::ParsingFailed;
            if( $view ) // Appel externe
                $this->view();
            
            return true;
        }
            if( !$correct )
                return false;
                
            /* [2] Creation (non serialisee) des flags
            ======================================================*/
            // Si tout se deroule bien, on cree les flags
                    $this->stylesheet .= "\t}\n";
                $this->stylesheet .= "</style>";
            }
            
            /* [5] On definit le header
            ==========================================================*/
            $this->header = $header;
            /* [6] On construit le chemin 
            /* [6] On construit le chemin
            ==========================================================*/
            $this->path = __ROOT__.$parent.'/'.$opt_subParent.$this->flags['filename'].'.'.$this->flags['extension'];
Total
-
- 64.97% covered (warning) +
+ 65.21% covered (warning)
64.97%
280 / 431
65.21%
283 / 434
47.83% covered (danger) @@ -161,7 +161,7 @@
100.00%
18 / 18
19 / 19
100.00% covered (success) @@ -183,13 +183,13 @@
ModuleRequest.php
-
- 86.81% covered (warning) +
+ 87.10% covered (warning)
86.81%
79 / 91
87.10%
81 / 93
62.50% covered (warning) @@ -350,7 +350,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 Wed Apr 20 9:10:21 UTC 2016. + Generated by PHP_CodeCoverage 2.1.7 using PHP 5.6.11-1ubuntu3.1 and PHPUnit 4.7.6 at Wed Apr 20 13:45:11 UTC 2016.

diff --git a/phpunit/coverage/sessionManager.php.html b/phpunit/coverage/sessionManager.php.html index 508c90f..7e2bd09 100755 --- a/phpunit/coverage/sessionManager.php.html +++ b/phpunit/coverage/sessionManager.php.html @@ -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 Wed Apr 20 9:10:21 UTC 2016. + Generated by PHP_CodeCoverage 2.1.7 using PHP 5.6.11-1ubuntu3.1 and PHPUnit 4.7.6 at Wed Apr 20 13:45:11 UTC 2016.

diff --git a/phpunit/tests/config.php b/phpunit/tests/config.php index 5d6f383..ab1f475 100644 --- a/phpunit/tests/config.php +++ b/phpunit/tests/config.php @@ -13,8 +13,9 @@ 'dispatcher-tree' => '../config/dispatcher-tree.json', 'menu' => '../config/menu.json', 'modules' => '../config/modules.json', - 'repositories' => '../config/repositories.json', - 'views' => '../config/views.json' + 'repositories' =>'../config/repositories.json', + 'upload-auth' =>'../config/upload-auth.json', + 'views' =>'../config/views.json' ); /* [1] config/database-local.json @@ -208,7 +209,26 @@ } } - /* [6] config/views.json + /* [6] config/upload-auth.json + =========================================================*/ + public function testUploadAuth(){ + /* (1) Lecture du fichier */ + $file_content = file_get_contents( self::$config['upload-auth'] ); + $this->assertNotFalse( $file_content ); + + /* (2) Parsage en JSON */ + $json_content = json_decode( $file_content, true ); + $this->assertNotNull( $json_content ); + + /* (3) Racine des uploads */ + $this->assertTrue( isset($json_content['root']) ); + + /* (4) Liste des répertoires autorisés */ + foreach($json_content['directories'] as $dir) + $this->assertTrue( preg_match('/^[a-z0-9_-]+$/', $dir) == true ); + } + + /* [7] config/views.json =========================================================*/ public function testViews(){ /* (1) Lecture du fichier */