Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 958 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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