Subversion Repositories eFlore/Projets.eflore-projets

Compare Revisions

Ignore whitespace Rev 946 → Rev 947

/trunk/services/tests/0.1/ServiceEflorePhpUnit.php
14,6 → 14,7
* @license http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
* @version $Id$
*/
 
abstract class ServiceEflorePhpUnit extends PHPUnit_Framework_TestCase {
 
/** Définir la valeur de cet attribut dans le constructeur de la classe de test.*/
49,20 → 50,22
}
 
private static function chargerFramework() {
$cheminRacine = realpath(dirname(__FILE__).'/../..').'/';
$framework = $cheminRacine.'framework.php';
if (!file_exists($framework)) {
$e = "Veuillez paramétrer l'emplacement et la version du Framework dans le fichier $framework";
trigger_error($e, E_USER_ERROR);
} else {
// Inclusion du Framework
require_once $framework;
static $cheminRacine;
if(!$cheminRacine) {
$cheminRacine = realpath(dirname(__FILE__).'/../..').'/';
$framework = $cheminRacine.'framework.php';
if (!file_exists($framework)) {
$e = "Veuillez paramétrer l'emplacement et la version du Framework dans le fichier $framework";
trigger_error($e, E_USER_ERROR);
} else {
// Inclusion du Framework
require_once $framework;
// Ajout d'information concernant cette application
Framework::setCheminAppli($cheminRacine);// Obligatoire
}
}
}
 
// Ajout d'information concernant cette application
Framework::setCheminAppli($cheminRacine);// Obligatoire
}
}
 
