From cd1daeb05127646b6c811a81c13016d673c85295 Mon Sep 17 00:00:00 2001 From: Lucas Mascaro Date: Sun, 3 Jan 2016 18:35:41 +0100 Subject: [PATCH] correction et completion de tests --- coverage/StaticRepo.php.html | 56 +++++++-------- coverage/dashboard.html | 11 ++- coverage/index.html | 34 +++++----- coverage/repos/MedecinRepo.php.html | 102 ++++++++++++++-------------- coverage/repos/PatientRepo.php.html | 8 +-- coverage/repos/RDVRepo.php.html | 2 +- coverage/repos/StatsRepo.php.html | 2 +- coverage/repos/dashboard.html | 11 ++- coverage/repos/index.html | 34 +++++----- repositories/repos/MedecinRepo.php | 4 +- repositories/repos/PatientRepo.php | 2 +- test/MedecinRepoTest.php | 6 +- 12 files changed, 137 insertions(+), 135 deletions(-) diff --git a/coverage/StaticRepo.php.html b/coverage/StaticRepo.php.html index eda9e8e..7062b70 100755 --- a/coverage/StaticRepo.php.html +++ b/coverage/StaticRepo.php.html @@ -201,13 +201,13 @@
12
     * @return PDO instance de la connexion a la BDD
13
     */
