| 520 | mathilde | 1 | <?php
 | 
        
           |  |  | 2 |   | 
        
           |  |  | 3 | require_once dirname(__FILE__).'/../ServiceEflorePhpUnit.php';
 | 
        
           |  |  | 4 |   | 
        
           | 594 | mathilde | 5 | /* TO DO = ajouter un test pour Informations/id/Relations/catminat */
 | 
        
           |  |  | 6 |   | 
        
           | 520 | mathilde | 7 | class InformationsBaseflorTest extends ServiceEflorePhpUnit {
 | 
        
           |  |  | 8 |   | 
        
           |  |  | 9 | 	public function __construct() {
 | 
        
           |  |  | 10 | 		$this->projet = 'baseflor';
 | 
        
           |  |  | 11 | 		$this->service = 'informations';
 | 
        
           |  |  | 12 | 	}
 | 
        
           |  |  | 13 |   | 
        
           |  |  | 14 |   | 
        
           |  |  | 15 | 	//++ ------------------------------------Test des ressources -----------------------------++
 | 
        
           |  |  | 16 |   | 
        
           |  |  | 17 | 	public function testRessourceReferentielInconnu() {
 | 
        
           |  |  | 18 | 		$ressources = array('dgoju.nn:73256');
 | 
        
           |  |  | 19 | 		$parametres = array();
 | 
        
           | 790 | raphael | 20 | 		$retour = ServiceEflorePhpUnit::consulterBrut($this->service, $this->projet, $ressources, $parametres);
 | 
        
           | 520 | mathilde | 21 | 		$messageAttendu =
 | 
        
           |  |  | 22 | 			  "Erreur dans l'url de votre requête :".
 | 
        
           | 783 | raphael | 23 | 				" </br> Le référentiel \" dgoju \" n'existe pas.";
 | 
        
           | 520 | mathilde | 24 | 		$this->assertEquals($messageAttendu, $retour,
 | 
        
           |  |  | 25 | 						"Il faut indiquer un référentiel inconnu.");
 | 
        
           |  |  | 26 | 	}
 | 
        
           |  |  | 27 |   | 
        
           |  |  | 28 | 	public function testRessourceInconnue() {
 | 
        
           |  |  | 29 | 		$ressources = array('inconnue');
 | 
        
           |  |  | 30 | 		$parametres = array();
 | 
        
           | 790 | raphael | 31 | 		$retour = ServiceEflorePhpUnit::consulterBrut($this->service, $this->projet, $ressources, $parametres);
 | 
        
           | 520 | mathilde | 32 | 		$messageAttendu =
 | 
        
           |  |  | 33 | 				  "Erreur dans l'url de votre requête : </br> La ressource demandée n'existe pas.";
 | 
        
           |  |  | 34 | 		$this->assertEquals($messageAttendu, $retour,
 | 
        
           |  |  | 35 | 							"Il faut indiquer si une ressource est eronnée.");
 | 
        
           |  |  | 36 | 	}
 | 
        
           |  |  | 37 |   | 
        
           |  |  | 38 | 	public function testRessourceNNInconnu() {
 | 
        
           |  |  | 39 | 		$ressources = array('bdtfx.nn:3');
 | 
        
           |  |  | 40 | 		$parametres = array();
 | 
        
           | 790 | raphael | 41 | 		$retour = ServiceEflorePhpUnit::consulterBrut($this->service, $this->projet, $ressources, $parametres);
 | 
        
           | 520 | mathilde | 42 | 		$messageAttendu = "Les données recherchées sont introuvables.";
 | 
        
           |  |  | 43 | 		$this->assertEquals($messageAttendu, $retour,
 | 
        
           |  |  | 44 | 			"Il faut indiquer si une requête ne renvoie pas de résultats.");
 | 
        
           |  |  | 45 | 	}
 | 
        
           |  |  | 46 |   | 
        
           |  |  | 47 | 	//++ ------------------------------------Test des paramètres -----------------------------++
 | 
        
           |  |  | 48 |   | 
        
           |  |  | 49 | 	public function testParametreInconnu() {
 | 
        
           |  |  | 50 | 		$ressourcesList = array(
 | 
        
           |  |  | 51 | 			array('bdtfx.nn:73256'),
 | 
        
           |  |  | 52 | 			array('bdtfx.nn:101128'));
 | 
        
           |  |  | 53 | 		$parametres = array('paramatre' => 'image/jpeg');
 | 
        
           |  |  | 54 | 		foreach ($ressourcesList as $ressources) {
 | 
        
           | 790 | raphael | 55 | 			$retour = ServiceEflorePhpUnit::consulterBrut($this->service, $this->projet, $ressources, $parametres);
 | 
        
           | 520 | mathilde | 56 | 			$messageAttendu = "Erreur dans les parametres de votre requête :".
 | 
        
           |  |  | 57 | 										" </br> Le paramètre \" paramatre \" n'existe pas.";
 | 
        
           |  |  | 58 | 			$this->assertEquals($messageAttendu, $retour,
 | 
        
           | 783 | raphael | 59 | 				"Il faut indiquer si un paramètre est inconnu.");
 | 
        
           | 520 | mathilde | 60 | 		}
 | 
        
           |  |  | 61 |   | 
        
           |  |  | 62 | 	}
 | 
        
           |  |  | 63 |   | 
        
           |  |  | 64 | 	public function testParametreCategorieInconnue() {
 | 
        
           |  |  | 65 | 		$ressourcesList = array(
 | 
        
           |  |  | 66 | 			array('bdtfx.nn:73256'),
 | 
        
           |  |  | 67 | 			array('bdtfx.nn:101128'));
 | 
        
           |  |  | 68 | 		$parametres = array('categorie' => 'inventé');
 | 
        
           |  |  | 69 | 		foreach ($ressourcesList as $ressources) {
 | 
        
           | 790 | raphael | 70 | 			$retour = ServiceEflorePhpUnit::consulterBrut($this->service, $this->projet, $ressources, $parametres);
 | 
        
           | 788 | raphael | 71 | 			$messageAttendu = "Valeur de paramètre inconnue pour 'categorie'. Ce paramètre n'est pas autorisé";
 | 
        
           |  |  | 72 | 			$this->assertContains($messageAttendu, $retour,
 | 
        
           |  |  | 73 | 								"Il faut indiquer si la valeur du paramètre categorie est inconnue pour (" . implode(',', $ressources) . ").");
 | 
        
           | 520 | mathilde | 74 | 		}
 | 
        
           |  |  | 75 | 	}
 | 
        
           |  |  | 76 |   | 
        
           | 594 | mathilde | 77 | 	public function testParametreNavigationDepartSansLimite() {
 | 
        
           | 520 | mathilde | 78 | 		$ressources = array();
 | 
        
           | 594 | mathilde | 79 | 		$parametres = array('navigation.depart' => 10);
 | 
        
           | 790 | raphael | 80 | 		$retour = ServiceEflorePhpUnit::consulterBrut($this->service, $this->projet, $ressources, $parametres);
 | 
        
           | 594 | mathilde | 81 | 		$messageAttendu = "indiquez également la valeur pour le paramètre navigation.limite.";
 | 
        
           |  |  | 82 | 		$this->assertEquals($messageAttendu, $retour,
 | 
        
           |  |  | 83 | 					"Navigation.depart doit être accompagné de navigation.limite ensemble.");
 | 
        
           |  |  | 84 |   | 
        
           | 520 | mathilde | 85 | 	}
 | 
        
           |  |  | 86 |   | 
        
           |  |  | 87 | 	public function testParametreDepartSuperieurTotalResultats() {
 | 
        
           |  |  | 88 | 		$ressources = array();
 | 
        
           |  |  | 89 | 		$parametres = array('navigation.depart' => 20000, 'navigation.limite' => 10 );
 | 
        
           | 790 | raphael | 90 | 			$retour = ServiceEflorePhpUnit::consulterBrut($this->service, $this->projet, $ressources, $parametres);
 | 
        
           | 520 | mathilde | 91 | 			$messageAttendu =
 | 
        
           |  |  | 92 | 				"Erreur : la valeur pour le paramètre navigation.départ est supérieure".
 | 
        
           |  |  | 93 | 				" au nombre total de résultats.";
 | 
        
           |  |  | 94 | 			$this->assertEquals($messageAttendu, $retour,
 | 
        
           |  |  | 95 | 						"Il faut indiquer si la valeur de départ est supérieure au nombre de résultats.");
 | 
        
           |  |  | 96 | 	}
 | 
        
           |  |  | 97 |   | 
        
           |  |  | 98 |   | 
        
           |  |  | 99 | 	public function testParametreNavigationErrone() {
 | 
        
           |  |  | 100 | 		$ressources = array();
 | 
        
           |  |  | 101 | 		$parametresList = array(
 | 
        
           |  |  | 102 | 			array('navigation.depart' => -5, 'navigation.limite' => 10 ),
 | 
        
           |  |  | 103 | 			array('navigation.depart' => 0, 'navigation.limite' => abc ));
 | 
        
           |  |  | 104 | 		$cles = array('navigation.depart','navigation.limite');
 | 
        
           |  |  | 105 | 		$i = 0 ;
 | 
        
           |  |  | 106 | 		foreach ($parametresList as $parametres) {
 | 
        
           | 790 | raphael | 107 | 			$retour = ServiceEflorePhpUnit::consulterBrut($this->service, $this->projet, $ressources, $parametres);
 | 
        
           | 520 | mathilde | 108 | 			$messageAttendu = "Erreur : valeur erronnée pour le paramètre {$cles[$i]}.";
 | 
        
           |  |  | 109 | 			$this->assertEquals($messageAttendu, $retour,
 | 
        
           |  |  | 110 | 						"il faut indiquer lorsque qu'un des paramètres de navigation a une valeur impossible.");
 | 
        
           |  |  | 111 | 			$i++;
 | 
        
           |  |  | 112 | 		}
 | 
        
           |  |  | 113 | 	}
 | 
        
           |  |  | 114 |   | 
        
           |  |  | 115 | 	public function testParametreRetourFormatErrone() {
 | 
        
           |  |  | 116 | 		$ressourcesList = array(
 | 
        
           |  |  | 117 | 			array('bdtfx.nn:73256'),
 | 
        
           |  |  | 118 | 			array('bdtfx.nn:101128'));
 | 
        
           |  |  | 119 | 		$parametres = array('retour.format' => 'pdf');
 | 
        
           |  |  | 120 | 		foreach ($ressourcesList as $ressources) {
 | 
        
           | 790 | raphael | 121 | 			$retour = ServiceEflorePhpUnit::consulterBrut($this->service, $this->projet, $ressources, $parametres);
 | 
        
           | 788 | raphael | 122 | 			$messageAttendu = "Valeur de paramètre inconnue pour 'retour.format'. Ce paramètre n'est pas autorisé";
 | 
        
           |  |  | 123 | 			$this->assertContains($messageAttendu, $retour,
 | 
        
           | 520 | mathilde | 124 | 							"il faut indiquer lorsque que le paramètre retour.format a une valeur impossible.");
 | 
        
           |  |  | 125 | 		}
 | 
        
           |  |  | 126 | 	}
 | 
        
           |  |  | 127 |   | 
        
           |  |  | 128 | 	public function testParametreVersionProjetInconnu() {
 | 
        
           |  |  | 129 | 		$ressourcesList = array(
 | 
        
           |  |  | 130 | 			array('bdtfx.nn:73256'),
 | 
        
           |  |  | 131 | 			array('bdtfx.nn:101128'));
 | 
        
           |  |  | 132 | 		$parametres = array('version.projet' => 'dhgkg22');
 | 
        
           |  |  | 133 | 		foreach ($ressourcesList as $ressources){
 | 
        
           | 790 | raphael | 134 | 			$retour = ServiceEflorePhpUnit::consulterBrut($this->service, $this->projet, $ressources, $parametres);
 | 
        
           | 520 | mathilde | 135 | 			$messageAttendu = "Erreur : La version est inconnue.";
 | 
        
           |  |  | 136 | 			$this->assertEquals($messageAttendu, $retour,
 | 
        
           |  |  | 137 | 									"Il faut indiquer si la valeur du  paramètre version.projet est inconnue.");
 | 
        
           |  |  | 138 | 		}
 | 
        
           |  |  | 139 | 	}
 | 
        
           |  |  | 140 |   | 
        
           |  |  | 141 | 	//++ ------------------------------------Test du retour json correct -----------------------------++
 | 
        
           |  |  | 142 |   | 
        
           |  |  | 143 | 	//++ ---Informations ----++
 | 
        
           |  |  | 144 |   | 
        
           |  |  | 145 | 	public function testJsonBienFormeInformations() {
 | 
        
           |  |  | 146 | 		$ressources = array();
 | 
        
           |  |  | 147 | 		$parametres = array('navigation.depart' => 10, 'navigation.limite' => 15);
 | 
        
           | 790 | raphael | 148 | 			$url = ServiceEflorePhpUnit::creerUrl($this->service, $ressources, $parametres);
 | 
        
           |  |  | 149 | 			$retour = $this->consulterJson($this->service, $this->projet, $ressources, $parametres);
 | 
        
           | 520 | mathilde | 150 | 			$this->assertArrayHasKey('entete', $retour, "Le json ne contient pas d'attribut : entete. Voir : $url");
 | 
        
           |  |  | 151 | 			$this->assertArrayHasKey('resultats', $retour, "Le json ne contient pas d'attribut : resultat. Voir : $url");
 | 
        
           |  |  | 152 | 			$this->verifierJsonEnteteBienFormeInformations($retour, $parametres);
 | 
        
           |  |  | 153 | 	}
 | 
        
           |  |  | 154 |   | 
        
           |  |  | 155 | 	private function verifierJsonEnteteBienFormeInformations($retour, $parametres) {
 | 
        
           |  |  | 156 | 		//depart
 | 
        
           |  |  | 157 | 		$this->assertArrayHasKey('depart', $retour['entete'],
 | 
        
           |  |  | 158 | 					"L'en-tête ne contient pas d'attribut : depart ");
 | 
        
           |  |  | 159 | 		$this->assertEquals($retour['entete']['depart'], $parametres['navigation.depart'],
 | 
        
           |  |  | 160 | 					"La valeur de départ est incorrecte dans l'en-tête.");
 | 
        
           |  |  | 161 | 		//limite
 | 
        
           |  |  | 162 | 		$this->assertArrayHasKey('limite', $retour['entete'],
 | 
        
           |  |  | 163 | 					"L'en-tête ne contient pas d'attribut : limite");
 | 
        
           |  |  | 164 | 		$this->assertEquals($retour['entete']['limite'], $parametres['navigation.limite'],
 | 
        
           |  |  | 165 | 					"La valeur de limite est incorrecte dans l'en-tête.");
 | 
        
           |  |  | 166 | 		//total
 | 
        
           |  |  | 167 | 		$this->assertArrayHasKey('total', $retour['entete'],
 | 
        
           |  |  | 168 | 					"L'en-tête ne contient pas d'attribut : total ");
 | 
        
           |  |  | 169 | 		$this->assertNotEquals('', $retour['entete']['total'],
 | 
        
           |  |  | 170 | 							"La valeur de total est vide dans l'en-tête.");
 | 
        
           |  |  | 171 | 		//href
 | 
        
           |  |  | 172 | 		$this->assertArrayHasKey('href.suivant', $retour['entete'],
 | 
        
           |  |  | 173 | 					"L'en-tête ne contient pas d'attribut : href.suivant ");
 | 
        
           |  |  | 174 | 		$this->assertArrayHasKey('href.precedent', $retour['entete'],
 | 
        
           |  |  | 175 | 							"L'en-tête ne contient pas d'attribut : href.precedent ");
 | 
        
           |  |  | 176 | 		$parametres_url =
 | 
        
           |  |  | 177 | 		array('navigation.depart' => ($retour['entete']['limite']+$retour['entete']['depart']),
 | 
        
           |  |  | 178 | 						 'navigation.limite' => $retour['entete']['limite'] );
 | 
        
           | 790 | raphael | 179 | 		$urlsuivant = ServiceEflorePhpUnit::creerUrl($this->service, $ressources, $parametres_url);
 | 
        
           | 520 | mathilde | 180 | 		$this->assertEquals($urlsuivant, $retour['entete']['href.suivant'],
 | 
        
           |  |  | 181 | 												"L' url $urlsuivant de l'entete est incorrecte.");
 | 
        
           |  |  | 182 | 	}
 | 
        
           |  |  | 183 |   | 
        
           |  |  | 184 | 	public function testJsonResultatsHrefInformations() {
 | 
        
           |  |  | 185 | 		$ressources = array();
 | 
        
           |  |  | 186 | 		$parametres = array('navigation.depart' => 370, 'navigation.limite' => 5);
 | 
        
           | 790 | raphael | 187 | 		$url = ServiceEflorePhpUnit::creerUrl($this->service, $ressources, $parametres);
 | 
        
           |  |  | 188 | 		$retour = $this->consulterJson($this->service, $this->projet, $ressources, $parametres);
 | 
        
           | 783 | raphael | 189 | 		foreach ($retour['resultats'] as $id => $valeurs) {
 | 
        
           |  |  | 190 | 			if (!$valeurs['num_nomen']) {
 | 
        
           |  |  | 191 | 				$this->assertArrayNotHasKey('href', $valeurs,
 | 
        
           | 520 | mathilde | 192 | 							"Il ne doit pas avoir de lien s'il n'y a pas de numéro nomenclatural (=0). Voir $url ");
 | 
        
           |  |  | 193 | 			}
 | 
        
           |  |  | 194 | 		}
 | 
        
           |  |  | 195 | 	}
 | 
        
           |  |  | 196 |   | 
        
           |  |  | 197 | 	public function testJsonNombreLimiteDemande() {
 | 
        
           |  |  | 198 | 		$ressources = array();
 | 
        
           |  |  | 199 | 		$parametresList = array('navigation.depart' => 10, 'navigation.limite' => 15 );
 | 
        
           | 790 | raphael | 200 | 			$url = ServiceEflorePhpUnit::creerUrl($this->service, $ressources, $parametres);
 | 
        
           |  |  | 201 | 			$retour = $this->consulterJson($this->service, $this->projet, $ressources, $parametres);
 | 
        
           | 520 | mathilde | 202 | 			$this->assertLessThanOrEqual(15, count($retour),
 | 
        
           |  |  | 203 | 				"Le json renvoie un nombre de résultats trop important : entete. Voir : $url");
 | 
        
           |  |  | 204 | 	}
 | 
        
           |  |  | 205 |   | 
        
           |  |  | 206 | 	//++ ---Informations.nn ----++
 | 
        
           |  |  | 207 |   | 
        
           |  |  | 208 | 	public function testJsonInformationsNN_min() {
 | 
        
           |  |  | 209 | 		$ressourcesList = array(
 | 
        
           |  |  | 210 | 			array('bdtfx.nn:73256'),
 | 
        
           |  |  | 211 | 			array('bdtfx.nn:101128'));
 | 
        
           |  |  | 212 | 		$parametres = array('retour.format' => 'min' );
 | 
        
           |  |  | 213 | 		foreach ($ressourcesList as $ressources) {
 | 
        
           | 790 | raphael | 214 | 			$retour = $this->consulterJson($this->service, $this->projet, $ressources, $parametres);
 | 
        
           | 520 | mathilde | 215 | 			$this->assertArrayNotHasKey('type_bio.code',$retour,
 | 
        
           |  |  | 216 | 				"Le champs 'type_bio.code' ne doit pas être présent si retour.format=min. ");
 | 
        
           |  |  | 217 | 			$this->assertArrayNotHasKey('type_bio.libelle',$retour,
 | 
        
           |  |  | 218 | 				"Le champs 'type_bio.libelle' ne doit pas être présent si retour.format=min.");
 | 
        
           |  |  | 219 | 			$this->assertArrayNotHasKey('type_bio.detail',$retour,
 | 
        
           |  |  | 220 | 				"Le champs 'type_bio.detail' ne doit pas être présent si retour.format=min.");
 | 
        
           |  |  | 221 | 			$champs = array_keys(config::get('champs_ontologiques'));
 | 
        
           |  |  | 222 | 			foreach ($champs as $chps) {
 | 
        
           |  |  | 223 | 				$this->assertArrayNotHasKey($chps.'.libelle', $retour,
 | 
        
           |  |  | 224 | 					"Le champs '{$chps}.libelle' ne doit pas être présent si retour.format=min.");
 | 
        
           |  |  | 225 | 				$this->assertArrayNotHasKey($chps.'.code', $retour,
 | 
        
           |  |  | 226 | 					"Le champs '{$chps}.code' ne doit pas être présent si retour.format=min.");
 | 
        
           |  |  | 227 | 				$this->assertArrayNotHasKey($chps.'.href', $retour,
 | 
        
           |  |  | 228 | 					"Le champs '{$chps}.href' ne doit pas être présent si retour.format=min.");
 | 
        
           |  |  | 229 | 			}
 | 
        
           |  |  | 230 | 			foreach ($champs as $chps) {
 | 
        
           |  |  | 231 | 				$this->assertArrayNotHasKey($chps.'_min.libelle', $retour,
 | 
        
           |  |  | 232 | 								"Le champs '{$chps}_min.libelle' ne doit pas être présent si retour.format=min.");
 | 
        
           |  |  | 233 | 				$this->assertArrayNotHasKey($chps.'_min.code', $retour,
 | 
        
           |  |  | 234 | 								"Le champs '{$chps}_min.code' ne doit pas être présent si retour.format=min.");
 | 
        
           |  |  | 235 | 				$this->assertArrayNotHasKey($chps.'_min.href', $retour,
 | 
        
           |  |  | 236 | 								"Le champs '{$chps}_min.href' ne doit pas être présent si retour.format=min.");
 | 
        
           |  |  | 237 | 				$this->assertArrayNotHasKey($chps.'_max.libelle', $retour,
 | 
        
           |  |  | 238 | 								"Le champs '{$chps}_max.libelle' ne doit pas être présent si retour.format=min.");
 | 
        
           |  |  | 239 | 				$this->assertArrayNotHasKey($chps.'_max.code', $retour,
 | 
        
           |  |  | 240 | 								"Le champs '{$chps}_max.code' ne doit pas être présent si retour.format=min.");
 | 
        
           |  |  | 241 | 				$this->assertArrayNotHasKey($chps.'_max.href', $retour,
 | 
        
           |  |  | 242 | 								"Le champs '{$chps}_max.href' ne doit pas être présent si retour.format=min.");
 | 
        
           |  |  | 243 | 			}
 | 
        
           |  |  | 244 |   | 
        
           |  |  | 245 | 		}
 | 
        
           |  |  | 246 | 	}
 | 
        
           |  |  | 247 |   | 
        
           |  |  | 248 |   | 
        
           |  |  | 249 | 	public function testJsonInformationsNNBasefor_max() {
 | 
        
           |  |  | 250 | 		$ressources = array('bdtfx.nn:73256');
 | 
        
           |  |  | 251 | 		$parametresList = array(
 | 
        
           |  |  | 252 | 			array('retour.format' => 'max', 'categorie' => 'description'),
 | 
        
           |  |  | 253 | 			array('retour.format' => 'max' , 'categorie' => 'ecologie'));
 | 
        
           |  |  | 254 | 			foreach ($parametresList  as $parametres) {
 | 
        
           | 790 | raphael | 255 | 				$retour = $this->consulterJson($this->service, $this->projet, $ressources, $parametres);
 | 
        
           | 520 | mathilde | 256 | 				if ($parametres['categorie'] == 'description') {
 | 
        
           |  |  | 257 | 					$this->verifierParametresDescription_max($retour);
 | 
        
           |  |  | 258 | 				} else {
 | 
        
           |  |  | 259 | 					$this->verifierParametresEcologie_max($retour, 'baseflor');
 | 
        
           |  |  | 260 | 				}
 | 
        
           |  |  | 261 | 			}
 | 
        
           |  |  | 262 | 	}
 | 
        
           |  |  | 263 |   | 
        
           |  |  | 264 | 	public function testJsonInformationsNNRangSup_max() {
 | 
        
           |  |  | 265 | 		$ressources = array('bdtfx.nn:101128');
 | 
        
           |  |  | 266 | 		$parametres = array('retour.format' => 'max' , 'categorie' => 'ecologie');
 | 
        
           | 790 | raphael | 267 | 			$retour = $this->consulterJson($this->service, $this->projet, $ressources, $parametres);
 | 
        
           | 520 | mathilde | 268 | 			if ($parametres['categorie'] == 'description') {
 | 
        
           |  |  | 269 | 				$this->verifierParametresDescription_max();
 | 
        
           |  |  | 270 | 			} else {
 | 
        
           |  |  | 271 | 				$this->verifierParametresEcologie_max($retour, 'rangSup');
 | 
        
           |  |  | 272 | 			}
 | 
        
           |  |  | 273 | 	}
 | 
        
           |  |  | 274 |   | 
        
           |  |  | 275 | 	private function verifierParametresDescription_max($retour) {
 | 
        
           |  |  | 276 | 		$this->assertArrayHasKey('type_bio.code',$retour,
 | 
        
           |  |  | 277 | 									"Le champs 'type_bio.code'  doit  être présent si retour.format=max. ");
 | 
        
           |  |  | 278 | 		$this->assertArrayHasKey('type_bio.libelle',$retour,
 | 
        
           |  |  | 279 | 									"Le champs 'type_bio.libelle' doit  être présent si retour.format=max.");
 | 
        
           |  |  | 280 | 		$this->assertArrayHasKey('type_bio.detail',$retour,
 | 
        
           |  |  | 281 | 									"Le champs 'type_bio.detail' doit  être présent si retour.format=max.");
 | 
        
           |  |  | 282 | 	}
 | 
        
           |  |  | 283 |   | 
        
           |  |  | 284 | 	private function verifierParametresEcologie_max($retour,$type) {
 | 
        
           |  |  | 285 | 		$champs = array_keys(config::get('champs_ontologiques'));
 | 
        
           |  |  | 286 | 		if ($type == 'baseflor') {
 | 
        
           |  |  | 287 | 			foreach ($champs as $chps) {
 | 
        
           |  |  | 288 | 				$this->assertArrayHasKey($chps.'.libelle', $retour,
 | 
        
           |  |  | 289 | 													"Le champs '{$chps}.libelle'  doit  être présent si retour.format=max.");
 | 
        
           |  |  | 290 | 				$this->assertArrayHasKey($chps.'.code', $retour,
 | 
        
           |  |  | 291 | 													"Le champs '{$chps}.code'  doit  être présent si retour.format=max.");
 | 
        
           |  |  | 292 | 				$this->assertArrayHasKey($chps.'.href', $retour,
 | 
        
           |  |  | 293 | 													"Le champs '{$chps}.href'  doit  être présent si retour.format=max.");
 | 
        
           |  |  | 294 | 			}
 | 
        
           |  |  | 295 | 		} elseif ($type == 'rangSup') {
 | 
        
           |  |  | 296 | 			foreach ($champs as $chps) {
 | 
        
           |  |  | 297 | 				$this->assertArrayHasKey($chps.'_min.libelle', $retour,
 | 
        
           |  |  | 298 | 											"Le champs '{$chps}_min.libelle'  doit  être présent si retour.format=max.");
 | 
        
           |  |  | 299 | 				$this->assertArrayHasKey($chps.'_min.code', $retour,
 | 
        
           |  |  | 300 | 											"Le champs '{$chps}_min.code' doit  être présent si retour.format=max.");
 | 
        
           |  |  | 301 | 				$this->assertArrayHasKey($chps.'_min.href', $retour,
 | 
        
           |  |  | 302 | 											"Le champs '{$chps}_min.href' doit  être présent si retour.format=max.");
 | 
        
           |  |  | 303 | 				$this->assertArrayHasKey($chps.'_max.libelle', $retour,
 | 
        
           |  |  | 304 | 											"Le champs '{$chps}_max.libelle' doit  être présent si retour.format=max.");
 | 
        
           |  |  | 305 | 				$this->assertArrayHasKey($chps.'_max.code', $retour,
 | 
        
           |  |  | 306 | 											"Le champs '{$chps}_max.code' doit  être présent si retour.format=max.");
 | 
        
           |  |  | 307 | 				$this->assertArrayHasKey($chps.'_max.href', $retour,
 | 
        
           |  |  | 308 | 											"Le champs '{$chps}_max.href' doit  être présent si retour.format=max.");
 | 
        
           |  |  | 309 | 			}
 | 
        
           |  |  | 310 | 		}
 | 
        
           |  |  | 311 | 	}
 | 
        
           |  |  | 312 |   | 
        
           | 554 | mathilde | 313 | 	//++ ------------------------------------Test du champs type biologique  -----------------------------++
 | 
        
           | 520 | mathilde | 314 |   | 
        
           | 555 | mathilde | 315 | 	//TEST sur différents cas typique de 'type_bio.libelle'
 | 
        
           | 554 | mathilde | 316 | 	public function testJsonTypeBioOntologies() {
 | 
        
           |  |  | 317 | 		$ressourcesList = array(array("bdtfx.nn:73256"),array("bdtfx.nn:70441"),array("bdtfx.nn:62911"),array("bdtfx.nn:72496"),
 | 
        
           |  |  | 318 | 							array("bdtfx.nn:6446"),array("bdtfx.nn:8373"), array("bdafx.nn:35574"), array("bdtfx.nn:62443"),
 | 
        
           |  |  | 319 | 							array("bdtfx.nn:62442"));
 | 
        
           |  |  | 320 | 		$parametres = array();
 | 
        
           |  |  | 321 | 		$resultats_attendus = array ('Grhi-aqua' => 'Géophytes (>= 1m) à rhizome  (plantes aquatiques) ' ,
 | 
        
           |  |  | 322 | 				'test-aqua-car' => 'Thérophytes (< 1m) estivaux  (plantes aquatiques, carnivores) ',
 | 
        
           |  |  | 323 | 				'grhi' => 'Géophytes (< 1m) à rhizome ',
 | 
        
           |  |  | 324 | 				'hsto(test)' => 'Hémicryptophytes (< 1m) stolonifères , Thérophytes (< 1m) estivaux ',
 | 
        
           |  |  | 325 | 				'Hsto-lia(Grhi-lia)' => 'Hémicryptophytes (>= 1m) stolonifères  (lianes) , Géophytes (>= 1m) à rhizome (lianes) ',
 | 
        
           |  |  | 326 | 				'Cfru(b-cad)' => 'Chaméphytes (>= 1m) frutescents , Nanophanérophytes (2 à 4m) (caducifoliées) ',
 | 
        
           |  |  | 327 | 				'test-aqua(heri)' => 'Thérophytes (< 1m) estivaux  (plantes aquatiques) , Hémicryptophytes (< 1m) érigé ',
 | 
        
           |  |  | 328 | 				'hbis(hsto,test)-suc' => 'Hémicryptophytes (< 1m) bisannuels  (succulentes) , Hémicryptophytes (< 1m) stolonifères, Thérophytes (< 1m) estivaux ',
 | 
        
           |  |  | 329 | 				'hbis(hsto)-suc' => 'Hémicryptophytes (< 1m) bisannuels  (succulentes) , Hémicryptophytes (< 1m) stolonifères ');
 | 
        
           |  |  | 330 | 		foreach ($ressourcesList as $ressources) {
 | 
        
           | 790 | raphael | 331 | 			$retour = $this->consulterJson($this->service, $this->projet, $ressources, $parametres);
 | 
        
           | 554 | mathilde | 332 | 			$code = $retour['type_bio.code'];
 | 
        
           |  |  | 333 | 			$this->assertEquals($resultats_attendus[$code], $retour['type_bio.libelle'],
 | 
        
           |  |  | 334 | 										"le traitement de l'ontologie pour les types biologiques est erroné pour $ressources[0] . ");
 | 
        
           |  |  | 335 | 		}
 | 
        
           |  |  | 336 | 	}
 | 
        
           | 520 | mathilde | 337 |   | 
        
           |  |  | 338 | }
 | 
        
           |  |  | 339 | ?>
 |