Tests unitaires de tous les fichiers de configuration

This commit is contained in:
xdrm-brackets 2016-04-18 08:42:26 +02:00
parent 8012f68f6b
commit 81fcbde794
18 changed files with 171 additions and 72 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
.ftpconfig
sftp-config.json sftp-config.json
phpunit/coverage/ phpunit/coverage/

View File

@ -74,10 +74,10 @@
debug(); debug();
/* () Test du client de l'API generique */
// $api = new client(); // $api = new client();
// $response = $api->send('testmethod', array( // $response = $api->send('generate-network-chart-data', array(
// '@token'=> '52945efbed43b50c12413f2f0e9519bfd9e98ce8' // '@token'=> '52945efbed43b50c12413f2f0e9519bfd9e98ce8'
// )); // ));

View File

@ -60,4 +60,4 @@
"attributes": { "data-sublink": "users" } } "attributes": { "data-sublink": "users" } }
] ]
} }
] ]

View File

@ -16,7 +16,7 @@
"parameters": {} "parameters": {}
}, },
"getById": { "getById": {
"description": "Retourne les informations d'un utilisateur.", "description": "Retourne les informations d'un utilisateur.",
"permissions": ["admin"], "permissions": ["admin"],
@ -25,14 +25,14 @@
} }
}, },
"getAll": { "getAll": {
"description": "Retourne les informations de tous les utilisateurs.", "description": "Retourne les informations de tous les utilisateurs.",
"permissions": ["admin"], "permissions": ["admin"],
"parameters": {} "parameters": {}
}, },
"create": { "create": {
"description": "Creation d'un nouvel utilisateur.", "description": "Creation d'un nouvel utilisateur.",
"permissions": ["admin"], "permissions": ["admin"],
@ -45,7 +45,7 @@
} }
}, },
"remove": { "remove": {
"description": "Suppression d'un utilisateur.", "description": "Suppression d'un utilisateur.",
"permissions": ["admin"], "permissions": ["admin"],
@ -105,4 +105,4 @@
} }
} }
} }

View File

@ -23,4 +23,4 @@
"remove" "remove"
] ]
} }

View File

@ -4,4 +4,4 @@
"analytics", "analytics",
"charts", "charts",
"settings" "settings"
] ]

View File