14
    public static function getConnexion(){ -
15
        if(static::$config == null){ -
16
            static::$config = json_decode(file_get_contents(dirname(__FILE__).DIRECTORY_SEPARATOR.'config.json'),true); +
15
        if(static::$config == null){ +
16
            static::$config = json_decode(file_get_contents(dirname(__FILE__).DIRECTORY_SEPARATOR.'config.json'),true);
17
        } -
18
        if(static::$connexion == null){ -
19
            static::$connexion = new PDO('mysql:host='.static::$config['host'].';dbname='.static::$config['database'], static::$config['login'], static::$config['password']); +
18
        if(static::$connexion == null){ +
19
            static::$connexion = new PDO('mysql:host='.static::$config['host'].';dbname='.static::$config['database'], static::$config['login'], static::$config['password']);
20
        } -
21
        return static::$connexion; +
21
        return static::$connexion;
22
    }
23
24
    /** @@ -230,11 +230,11 @@
41
    public static function delNumeric($fetchData, $oneDimension=false){
42
    
43
    // cas où fetch renvoie FALSE -
44
    if( $fetchData === false ) return false; +
44
    if( $fetchData === false ) return false;
45
46
        /* [1] 2 dimensions
47
        ===============================================*/ -
48
        if( !$oneDimension ){ +
48
        if( !$oneDimension ){
49
50
        // on supprime les doublons des entrées (indice numérique)
51
        for( $i = 0 ; $i < count($fetchData) ; $i++ ) // pour tout les utilisateurs @@ -252,18 +252,18 @@
63
        }else{
64
65
            // on supprime les doublons des entrées (indice numérique) -
66
            foreach($fetchData as $i=>$val){ // pour toutes les entrées +
66
            foreach($fetchData as $i=>$val){ // pour toutes les entrées
67
                 -
68
                if( !mb_detect_encoding($val, 'UTF-8') ) +
68
                if( !mb_detect_encoding($val, 'UTF-8') )
69
                    $fetchData[$i] = utf8_encode($val);
70
-
71
                if( is_int($i) )             // si l'indice est un entier -
72
                    unset( $fetchData[$i] ); // on le supprime +
71
                if( is_int($i) )             // si l'indice est un entier +
72
                    unset( $fetchData[$i] ); // on le supprime
73
            }
74
75
        }
76
-
77
        return $fetchData; +
77
        return $fetchData;
78
    }
79
80
@@ -291,39 +291,39 @@
102
    public static function checkParam($variable, $dbtype){
103
        /* [1] on vérifie que $dbtype est un String
104
        =============================================================*/ -
105
        if( !is_string($dbtype) ) return false; +
105
        if( !is_string($dbtype) ) return false;
106
107
108
        /* [2] Vérifications
109
        =============================================================*/ -
110
        $checker = true; // contiendra VRAI si la vérification s'avère correcte -
111
        $matches = []; -
112
        $len = 8; +
110
        $checker = true; // contiendra VRAI si la vérification s'avère correcte +
111
        $matches = []; +
112
        $len = 8;
113
114
        //si on a un type scalairexlongueur, on traite -
115
        if(preg_match_all('/([A-Z][a-z]+)(\d+)/s', $dbtype,$matches)){ -
116
            $dbtype = $matches[1][0]; -
117
            $len    = $matches[2][0]; +
115
        if(preg_match_all('/([A-Z][a-z]+)(\d+)/s', $dbtype,$matches)){ +
116
            $dbtype = $matches[1][0]; +
117
            $len    = $matches[2][0];
118
        }
119
120
        switch($dbtype){
121
            // [1] 'M' / 'F'  -
122
            case 'Civilite': -
123
                $checker = $checker && !is_null($variable) && is_string($variable) && in_array($variable, ['M','F']); -
124
                break; +
122
            case 'Civilite': +
123
                $checker = $checker && !is_null($variable) && is_string($variable) && in_array($variable, ['M','F']); +
124
                break;
125
126
            // [2] Chaine de caractère (longueur variable)
127
            case 'String': -
128
                $checker = $checker && !is_null($variable) && is_string($variable) && strlen($variable) > 0 && strlen($variable) <= $len; -
129
                break; +
128
                $checker = $checker && !is_null($variable) && is_string($variable) && strlen($variable) > 0 && strlen($variable) <= $len; +
129
                break;
130
131
            case 'Integer':
132
                $checker = $checker && !is_null($variable) && is_int($variable) && $variable<pow(2, 32);
133
                break;
134
135
            case 'Numeric': -
136
                $checker = $checker && !is_null($variable) && is_numeric($variable); -
137
                break; +
136
                $checker = $checker && !is_null($variable) && is_numeric($variable); +
137
                break;
138
139
            case 'SmallInteger':
140
                $checker = $checker && !is_null($variable) && is_int($variable) && $variable<pow(2, 16); @@ -352,7 +352,7 @@
163
164
        /* [3] On retourne le résultat de la vérif
165
        =============================================================*/ -
166
        return $checker; +
166
        return $checker;
167
168
    }
169
@@ -372,7 +372,7 @@ Dead Code

- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.1 and PHPUnit 5.1.3 at Sun Jan 3 17:26:02 UTC 2016. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.1 and PHPUnit 5.1.3 at Sun Jan 3 17:34:44 UTC 2016.

diff --git a/coverage/dashboard.html b/coverage/dashboard.html index 0459ac0..f680577 100755 --- a/coverage/dashboard.html +++ b/coverage/dashboard.html @@ -113,7 +113,6 @@ - update0% checkParam80% delNumeric85% getAll86% @@ -137,7 +136,7 @@ checkParam51 delNumeric10 getAll5 - add5 + add3 @@ -147,7 +146,7 @@ @@ -186,7 +185,7 @@ $(document).ready(function() { .yAxis.tickFormat(d3.format('d')); d3.select('#methodCoverageDistribution svg') - .datum(getCoverageDistributionData([1,0,0,0,0,0,0,0,0,4,3,21], "Method Coverage")) + .datum(getCoverageDistributionData([0,0,0,0,0,0,0,0,0,4,3,22], "Method Coverage")) .transition().duration(500).call(chart); nv.utils.windowResize(chart.update); @@ -236,7 +235,7 @@ $(document).ready(function() { chart.yAxis.axisLabel('Cyclomatic Complexity'); d3.select('#classComplexity svg') - .datum(getComplexityData([[83.928571428571,54,"StaticRepo<\/a>"],[91.176470588235,20,"MedecinRepo<\/a>"],[97.560975609756,47,"PatientRepo<\/a>"],[96.774193548387,25,"RDVRepo<\/a>"],[93.548387096774,9,"StatsRepo<\/a>"]], 'Class Complexity')) + .datum(getComplexityData([[83.928571428571,54,"StaticRepo<\/a>"],[97.058823529412,17,"MedecinRepo<\/a>"],[97.560975609756,46,"PatientRepo<\/a>"],[96.774193548387,25,"RDVRepo<\/a>"],[93.548387096774,9,"StatsRepo<\/a>"]], 'Class Complexity')) .transition() .duration(500) .call(chart); @@ -260,7 +259,7 @@ $(document).ready(function() { chart.yAxis.axisLabel('Method Complexity'); d3.select('#methodComplexity svg') - .datum(getComplexityData([[100,3,"StaticRepo::getConnexion<\/a>"],[100,1,"StaticRepo::testConnexion<\/a>"],[85.714285714286,10,"StaticRepo::delNumeric<\/a>"],[80.555555555556,40,"StaticRepo::checkParam<\/a>"],[100,2,"MedecinRepo::getById<\/a>"],[88.888888888889,5,"MedecinRepo::add<\/a>"],[100,2,"MedecinRepo::delete<\/a>"],[100,7,"MedecinRepo::search<\/a>"],[100,2,"MedecinRepo::getPatients<\/a>"],[100,1,"MedecinRepo::getAll<\/a>"],[0,1,"MedecinRepo::update<\/a>"],[100,2,"PatientRepo::getById<\/a>"],[96.774193548387,16,"PatientRepo::add<\/a>"],[96.774193548387,16,"PatientRepo::update<\/a>"],[100,2,"PatientRepo::delete<\/a>"],[100,3,"PatientRepo::updateMedecinTraitant<\/a>"],[100,7,"PatientRepo::search<\/a>"],[100,1,"PatientRepo::getAll<\/a>"],[100,2,"RDVRepo::getById<\/a>"],[100,1,"RDVRepo::getForMonth<\/a>"],[100,2,"RDVRepo::getByDate<\/a>"],[100,2,"RDVRepo::delete<\/a>"],[100,6,"RDVRepo::add<\/a>"],[100,2,"RDVRepo::updateDateTime<\/a>"],[100,3,"RDVRepo::getByPatientAndDate<\/a>"],[86.666666666667,5,"RDVRepo::getAll<\/a>"],[100,2,"RDVRepo::getByMonth<\/a>"],[92.592592592593,8,"StatsRepo::getAgePatient<\/a>"],[100,1,"StatsRepo::getRDVStat<\/a>"]], 'Method Complexity')) + .datum(getComplexityData([[100,3,"StaticRepo::getConnexion<\/a>"],[100,1,"StaticRepo::testConnexion<\/a>"],[85.714285714286,10,"StaticRepo::delNumeric<\/a>"],[80.555555555556,40,"StaticRepo::checkParam<\/a>"],[100,2,"MedecinRepo::getById<\/a>"],[88.888888888889,3,"MedecinRepo::add<\/a>"],[100,2,"MedecinRepo::delete<\/a>"],[100,6,"MedecinRepo::search<\/a>"],[100,2,"MedecinRepo::getPatients<\/a>"],[100,1,"MedecinRepo::getAll<\/a>"],[100,1,"MedecinRepo::update<\/a>"],[100,2,"PatientRepo::getById<\/a>"],[96.774193548387,16,"PatientRepo::add<\/a>"],[96.774193548387,16,"PatientRepo::update<\/a>"],[100,2,"PatientRepo::delete<\/a>"],[100,3,"PatientRepo::updateMedecinTraitant<\/a>"],[100,6,"PatientRepo::search<\/a>"],[100,1,"PatientRepo::getAll<\/a>"],[100,2,"RDVRepo::getById<\/a>"],[100,1,"RDVRepo::getForMonth<\/a>"],[100,2,"RDVRepo::getByDate<\/a>"],[100,2,"RDVRepo::delete<\/a>"],[100,6,"RDVRepo::add<\/a>"],[100,2,"RDVRepo::updateDateTime<\/a>"],[100,3,"RDVRepo::getByPatientAndDate<\/a>"],[86.666666666667,5,"RDVRepo::getAll<\/a>"],[100,2,"RDVRepo::getByMonth<\/a>"],[92.592592592593,8,"StatsRepo::getAgePatient<\/a>"],[100,1,"StatsRepo::getRDVStat<\/a>"]], 'Method Complexity')) .transition() .duration(500) .call(chart); diff --git a/coverage/index.html b/coverage/index.html index c7ea752..0006479 100755 --- a/coverage/index.html +++ b/coverage/index.html @@ -43,21 +43,21 @@ Total
-
- 93.21% covered (success) +
+ 93.96% covered (success)
-
93.21%
-
247 / 265
+
93.96%
+
249 / 265
-
- 72.41% covered (warning) +
+ 75.86% covered (warning)
-
72.41%
-
21 / 29
+
75.86%
+
22 / 29
0.00% covered (danger) @@ -71,21 +71,21 @@ repos
-
- 95.69% covered (success) +
+ 96.65% covered (success)
-
95.69%
-
200 / 209
+
96.65%
+
202 / 209
-
- 76.00% covered (warning) +
+ 80.00% covered (warning)
-
76.00%
-
19 / 25
+
80.00%
+
20 / 25
0.00% covered (danger) @@ -136,7 +136,7 @@ High: 90% to 100%

- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.1 and PHPUnit 5.1.3 at Sun Jan 3 17:26:02 UTC 2016. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.1 and PHPUnit 5.1.3 at Sun Jan 3 17:34:44 UTC 2016.

diff --git a/coverage/repos/MedecinRepo.php.html b/coverage/repos/MedecinRepo.php.html index bf4f5ff..3ee9160 100755 --- a/coverage/repos/MedecinRepo.php.html +++ b/coverage/repos/MedecinRepo.php.html @@ -52,22 +52,22 @@
0.00%
0 / 1
-
- 71.43% covered (warning) +
+ 85.71% covered (warning)
-
71.43%
-
5 / 7
+
85.71%
+
6 / 7
CRAP
-
- 91.18% covered (success) +
+ 97.06% covered (success)
-
91.18%
-
31 / 34
+
97.06%
+
33 / 34
@@ -81,22 +81,22 @@
0.00%
0 / 1
-
- 71.43% covered (warning) +
+ 85.71% covered (warning)
-
71.43%
-
5 / 7
- 20.27 +
85.71%
+
6 / 7
+ 17
-
- 91.18% covered (success) +
+ 97.06% covered (success)
-
91.18%
-
31 / 34
+
97.06%
+
33 / 34
@@ -130,7 +130,7 @@
0.00%
0 / 1
- 5.03 + 3.01
88.89% covered (warning) @@ -172,7 +172,7 @@
100.00%
1 / 1
- 7 + 6
100.00% covered (success) @@ -226,24 +226,24 @@ -  update -
-
- 0.00% covered (danger) +  update +
+
+ 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 / 2
+
100.00%
+
2 / 2
@@ -264,46 +264,46 @@     public static function getById($id){ -         if(!StaticRepo::checkParam($id, 'Numeric')) return false; +         if(!StaticRepo::checkParam($id, 'Numeric')) return false; -         $req = StaticRepo::getConnexion()->prepare('SELECT * FROM Medecin WHERE Id = :id'); -         $req->execute(['id' => $id]); -         return StaticRepo::delNumeric( $req->fetch(), true ); +         $req = StaticRepo::getConnexion()->prepare('SELECT * FROM Medecin WHERE Id = :id'); +         $req->execute(['id' => $id]); +         return StaticRepo::delNumeric( $req->fetch(), true );     }     public static function add($civilite,$prenom,$nom){ -         if(!StaticRepo::checkParam($civilite,'Civilite') && !StaticRepo::checkParam($prenom,'String45') && !StaticRepo::checkParam($nom,'String45')) return false; +         if(!StaticRepo::checkParam($civilite,'Civilite') | !StaticRepo::checkParam($prenom,'String45') | !StaticRepo::checkParam($nom,'String45')) return false; -         $req = StaticRepo::getConnexion()->prepare('INSERT INTO Medecin VALUES (DEFAULT,:civilite,:prenom,:nom)'); -         $result = $req->execute(['civilite' => $civilite, -             'nom' => $nom, -             'prenom' => $prenom +         $req = StaticRepo::getConnexion()->prepare('INSERT INTO Medecin VALUES (DEFAULT,:civilite,:prenom,:nom)'); +         $result = $req->execute(['civilite' => $civilite, +             'nom' => $nom, +             'prenom' => $prenom         ]);         //PDO renvoie un ID sous forme de char, on transtype -         $id = StaticRepo::getConnexion()->lastInsertId(); -         settype($id, 'integer'); +         $id = StaticRepo::getConnexion()->lastInsertId(); +         settype($id, 'integer'); -         if($result) return $id; +         if($result) return $id;         else        return false;     }     public static function delete($idMedecin){ -         if(!StaticRepo::checkParam($idMedecin,'Numeric')) return false; +         if(!StaticRepo::checkParam($idMedecin,'Numeric')) return false; -         var_dump($idMedecin); +         var_dump($idMedecin); -         $req = StaticRepo::getConnexion()->prepare('DELETE FROM Medecin WHERE Id = :id'); -         return $req->execute(['id' => $idMedecin]); +         $req = StaticRepo::getConnexion()->prepare('DELETE FROM Medecin WHERE Id = :id'); +         return $req->execute(['id' => $idMedecin]);     }     public static function search($nom, $prenom){ -         if( !StaticRepo::checkParam($prenom,'String45') && !StaticRepo::checkParam($nom,'String45') ) return false; +         if( !StaticRepo::checkParam($prenom,'String45') | !StaticRepo::checkParam($nom,'String45') ) return false;         // on définit les valeurs (peuvent être nulles)         $optPrenom = ( $prenom != 'null' && StaticRepo::checkParam($prenom,'String45') ) ? '%'.$prenom.'%' : '%'; @@ -342,8 +342,8 @@     public static function update($id, $nom, $prenom){ -         $req = StaticRepo::getConnexion()->prepare("UPDATE Medecin SET Nom = :nom, Prenom = :prenom WHERE Id = :id"); -         return $req->execute([ ':nom' => strtoupper($nom), ':prenom' => $prenom, ':id' => $id ]); +         $req = StaticRepo::getConnexion()->prepare("UPDATE Medecin SET Nom = :nom, Prenom = :prenom WHERE Id = :id"); +         return $req->execute([ ':nom' => strtoupper($nom), ':prenom' => $prenom, ':id' => $id ]);     } } @@ -359,7 +359,7 @@ Dead Code

- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.1 and PHPUnit 5.1.3 at Sun Jan 3 17:26:02 UTC 2016. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.1 and PHPUnit 5.1.3 at Sun Jan 3 17:34:44 UTC 2016.

diff --git a/coverage/repos/PatientRepo.php.html b/coverage/repos/PatientRepo.php.html index f501eda..f0ff79c 100755 --- a/coverage/repos/PatientRepo.php.html +++ b/coverage/repos/PatientRepo.php.html @@ -88,7 +88,7 @@
71.43%
5 / 7
- 47 + 46
97.56% covered (success) @@ -214,7 +214,7 @@
100.00%
1 / 1
- 7 + 6
100.00% covered (success) @@ -386,7 +386,7 @@     public static function search($nom, $prenom){ -         if( !StaticRepo::checkParam($prenom,'String45') && !StaticRepo::checkParam($nom,'String45') ) return false; +         if( !StaticRepo::checkParam($prenom,'String45') | !StaticRepo::checkParam($nom,'String45') ) return false;         // on définit les valeurs (peuvent être nulles)         $optPrenom = ( $prenom != 'null' && StaticRepo::checkParam($prenom,'String45') ) ? '%'.$prenom.'%' : '%'; @@ -424,7 +424,7 @@ Dead Code

- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.1 and PHPUnit 5.1.3 at Sun Jan 3 17:26:02 UTC 2016. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.1 and PHPUnit 5.1.3 at Sun Jan 3 17:34:44 UTC 2016.

diff --git a/coverage/repos/RDVRepo.php.html b/coverage/repos/RDVRepo.php.html index 6d44799..3596caf 100755 --- a/coverage/repos/RDVRepo.php.html +++ b/coverage/repos/RDVRepo.php.html @@ -437,7 +437,7 @@ Dead Code

- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.1 and PHPUnit 5.1.3 at Sun Jan 3 17:26:02 UTC 2016. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.1 and PHPUnit 5.1.3 at Sun Jan 3 17:34:44 UTC 2016.

diff --git a/coverage/repos/StatsRepo.php.html b/coverage/repos/StatsRepo.php.html index 0a7dd77..66b83a2 100755 --- a/coverage/repos/StatsRepo.php.html +++ b/coverage/repos/StatsRepo.php.html @@ -220,7 +220,7 @@ Dead Code

- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.1 and PHPUnit 5.1.3 at Sun Jan 3 17:26:02 UTC 2016. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.1 and PHPUnit 5.1.3 at Sun Jan 3 17:34:44 UTC 2016.

diff --git a/coverage/repos/dashboard.html b/coverage/repos/dashboard.html index 717ed5f..2d229e8 100755 --- a/coverage/repos/dashboard.html +++ b/coverage/repos/dashboard.html @@ -112,7 +112,6 @@ - update0% getAll86% add88% @@ -132,7 +131,7 @@ getAll5 - add5 + add3 @@ -142,7 +141,7 @@
@@ -181,7 +180,7 @@ $(document).ready(function() { .yAxis.tickFormat(d3.format('d')); d3.select('#methodCoverageDistribution svg') - .datum(getCoverageDistributionData([1,0,0,0,0,0,0,0,0,2,3,19], "Method Coverage")) + .datum(getCoverageDistributionData([0,0,0,0,0,0,0,0,0,2,3,20], "Method Coverage")) .transition().duration(500).call(chart); nv.utils.windowResize(chart.update); @@ -231,7 +230,7 @@ $(document).ready(function() { chart.yAxis.axisLabel('Cyclomatic Complexity'); d3.select('#classComplexity svg') - .datum(getComplexityData([[91.176470588235,20,"MedecinRepo<\/a>"],[97.560975609756,47,"PatientRepo<\/a>"],[96.774193548387,25,"RDVRepo<\/a>"],[93.548387096774,9,"StatsRepo<\/a>"]], 'Class Complexity')) + .datum(getComplexityData([[97.058823529412,17,"MedecinRepo<\/a>"],[97.560975609756,46,"PatientRepo<\/a>"],[96.774193548387,25,"RDVRepo<\/a>"],[93.548387096774,9,"StatsRepo<\/a>"]], 'Class Complexity')) .transition() .duration(500) .call(chart); @@ -255,7 +254,7 @@ $(document).ready(function() { chart.yAxis.axisLabel('Method Complexity'); d3.select('#methodComplexity svg') - .datum(getComplexityData([[100,2,"MedecinRepo::getById<\/a>"],[88.888888888889,5,"MedecinRepo::add<\/a>"],[100,2,"MedecinRepo::delete<\/a>"],[100,7,"MedecinRepo::search<\/a>"],[100,2,"MedecinRepo::getPatients<\/a>"],[100,1,"MedecinRepo::getAll<\/a>"],[0,1,"MedecinRepo::update<\/a>"],[100,2,"PatientRepo::getById<\/a>"],[96.774193548387,16,"PatientRepo::add<\/a>"],[96.774193548387,16,"PatientRepo::update<\/a>"],[100,2,"PatientRepo::delete<\/a>"],[100,3,"PatientRepo::updateMedecinTraitant<\/a>"],[100,7,"PatientRepo::search<\/a>"],[100,1,"PatientRepo::getAll<\/a>"],[100,2,"RDVRepo::getById<\/a>"],[100,1,"RDVRepo::getForMonth<\/a>"],[100,2,"RDVRepo::getByDate<\/a>"],[100,2,"RDVRepo::delete<\/a>"],[100,6,"RDVRepo::add<\/a>"],[100,2,"RDVRepo::updateDateTime<\/a>"],[100,3,"RDVRepo::getByPatientAndDate<\/a>"],[86.666666666667,5,"RDVRepo::getAll<\/a>"],[100,2,"RDVRepo::getByMonth<\/a>"],[92.592592592593,8,"StatsRepo::getAgePatient<\/a>"],[100,1,"StatsRepo::getRDVStat<\/a>"]], 'Method Complexity')) + .datum(getComplexityData([[100,2,"MedecinRepo::getById<\/a>"],[88.888888888889,3,"MedecinRepo::add<\/a>"],[100,2,"MedecinRepo::delete<\/a>"],[100,6,"MedecinRepo::search<\/a>"],[100,2,"MedecinRepo::getPatients<\/a>"],[100,1,"MedecinRepo::getAll<\/a>"],[100,1,"MedecinRepo::update<\/a>"],[100,2,"PatientRepo::getById<\/a>"],[96.774193548387,16,"PatientRepo::add<\/a>"],[96.774193548387,16,"PatientRepo::update<\/a>"],[100,2,"PatientRepo::delete<\/a>"],[100,3,"PatientRepo::updateMedecinTraitant<\/a>"],[100,6,"PatientRepo::search<\/a>"],[100,1,"PatientRepo::getAll<\/a>"],[100,2,"RDVRepo::getById<\/a>"],[100,1,"RDVRepo::getForMonth<\/a>"],[100,2,"RDVRepo::getByDate<\/a>"],[100,2,"RDVRepo::delete<\/a>"],[100,6,"RDVRepo::add<\/a>"],[100,2,"RDVRepo::updateDateTime<\/a>"],[100,3,"RDVRepo::getByPatientAndDate<\/a>"],[86.666666666667,5,"RDVRepo::getAll<\/a>"],[100,2,"RDVRepo::getByMonth<\/a>"],[92.592592592593,8,"StatsRepo::getAgePatient<\/a>"],[100,1,"StatsRepo::getRDVStat<\/a>"]], 'Method Complexity')) .transition() .duration(500) .call(chart); diff --git a/coverage/repos/index.html b/coverage/repos/index.html index a040bea..75178d7 100755 --- a/coverage/repos/index.html +++ b/coverage/repos/index.html @@ -44,21 +44,21 @@ Total
-
- 95.69% covered (success) +
+ 96.65% covered (success)
-
95.69%
-
200 / 209
+
96.65%
+
202 / 209
-
- 76.00% covered (warning) +
+ 80.00% covered (warning)
-
76.00%
-
19 / 25
+
80.00%
+
20 / 25
0.00% covered (danger) @@ -72,21 +72,21 @@ MedecinRepo.php
-
- 91.18% covered (success) +
+ 97.06% covered (success)
-
91.18%
-
31 / 34
+
97.06%
+
33 / 34
-
- 71.43% covered (warning) +
+ 85.71% covered (warning)
-
71.43%
-
5 / 7
+
85.71%
+
6 / 7
0.00% covered (danger) @@ -193,7 +193,7 @@ High: 90% to 100%

- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.1 and PHPUnit 5.1.3 at Sun Jan 3 17:26:02 UTC 2016. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.1 and PHPUnit 5.1.3 at Sun Jan 3 17:34:44 UTC 2016.

diff --git a/repositories/repos/MedecinRepo.php b/repositories/repos/MedecinRepo.php index 6ef2e81..c53c489 100755 --- a/repositories/repos/MedecinRepo.php +++ b/repositories/repos/MedecinRepo.php @@ -21,7 +21,7 @@ class MedecinRepo public static function add($civilite,$prenom,$nom){ - if(!StaticRepo::checkParam($civilite,'Civilite') && !StaticRepo::checkParam($prenom,'String45') && !StaticRepo::checkParam($nom,'String45')) return false; + if(!StaticRepo::checkParam($civilite,'Civilite') | !StaticRepo::checkParam($prenom,'String45') | !StaticRepo::checkParam($nom,'String45')) return false; $req = StaticRepo::getConnexion()->prepare('INSERT INTO Medecin VALUES (DEFAULT,:civilite,:prenom,:nom)'); $result = $req->execute(['civilite' => $civilite, @@ -50,7 +50,7 @@ class MedecinRepo public static function search($nom, $prenom){ - if( !StaticRepo::checkParam($prenom,'String45') && !StaticRepo::checkParam($nom,'String45') ) return false; + if( !StaticRepo::checkParam($prenom,'String45') | !StaticRepo::checkParam($nom,'String45') ) return false; // on définit les valeurs (peuvent être nulles) $optPrenom = ( $prenom != 'null' && StaticRepo::checkParam($prenom,'String45') ) ? '%'.$prenom.'%' : '%'; diff --git a/repositories/repos/PatientRepo.php b/repositories/repos/PatientRepo.php index edc3743..bed59a4 100755 --- a/repositories/repos/PatientRepo.php +++ b/repositories/repos/PatientRepo.php @@ -133,7 +133,7 @@ class PatientRepo public static function search($nom, $prenom){ - if( !StaticRepo::checkParam($prenom,'String45') && !StaticRepo::checkParam($nom,'String45') ) return false; + if( !StaticRepo::checkParam($prenom,'String45') | !StaticRepo::checkParam($nom,'String45') ) return false; // on définit les valeurs (peuvent être nulles) $optPrenom = ( $prenom != 'null' && StaticRepo::checkParam($prenom,'String45') ) ? '%'.$prenom.'%' : '%'; diff --git a/test/MedecinRepoTest.php b/test/MedecinRepoTest.php index cc161aa..2df169a 100755 --- a/test/MedecinRepoTest.php +++ b/test/MedecinRepoTest.php @@ -17,10 +17,14 @@ class MedecinRepoTest extends PHPUnit_Framework_TestCase public function testConstruct(){ $this->assertTrue(new MedecinRepo() instanceof MedecinRepo); } - public function testAddAndDelete(){ + public function testAddDeleteUpdate(){ $id = $this->repo->add('M','Lucas','Mascaro'); $this->assertNotNull($id); + $this->assertTrue($this->repo->update($id,'Mascara','Loucasse')); + $this->assertEquals($this->repo->getById($id)['Nom'],'MASCARA'); $this->assertTrue($this->repo->delete($id)); + + $this->assertFalse($this->repo->add('Z','Lucas','Mascaro')); } public function testSearch(){