//+------------------------------------------------------------------------------------------------------+
// Refactorisation
public function consulterJson($service, $projet, $ressources, $parametres = NULL) {
/trunk/services/tests/0.1/baseflor/InformationsBaseflorTest.php
98,7 → 98,7
$ressources = array();
$parametresList = array(
array('navigation.depart' => -5, 'navigation.limite' => 10 ),
array('navigation.depart' => 0, 'navigation.limite' => abc ));
array('navigation.depart' => 0, 'navigation.limite' => 'abc' ));
$cles = array('navigation.depart','navigation.limite');
$i = 0 ;
foreach ($parametresList as $parametres) {
132,7 → 132,7
$retour = ServiceEflorePhpUnit::consulterBrut($this->service, $this->projet, $ressources, $parametres);
$messageAttendu = "Erreur : La version est inconnue.";
$this->assertEquals($messageAttendu, $retour,
"Il faut indiquer si la valeur du paramètre version.projet est inconnue.");
"Il faut indiquer si la valeur du paramètre version.projet est inconnue.");
}
}
147,10 → 147,10
$retour = $this->consulterJson($this->service, $this->projet, $ressources, $parametres);
$this->assertArrayHasKey('entete', $retour, "Le json ne contient pas d'attribut : entete. Voir : $url");
$this->assertArrayHasKey('resultats', $retour, "Le json ne contient pas d'attribut : resultat. Voir : $url");
$this->verifierJsonEnteteBienFormeInformations($retour, $parametres);
$this->verifierJsonEnteteBienFormeInformations($retour, $ressources, $parametres);
}
private function verifierJsonEnteteBienFormeInformations($retour, $parametres) {
private function verifierJsonEnteteBienFormeInformations($retour, $ressources, $parametres) {
//depart
$this->assertArrayHasKey('depart', $retour['entete'],
"L'en-tête ne contient pas d'attribut : depart ");
194,6 → 194,7
public function testJsonNombreLimiteDemande() {
$ressources = array();
$parametres = array();
$parametresList = array('navigation.depart' => 10, 'navigation.limite' => 15 );
$url = ServiceEflorePhpUnit::creerUrl($this->service, $ressources, $parametres);
$retour = $this->consulterJson($this->service, $this->projet, $ressources, $parametres);
245,18 → 246,11
public function testJsonInformationsNNBasefor_max() {
$ressources = array('bdtfx.nn:73256');
$parametresList = array(
array('retour.format' => 'max', 'categorie' => 'description'),
array('retour.format' => 'max' , 'categorie' => 'ecologie'));
foreach ($parametresList as $parametres) {
$retour = $this->consulterJson($this->service, $this->projet, $ressources, $parametres);
if ($parametres['categorie'] == 'description') {
$this->verifierParametresDescription_max($retour);
} else {
$this->verifierParametresEcologie_max($retour, 'baseflor');
}
}
$retour = $this->consulterJson($this->service, $this->projet, ['bdtfx.nn:73256'], ['retour.format' => 'max', 'categorie' => 'description']);
$this->verifierParametresDescription_max($retour);
 
$retour = $this->consulterJson($this->service, $this->projet, ['bdtfx.nn:73256'], ['retour.format' => 'max', 'categorie' => 'ecologie']);
$this->verifierParametresEcologie_max($retour, 'baseflor');
}
public function testJsonInformationsNNRangSup_max() {
272,11 → 266,11
 
private function verifierParametresDescription_max($retour) {
$this->assertArrayHasKey('type_bio.code',$retour,
"Le champs 'type_bio.code' doit être présent si retour.format=max. ");
"Le champs 'type_bio.code' doit être présent si retour.format=max. ");
$this->assertArrayHasKey('type_bio.libelle',$retour,
"Le champs 'type_bio.libelle' doit être présent si retour.format=max.");
"Le champs 'type_bio.libelle' doit être présent si retour.format=max.");
$this->assertArrayHasKey('type_bio.detail',$retour,
"Le champs 'type_bio.detail' doit être présent si retour.format=max.");
"Le champs 'type_bio.detail' doit être présent si retour.format=max.");
}
private function verifierParametresEcologie_max($retour,$type) {
284,31 → 278,31
if ($type == 'baseflor') {
foreach ($champs as $chps) {
$this->assertArrayHasKey($chps.'.libelle', $retour,
"Le champs '{$chps}.libelle' doit être présent si retour.format=max.");
"Le champs '{$chps}.libelle' doit être présent si retour.format=max.");
$this->assertArrayHasKey($chps.'.code', $retour,
"Le champs '{$chps}.code' doit être présent si retour.format=max.");
"Le champs '{$chps}.code' doit être présent si retour.format=max.");
$this->assertArrayHasKey($chps.'.href', $retour,
"Le champs '{$chps}.href' doit être présent si retour.format=max.");
"Le champs '{$chps}.href' doit être présent si retour.format=max.");
}
} elseif ($type == 'rangSup') {
foreach ($champs as $chps) {
$this->assertArrayHasKey($chps.'_min.libelle', $retour,
"Le champs '{$chps}_min.libelle' doit être présent si retour.format=max.");
"Le champs '{$chps}_min.libelle' doit être présent si retour.format=max.");
$this->assertArrayHasKey($chps.'_min.code', $retour,
"Le champs '{$chps}_min.code' doit être présent si retour.format=max.");
"Le champs '{$chps}_min.code' doit être présent si retour.format=max.");
$this->assertArrayHasKey($chps.'_min.href', $retour,
"Le champs '{$chps}_min.href' doit être présent si retour.format=max.");
"Le champs '{$chps}_min.href' doit être présent si retour.format=max.");
$this->assertArrayHasKey($chps.'_max.libelle', $retour,
"Le champs '{$chps}_max.libelle' doit être présent si retour.format=max.");
"Le champs '{$chps}_max.libelle' doit être présent si retour.format=max.");
$this->assertArrayHasKey($chps.'_max.code', $retour,
"Le champs '{$chps}_max.code' doit être présent si retour.format=max.");
"Le champs '{$chps}_max.code' doit être présent si retour.format=max.");
$this->assertArrayHasKey($chps.'_max.href', $retour,
"Le champs '{$chps}_max.href' doit être présent si retour.format=max.");
"Le champs '{$chps}_max.href' doit être présent si retour.format=max.");
}
}
}
//++ ------------------------------------Test du champs type biologique -----------------------------++
//++ ------------------------------------Test du champs type biologique -----------------------------++
//TEST sur différents cas typique de 'type_bio.libelle'
public function testJsonTypeBioOntologies() {
316,15 → 310,15
array("bdtfx.nn:6446"),array("bdtfx.nn:8373"), array("bdafx.nn:35574"), array("bdtfx.nn:62443"),
array("bdtfx.nn:62442"));
$parametres = array();
$resultats_attendus = array ('Grhi-aqua' => 'Géophytes (>= 1m) à rhizome (plantes aquatiques) ' ,
'test-aqua-car' => 'Thérophytes (< 1m) estivaux (plantes aquatiques, carnivores) ',
$resultats_attendus = array ('Grhi-aqua' => 'Géophytes (>= 1m) à rhizome (plantes aquatiques) ' ,
'test-aqua-car' => 'Thérophytes (< 1m) estivaux (plantes aquatiques, carnivores) ',
'grhi' => 'Géophytes (< 1m) à rhizome ',
'hsto(test)' => 'Hémicryptophytes (< 1m) stolonifères , Thérophytes (< 1m) estivaux ',
'Hsto-lia(Grhi-lia)' => 'Hémicryptophytes (>= 1m) stolonifères (lianes) , Géophytes (>= 1m) à rhizome (lianes) ',
'Hsto-lia(Grhi-lia)' => 'Hémicryptophytes (>= 1m) stolonifères (lianes) , Géophytes (>= 1m) à rhizome (lianes) ',
'Cfru(b-cad)' => 'Chaméphytes (>= 1m) frutescents , Nanophanérophytes (2 à 4m) (caducifoliées) ',
'test-aqua(heri)' => 'Thérophytes (< 1m) estivaux (plantes aquatiques) , Hémicryptophytes (< 1m) érigé ',
'hbis(hsto,test)-suc' => 'Hémicryptophytes (< 1m) bisannuels (succulentes) , Hémicryptophytes (< 1m) stolonifères, Thérophytes (< 1m) estivaux ',
'hbis(hsto)-suc' => 'Hémicryptophytes (< 1m) bisannuels (succulentes) , Hémicryptophytes (< 1m) stolonifères ');
'test-aqua(heri)' => 'Thérophytes (< 1m) estivaux (plantes aquatiques) , Hémicryptophytes (< 1m) érigé ',
'hbis(hsto,test)-suc' => 'Hémicryptophytes (< 1m) bisannuels (succulentes) , Hémicryptophytes (< 1m) stolonifères, Thérophytes (< 1m) estivaux ',
'hbis(hsto)-suc' => 'Hémicryptophytes (< 1m) bisannuels (succulentes) , Hémicryptophytes (< 1m) stolonifères ');
foreach ($ressourcesList as $ressources) {
$retour = $this->consulterJson($this->service, $this->projet, $ressources, $parametres);
$code = $retour['type_bio.code'];
335,6 → 329,7
 
public function testRelationsCatminat() {
$ressources = array('bdtfx.nn:5641', 'relations', 'catminat');
$parametres = array();
$retour = $this->consulterJson($this->service, $this->projet, $ressources, $parametres);
 
// valeurs standards
/trunk/services/tests/0.1/nvjfl/NvjflNomsVernaTest.php
26,7 → 26,7
 
$retour = ServiceEflorePhpUnit::consulterBrut($this->service, $this->projet, $ressources, $parametres);
 
$attendu = 'La requête SQL formée comporte une erreur!';
$attendu = "La table recherchée n'existe pas";
$message = "L'url :\n'$url'\n doit retourner un résultat de la forme :\n $attendu";
$this->assertEquals($attendu, $retour, $message);
}