@ -1,6 +1,6 @@
@import 'constants'; @import 'constants';
body{ body{
font-family: 'Open Sans'; font-family: 'Open Sans';
font-size: 15px; font-size: 15px;
@ -23,7 +23,7 @@ body{
z-index: 1; z-index: 1;
/* [1] Header de la page /* [1] Header de la page
==========================================*/ ==========================================*/
& > #HEADER{ & > #HEADER{
@ -42,9 +42,9 @@ body{
} }
/* [2] Side-Menu de la page /* [2] Side-Menu de la page
==========================================*/ ==========================================*/
// Gestion du menu // Gestion du menu
& > #MENU-SIDE{ & > #MENU-SIDE{
display: block; display: block;
@ -62,7 +62,7 @@ body{
z-index: 10; z-index: 10;
} }
/* [3] Container de la page /* [3] Container de la page
==========================================*/ ==========================================*/
@ -101,7 +101,7 @@ body{
&.active{ &.active{
left: 0; left: 0;
} }
// flex properties // flex properties
flex-direction: row; flex-direction: row;
flex-wrap: nowrap; flex-wrap: nowrap;
@ -131,7 +131,7 @@ body{
/* (2) Formulaire de connexion */ /* (2) Formulaire de connexion */
& > #login-form{ & > #login-form{
display: block; display: block;
/* (2.1) Champs de texte (login/password) */ /* (2.1) Champs de texte (login/password) */
& > input[type='text'], & > input[type='text'],
@ -149,7 +149,7 @@ body{
flex-wrap: nowrap; flex-wrap: nowrap;
align-items: middle; align-items: middle;
border-radius: 5px; border-radius: 5px;
border: 1px solid lighten($theme-fg, 10); border: 1px solid lighten($theme-fg, 10);
@ -158,7 +158,7 @@ body{
color: $dark-fg-primary; color: $dark-fg-primary;
font-weight: bold; font-weight: bold;
letter-spacing: .07em; letter-spacing: .07em;
transition: border .2s ease-in-out; transition: border .2s ease-in-out;
cursor: default; cursor: default;
@ -176,7 +176,7 @@ body{
& > input[type='submit']{ & > input[type='submit']{
width: 100%; width: 100%;
margin: 2em 0; margin: 2em 0;
border: 0; border: 0;
background-color: $theme-fg-primary; background-color: $theme-fg-primary;
@ -233,4 +233,4 @@ body{
cursor: pointer; cursor: pointer;
} }
} }

View File

@ -1,5 +1,5 @@
<?php define('__ROOT__', dirname(__FILE__) ); <?php define('__ROOT__', dirname(__FILE__) );
require_once __ROOT__.'/manager/autoloader.php'; require_once __ROOT__.'/manager/autoloader.php';
use \router\Router; use \router\Router;
@ -44,7 +44,7 @@
$login = new ModuleRequest('user/login', array( 'login' => $_POST['login'], 'password' => $_POST['password'] )); $login = new ModuleRequest('user/login', array( 'login' => $_POST['login'], 'password' => $_POST['password'] ));
$login_ans = $login->dispatch(); $login_ans = $login->dispatch();
// Si aucune erreur, on dit qu'on vient de se connecter // Si aucune erreur, on dit qu'on vient de se connecter
if( $login_ans->error == ManagerError::Success ) if( $login_ans->error == ManagerError::Success )
$_SESSION['login_status'] = 'logged'; $_SESSION['login_status'] = 'logged';
else // Si on n'a pas les bonnes donnees else // Si on n'a pas les bonnes donnees
@ -55,7 +55,7 @@
/* (3) Gestion de le deconnexion */ /* (3) Gestion de le deconnexion */
$logout_vars = isset($_POST['logout-sub']); $logout_vars = isset($_POST['logout-sub']);
// Si on se deconnecte // Si on se deconnecte
if( $logout_vars ){ if( $logout_vars ){
$logout = new ModuleRequest('user/logout'); $logout = new ModuleRequest('user/logout');
$logout_ans = $logout->dispatch(); $logout_ans = $logout->dispatch();
@ -99,7 +99,7 @@
$R->post('api/?', function(){ $R->post('api/?', function(){
$request = ModuleRequest::fromPost($_POST); $request = ModuleRequest::fromPost($_POST);
$answer = $request->dispatch(); $answer = $request->dispatch();
echo $answer->serialize(); echo $answer->serialize();
}); });
@ -107,7 +107,7 @@
// N'importe -> page d'accueil // N'importe -> page d'accueil
$R->get('.+', function(){ header('Location: /dashboard/'); }); $R->get('.+', function(){ header('Location: /dashboard/'); });
$R->post('.+', function(){ header('Location: /dashboard/'); }); $R->post('.+', function(){ header('Location: /dashboard/'); });
@ -115,4 +115,4 @@
===================================================*/ ===================================================*/
$R->run(); $R->run();
?> ?>

View File

@ -5,25 +5,24 @@ APIClass.prototype = {
xhr: [], // tableau d'objets pour les requêtes ajax xhr: [], // tableau d'objets pour les requêtes ajax
/* transaction avec le serveur (http://host/api/) /* transaction avec le serveur (http://host/api/)
* *
* @param pRequest<Object> l'objet passé en JSON à http://host/api/ * @param pRequest<Object> l'objet passé en JSON à http://host/api/
* @param pHandler<Function> fonction qui s'éxécutera lors de la réponse (1 argument -> réponse<Object>) * @param pHandler<Function> fonction qui s'éxécutera lors de la réponse (1 argument -> réponse<Object>)
* @param pToken<String> si donne, token d'auth pour l'api * @param pToken<String> si donne, token d'auth pour l'api
* *
* @return answer<Object> l'objet retourné par http://host/api/ via pHandler (1er argument) * @return answer<Object> l'objet retourné par http://host/api/ via pHandler (1er argument)
* *
*************************************************************************************************** ***************************************************************************************************
* *
* @usecase * @usecase
* 1. var answerObject = sendRequest( * 1. var answerObject = sendRequest(
* 2. { var1: "exemple", var2: 198294 }, * 2. { var1: "exemple", var2: 198294 },
* 3. function(rep){ alert(rep); } * 3. function(rep){ alert(rep); }
* 4. ); * 4. );
* @explain * @explain
* 1. on appelle la fonction <=> on créé la requête * 1. on appelle la fonction <=> on créé la requête
* 2. on passe l'objet qui sera envoyé * 2. on passe l'objet qui sera envoyé
* 3. on passe une fonction qui utilise un argument (sera la réponse de http://host/api/) (sous forme d'objet) * 3. on passe une fonction qui utilise un argument (sera la réponse de http://host/api/) (sous forme d'objet)
* *
*/ */
@ -46,7 +45,7 @@ APIClass.prototype = {
// création de l'objet AJAX // création de l'objet AJAX
if(window.XMLHttpRequest) // IE7+, Firefox, Chrome, Opera, Safari if(window.XMLHttpRequest) // IE7+, Firefox, Chrome, Opera, Safari
this.xhr[i] = new XMLHttpRequest(); this.xhr[i] = new XMLHttpRequest();
else // IE5, IE6 else // IE5, IE6
this.xhr[i] = new ActiveXObject('Microsoft.XMLHttpRequest'); this.xhr[i] = new ActiveXObject('Microsoft.XMLHttpRequest');
console.log(pRequest); console.log(pRequest);
@ -85,7 +84,7 @@ APIClass.prototype = {
// Gestion du token optionnel // Gestion du token optionnel
if( pToken != null ) this.xhr[i].setRequestHeader('Authorization', 'Digest '+pToken); if( pToken != null ) this.xhr[i].setRequestHeader('Authorization', 'Digest '+pToken);
this.xhr[i].send( form ); this.xhr[i].send( form );

View File

@ -499,8 +499,8 @@
<tr class="warning"><td><div align="right"><a name="247"></a><a href="#247">247</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">break</span><span class="keyword">;</span></td></tr> <tr class="warning"><td><div align="right"><a name="247"></a><a href="#247">247</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">break</span><span class="keyword">;</span></td></tr>
<tr><td><div align="right"><a name="248"></a><a href="#248">248</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr> <tr><td><div align="right"><a name="248"></a><a href="#248">248</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>
<tr class="covered-by-large-tests popin" data-title="1 test covers line 249" data-content="&lt;ul&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_check::testArrayRecursive&lt;/li&gt;&lt;/ul&gt;" data-placement="bottom" data-html="true"><td><div align="right"><a name="249"></a><a href="#249">249</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">default</span><span class="keyword">:</span></td></tr> <tr class="covered-by-large-tests popin" data-title="1 test covers line 249" data-content="&lt;ul&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_check::testArrayRecursive&lt;/li&gt;&lt;/ul&gt;" data-placement="bottom" data-html="true"><td><div align="right"><a name="249"></a><a href="#249">249</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">default</span><span class="keyword">:</span></td></tr>
<tr class="covered-by-large-tests popin" data-title="1 test covers line 250" data-content="&lt;ul&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_check::testArrayRecursive&lt;/li&gt;&lt;/ul&gt;" data-placement="bottom" data-html="true"><td><div align="right"><a name="250"></a><a href="#250">250</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</span><span class="default">false</span><span class="keyword">;</span></td></tr> <tr class="covered-by-large-tests popin" data-title="1 test covers line 250" data-content="&lt;ul&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_check::testArrayRecursive&lt;/li&gt;&lt;/ul&gt;" data-placement="bottom" data-html="true"><td><div align="right"><a name="250"></a><a href="#250">250</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</span><span class="default">false</span><span class="keyword">;</span></td></tr>
<tr><td><div align="right"><a name="251"></a><a href="#251">251</a></div></td><td class="codeLine"></td></tr> <tr class="warning"><td><div align="right"><a name="251"></a><a href="#251">251</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">break</span><span class="keyword">;</span></td></tr>
<tr class="covered-by-large-tests popin" data-title="1 test covers line 252" data-content="&lt;ul&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_check::testArrayRecursive&lt;/li&gt;&lt;/ul&gt;" data-placement="bottom" data-html="true"><td><div align="right"><a name="252"></a><a href="#252">252</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span></td></tr> <tr class="covered-by-large-tests popin" data-title="1 test covers line 252" data-content="&lt;ul&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_check::testArrayRecursive&lt;/li&gt;&lt;/ul&gt;" data-placement="bottom" data-html="true"><td><div align="right"><a name="252"></a><a href="#252">252</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span></td></tr>
<tr><td><div align="right"><a name="253"></a><a href="#253">253</a></div></td><td class="codeLine"></td></tr> <tr><td><div align="right"><a name="253"></a><a href="#253">253</a></div></td><td class="codeLine"></td></tr>
<tr class="warning"><td><div align="right"><a name="254"></a><a href="#254">254</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</span><span class="default">$checker</span><span class="keyword">;</span></td></tr> <tr class="warning"><td><div align="right"><a name="254"></a><a href="#254">254</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</span><span class="default">$checker</span><span class="keyword">;</span></td></tr>
@ -559,7 +559,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 2.1.7</a> using <a href="http://php.net/" target="_top">PHP 5.6.11-1ubuntu3.1</a> and <a href="http://phpunit.de/">PHPUnit 4.7.6</a> at Sun Apr 17 15:49:45 UTC 2016.</small> <small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 2.1.7</a> using <a href="http://php.net/" target="_top">PHP 5.6.11-1ubuntu3.1</a> and <a href="http://phpunit.de/">PHPUnit 4.7.6</a> at Mon Apr 18 6:41:06 UTC 2016.</small>
</p> </p>
<a title="Back to the top" id="toplink" href="#"><span class="glyphicon glyphicon-arrow-up"></span></a> <a title="Back to the top" id="toplink" href="#"><span class="glyphicon glyphicon-arrow-up"></span></a>
</footer> </footer>

View File

@ -247,7 +247,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 2.1.7</a> using <a href="http://php.net/" target="_top">PHP 5.6.11-1ubuntu3.1</a> and <a href="http://phpunit.de/">PHPUnit 4.7.6</a> at Sun Apr 17 15:49:45 UTC 2016.</small> <small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 2.1.7</a> using <a href="http://php.net/" target="_top">PHP 5.6.11-1ubuntu3.1</a> and <a href="http://phpunit.de/">PHPUnit 4.7.6</a> at Mon Apr 18 6:41:06 UTC 2016.</small>
</p> </p>
<a title="Back to the top" id="toplink" href="#"><span class="glyphicon glyphicon-arrow-up"></span></a> <a title="Back to the top" id="toplink" href="#"><span class="glyphicon glyphicon-arrow-up"></span></a>
</footer> </footer>

View File

@ -517,7 +517,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 2.1.7</a> using <a href="http://php.net/" target="_top">PHP 5.6.11-1ubuntu3.1</a> and <a href="http://phpunit.de/">PHPUnit 4.7.6</a> at Sun Apr 17 15:49:45 UTC 2016.</small> <small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 2.1.7</a> using <a href="http://php.net/" target="_top">PHP 5.6.11-1ubuntu3.1</a> and <a href="http://phpunit.de/">PHPUnit 4.7.6</a> at Mon Apr 18 6:41:06 UTC 2016.</small>
</p> </p>
<a title="Back to the top" id="toplink" href="#"><span class="glyphicon glyphicon-arrow-up"></span></a> <a title="Back to the top" id="toplink" href="#"><span class="glyphicon glyphicon-arrow-up"></span></a>
</footer> </footer>

View File

@ -214,7 +214,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 2.1.7</a> using <a href="http://php.net/" target="_top">PHP 5.6.11-1ubuntu3.1</a> and <a href="http://phpunit.de/">PHPUnit 4.7.6</a> at Sun Apr 17 15:49:45 UTC 2016.</small> <small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 2.1.7</a> using <a href="http://php.net/" target="_top">PHP 5.6.11-1ubuntu3.1</a> and <a href="http://phpunit.de/">PHPUnit 4.7.6</a> at Mon Apr 18 6:41:06 UTC 2016.</small>
</p> </p>
<a title="Back to the top" id="toplink" href="#"><span class="glyphicon glyphicon-arrow-up"></span></a> <a title="Back to the top" id="toplink" href="#"><span class="glyphicon glyphicon-arrow-up"></span></a>
</footer> </footer>

View File

@ -210,7 +210,7 @@
<span class="success"><strong>High</strong>: 90% to 100%</span> <span class="success"><strong>High</strong>: 90% to 100%</span>
</p> </p>
<p> <p>
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 2.1.7</a> using <a href="http://php.net/" target="_top">PHP 5.6.11-1ubuntu3.1</a> and <a href="http://phpunit.de/">PHPUnit 4.7.6</a> at Sun Apr 17 15:49:45 UTC 2016.</small> <small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 2.1.7</a> using <a href="http://php.net/" target="_top">PHP 5.6.11-1ubuntu3.1</a> and <a href="http://phpunit.de/">PHPUnit 4.7.6</a> at Mon Apr 18 6:41:06 UTC 2016.</small>
</p> </p>
</footer> </footer>
</div> </div>

View File

@ -315,7 +315,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 2.1.7</a> using <a href="http://php.net/" target="_top">PHP 5.6.11-1ubuntu3.1</a> and <a href="http://phpunit.de/">PHPUnit 4.7.6</a> at Sun Apr 17 15:49:45 UTC 2016.</small> <small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 2.1.7</a> using <a href="http://php.net/" target="_top">PHP 5.6.11-1ubuntu3.1</a> and <a href="http://phpunit.de/">PHPUnit 4.7.6</a> at Mon Apr 18 6:41:06 UTC 2016.</small>
</p> </p>
<a title="Back to the top" id="toplink" href="#"><span class="glyphicon glyphicon-arrow-up"></span></a> <a title="Back to the top" id="toplink" href="#"><span class="glyphicon glyphicon-arrow-up"></span></a>
</footer> </footer>

View File

@ -23,16 +23,16 @@
/* (1) Lecture du fichier */ /* (1) Lecture du fichier */
$file_content = file_get_contents( self::$config['database-local'] ); $file_content = file_get_contents( self::$config['database-local'] );
$this->assertNotFalse( $file_content ); $this->assertNotFalse( $file_content );
/* (2) Parsage en JSON */ /* (2) Parsage en JSON */
$json_content = json_decode( $file_content, true ); $json_content = json_decode( $file_content, true );
$this->assertNotNull( $json_content ); $this->assertNotNull( $json_content );
/* (3) Contenu */ /* (3) Contenu */
$this->assertArrayHasKey('host', $json_content); $this->assertArrayHasKey('host',$json_content);
$this->assertArrayHasKey('dbname', $json_content); $this->assertArrayHasKey('dbname',$json_content);
$this->assertArrayHasKey('user', $json_content); $this->assertArrayHasKey('user',$json_content);
$this->assertArrayHasKey('password', $json_content); $this->assertArrayHasKey('password',$json_content);
} }
@ -43,7 +43,7 @@
/* (1) Lecture du fichier */ /* (1) Lecture du fichier */
$file_content = file_get_contents( self::$config['database'] ); $file_content = file_get_contents( self::$config['database'] );
$this->assertNotFalse( $file_content ); $this->assertNotFalse( $file_content );
/* (2) Parsage en JSON */ /* (2) Parsage en JSON */
$json_content = json_decode( $file_content, true ); $json_content = json_decode( $file_content, true );
$this->assertNotNull( $json_content ); $this->assertNotNull( $json_content );
@ -63,7 +63,7 @@
/* (1) Lecture du fichier */ /* (1) Lecture du fichier */
$file_content = file_get_contents( self::$config['dispatcher-extensions'] ); $file_content = file_get_contents( self::$config['dispatcher-extensions'] );
$this->assertNotFalse( $file_content ); $this->assertNotFalse( $file_content );
/* (2) Parsage en JSON */ /* (2) Parsage en JSON */
$json_content = json_decode( $file_content, true ); $json_content = json_decode( $file_content, true );
$this->assertNotNull( $json_content ); $this->assertNotNull( $json_content );
@ -81,14 +81,13 @@
} }
/* [3] config/dispatcher-tree.json /* [3] config/dispatcher-tree.json
=========================================================*/ =========================================================*/
public function testDispatcherTree(){ public function testDispatcherTree(){
/* (1) Lecture du fichier */ /* (1) Lecture du fichier */
$file_content = file_get_contents( self::$config['dispatcher-tree'] ); $file_content = file_get_contents( self::$config['dispatcher-tree'] );
$this->assertNotFalse( $file_content ); $this->assertNotFalse( $file_content );
/* (2) Parsage en JSON */ /* (2) Parsage en JSON */
$json_content = json_decode( $file_content, true ); $json_content = json_decode( $file_content, true );
$this->assertNotNull( $json_content ); $this->assertNotNull( $json_content );
@ -106,28 +105,128 @@
} }
/* [3] config/menu.json /* [3] config/menu.json
=========================================================*/ =========================================================*/
public function testMenu(){ public function testMenu(){
/* (1) Lecture du fichier */ /* (1) Lecture du fichier */
$file_content = file_get_contents( self::$config['menu'] ); $file_content = file_get_contents( self::$config['menu'] );
$this->assertNotFalse( $file_content ); $this->assertNotFalse( $file_content );
/* (2) Parsage en JSON */ /* (2) Parsage en JSON */
$json_content = json_decode( $file_content, true ); $json_content = json_decode( $file_content, true );
$this->assertNotNull( $json_content ); $this->assertNotNull( $json_content );
/* (3) Contenu de chaque catégorie */
/* (3) Contenu */
foreach($json_content as $category){ foreach($json_content as $category){
continue; $this->assertArrayHasKey( 'icon', $category );
$this->assertTrue( is_string($category['icon']) );
$this->assertArrayHasKey( 'text', $category );
$this->assertTrue( is_string($category['text']) );
$this->assertArrayHasKey( 'attributes', $category );
$this->assertTrue( is_array($category['attributes']) );
$this->assertArrayHasKey( 'children', $category );
$this->assertTrue( is_array($category['children']) );
/* (4) Contenu de chaque sous-catégorie */
foreach($category['children'] as $children){
$this->assertArrayHasKey( 'permissions', $children );
$this->assertTrue( is_array($children['permissions']) );
$this->assertArrayHasKey( 'text', $children );
$this->assertTrue( is_string($children['text']) );
$this->assertArrayHasKey( 'attributes', $children );
$this->assertTrue( is_array($children['attributes']) );
}
}
}
/* [4] config/modules.json
=========================================================*/
public function testModules(){
/* (1) Lecture du fichier */
$file_content = file_get_contents( self::$config['modules'] );
$this->assertNotFalse( $file_content );
/* (2) Parsage en JSON */
$json_content = json_decode( $file_content, true );
$this->assertNotNull( $json_content );
/* (3) Contenu de chaque module */
foreach($json_content as $moduleName=>$methods){
$this->assertTrue( is_string($moduleName) );
/* (4) Liste des méthodes du module */
foreach($methods as $methodName=>$method){
$this->assertTrue( is_string($methodName) );
$this->assertArrayHasKey( 'description', $method );
$this->assertTrue( is_string($method['description']) );
$this->assertArrayHasKey( 'permissions', $method );
$this->assertTrue( is_array($method['permissions']) );
$this->assertArrayHasKey( 'parameters', $method );
$this->assertTrue( is_array($method['parameters']) );
/* (5) Pour chaque paramètre */
foreach($method['parameters'] as $parameterName=>$parameter){
$this->assertTrue( is_string($parameterName) );
$this->assertArrayHasKey( 'description', $parameter );
$this->assertTrue( is_string($parameter['description']) );
$typeIsDefined = isset($parameter['type']);
if( $typeIsDefined )
$this->assertTrue( is_string($parameter['type']) );
}
}
} }
} }
/* [5] config/repositories.json
=========================================================*/
public function testRepositories(){
/* (1) Lecture du fichier */
$file_content = file_get_contents( self::$config['repositories'] );
$this->assertNotFalse( $file_content );
/* (2) Parsage en JSON */
$json_content = json_decode( $file_content, true );
$this->assertNotNull( $json_content );
/* (3) Contenu de chaque repository */
foreach($json_content as $repoName=>$methods){
$this->assertTrue( is_string($repoName) );
/* (4) Liste des méthodes du repository */
foreach($methods as $methodName)
$this->assertTrue( is_string($methodName) );
}
}
/* [6] config/views.json
=========================================================*/
public function testViews(){
/* (1) Lecture du fichier */
$file_content = file_get_contents( self::$config['views'] );
$this->assertNotFalse( $file_content );
/* (2) Parsage en JSON */
$json_content = json_decode( $file_content, true );
$this->assertNotNull( $json_content );
/* (3) Contenu de chaque repository */
foreach($json_content as $viewName)
$this->assertTrue( is_string($viewName) );
}
} }
?> ?>

View File

@ -1,4 +1,4 @@
<?php define('__ROOT__', dirname(__FILE__) ); <?php define('__ROOT__', dirname(__FILE__) );
?>
?>

View File

@ -35,17 +35,17 @@
<!-- <script type='text/javascript' src='/f/js/sigma-plugins-animate-min/sigma/plugins' ></script> for animations --> <!-- <script type='text/javascript' src='/f/js/sigma-plugins-animate-min/sigma/plugins' ></script> for animations -->
</head> </head>
<body> <body>
<!-- LOGIN --> <!-- LOGIN -->
<?php if( connected() ) echo "<div id='LOGIN'>"; <?php if( connected() ) echo "<div id='LOGIN'>";
else echo "<div id='LOGIN' class='active'>"; ?> else echo "<div id='LOGIN' class='active'>"; ?>
<?php //var_dump(session_id()); ?> <?php //var_dump(session_id()); ?>
<div id='login-icon'></div> <div id='login-icon'></div>
<div id='login-close'>Accéder à la plateforme</div> <div id='login-close'>Accéder à la plateforme</div>
<form method='POST' action='' id='login-form'> <form method='POST' action='' id='login-form'>
<!-- SI ON EST PAS CONNECTE -> FORMULAIRE DE LOGIN --> <!-- SI ON EST PAS CONNECTE -> FORMULAIRE DE LOGIN -->
<?php if( !connected() ){ ?> <?php if( !connected() ){ ?>
<input type='text' placeholder='Identifiant ou adresse mail' name='login' id='login-login'> <input type='text' placeholder='Identifiant ou adresse mail' name='login' id='login-login'>
@ -58,7 +58,7 @@
<?php }else{ ?> <?php }else{ ?>
<input type='submit' value='Déconnexion' name='logout-sub'> <input type='submit' value='Déconnexion' name='logout-sub'>
<?php } ?> <?php } ?>
</form> </form>
</div> </div>
@ -66,7 +66,7 @@
<!-- CORPS DE LA PAGE --> <!-- CORPS DE LA PAGE -->
<div id='WRAPPER'> <div id='WRAPPER'>
<!-- HEADER DE LA PAGE --> <!-- HEADER DE LA PAGE -->
<div id='HEADER'> <div id='HEADER'>
@ -83,7 +83,7 @@
echo "<span id='user-picture'></span>"; echo "<span id='user-picture'></span>";
}?> }?>
</div> </div>
</div> </div>
@ -93,7 +93,7 @@
<?php <?php
$menuInflater = new MenuManager(); $menuInflater = new MenuManager();
echo $menuInflater->inflate(); echo $menuInflater->inflate();
?> ?>
</nav> </nav>
@ -101,11 +101,11 @@
<div id='CONTAINER'></div> <div id='CONTAINER'></div>
</div> </div>
<!-- Dépendences Javascript après chargement des éléments --> <!-- Dépendences Javascript après chargement des éléments -->
<script type='text/javascript' src='/f/js/action-script/js'></script> <script type='text/javascript' src='/f/js/action-script/js'></script>
</body> </body>
</html> </html>