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

@ -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();

View File

@ -5,7 +5,6 @@ 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/

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

@ -29,10 +29,10 @@
$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);
} }
@ -81,7 +81,6 @@
} }
/* [3] config/dispatcher-tree.json /* [3] config/dispatcher-tree.json
=========================================================*/ =========================================================*/
public function testDispatcherTree(){ public function testDispatcherTree(){
@ -106,7 +105,6 @@
} }
/* [3] config/menu.json /* [3] config/menu.json
=========================================================*/ =========================================================*/
public function testMenu(){ public function testMenu(){
@ -118,14 +116,115 @@
$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) );
}
} }