1 |
fmichon |
9227 |
<?php |
2 |
|
|
/** |
3 |
|
|
* Ce script contient la définition de la classe 'GeneralCommon'. |
4 |
|
|
* |
5 |
|
|
* @package openads |
6 |
|
|
* @version SVN : $Id$ |
7 |
|
|
*/ |
8 |
|
|
|
9 |
softime |
9282 |
require_once "../tests/resources/omtestcase.class.php"; |
10 |
|
|
|
11 |
fmichon |
9227 |
/** |
12 |
|
|
* Cette classe permet de tester unitairement les fonctions de l'application. |
13 |
|
|
*/ |
14 |
softime |
9282 |
abstract class GeneralCommon extends OMTestCase { |
15 |
fmichon |
9227 |
|
16 |
|
|
/** |
17 |
|
|
* Méthode lancée en fin de traitement |
18 |
|
|
*/ |
19 |
|
|
public function common_tearDown() { |
20 |
softime |
9282 |
parent::common_tearDown(); |
21 |
|
|
// |
22 |
|
|
$this->clean_session(); |
23 |
fmichon |
9227 |
} |
24 |
|
|
|
25 |
|
|
/** |
26 |
|
|
* Test la fonction mois_date() de la classe Utils. |
27 |
|
|
*/ |
28 |
|
|
public function test_01_utils_mois_date() { |
29 |
softime |
9282 |
// Instanciation de la classe *om_application* |
30 |
|
|
$f = $this->get_inst_om_application(); |
31 |
fmichon |
9227 |
$f->disableLog(); |
32 |
|
|
// Avec des mois |
33 |
|
|
|
34 |
|
|
// Pour les additions |
35 |
|
|
// Initialisation des tableaux |
36 |
|
|
$tab_date_dep = array(); |
37 |
|
|
$tab_delay = array(); |
38 |
|
|
$tab_date_fin = array(); |
39 |
|
|
|
40 |
|
|
// Tableau des date de départ |
41 |
|
|
$tab_date_dep = array( |
42 |
|
|
0 => "2013-12-31", |
43 |
|
|
1 => "2014-01-31", |
44 |
|
|
2 => "2014-01-01", |
45 |
|
|
3 => "2014-01-31", |
46 |
|
|
4 => "2015-12-31", |
47 |
|
|
5 => "", |
48 |
|
|
6 => "", |
49 |
|
|
7 => "", |
50 |
|
|
8 => "2015-12-31", |
51 |
|
|
9 => "2015-12-31", |
52 |
|
|
10 => "openADS", |
53 |
|
|
11 => "openADS", |
54 |
|
|
12 => "openADS", |
55 |
|
|
); |
56 |
|
|
// Tableau des delais |
57 |
|
|
$tab_delay = array( |
58 |
|
|
0 => "2", |
59 |
|
|
1 => "5", |
60 |
|
|
2 => "12", |
61 |
|
|
3 => "27", |
62 |
|
|
4 => "2", |
63 |
|
|
5 => "2", |
64 |
|
|
6 => "openads", |
65 |
|
|
7 => "", |
66 |
|
|
8 => "openADS", |
67 |
|
|
9 => "", |
68 |
|
|
10 => "2", |
69 |
|
|
11 => "openads", |
70 |
|
|
12 => "", |
71 |
|
|
); |
72 |
|
|
// Tableau des date résultat |
73 |
|
|
$tab_date_fin = array( |
74 |
|
|
0 => "2014-02-28", |
75 |
|
|
1 => "2014-06-30", |
76 |
|
|
2 => "2015-01-01", |
77 |
|
|
3 => "2016-04-30", |
78 |
|
|
4 => "2016-02-29", |
79 |
|
|
5 => null, |
80 |
|
|
6 => null, |
81 |
|
|
7 => null, |
82 |
|
|
8 => "2015-12-31", |
83 |
|
|
9 => "2015-12-31", |
84 |
|
|
10 => null, |
85 |
|
|
11 => null, |
86 |
|
|
12 => null, |
87 |
|
|
); |
88 |
|
|
|
89 |
|
|
// Pour chaque date |
90 |
|
|
foreach ($tab_date_dep as $key => $date_dep) { |
91 |
|
|
// Calcul la date résultat |
92 |
|
|
$date_fin = $f->mois_date($date_dep, $tab_delay[$key], "+"); |
93 |
|
|
// Vérifie que la date résultat est correct |
94 |
|
|
$this->assertEquals($date_fin, $tab_date_fin[$key]); |
95 |
|
|
} |
96 |
|
|
|
97 |
|
|
// Pour les soustractions |
98 |
|
|
// Initialisation des tableaux |
99 |
|
|
$tab_date_dep = array(); |
100 |
|
|
$tab_delay = array(); |
101 |
|
|
$tab_date_fin = array(); |
102 |
|
|
|
103 |
|
|
// Tableau des date de départ |
104 |
|
|
$tab_date_dep = array( |
105 |
|
|
0 => "2014-01-31", |
106 |
|
|
); |
107 |
|
|
// Tableau des delais |
108 |
|
|
$tab_delay = array( |
109 |
|
|
0 => "4", |
110 |
|
|
); |
111 |
|
|
// Tableau des date résultat |
112 |
|
|
$tab_date_fin = array( |
113 |
|
|
0 => "2013-09-30", |
114 |
|
|
); |
115 |
|
|
|
116 |
|
|
// Pour chaque date |
117 |
|
|
foreach ($tab_date_dep as $key => $date_dep) { |
118 |
|
|
// Calcul la date résultat |
119 |
|
|
$date_fin = $f->mois_date($date_dep, $tab_delay[$key], "-"); |
120 |
|
|
// Vérifie que la date résultat est correct |
121 |
|
|
$this->assertEquals($date_fin, $tab_date_fin[$key]); |
122 |
|
|
} |
123 |
|
|
|
124 |
|
|
// Avec des jours |
125 |
|
|
|
126 |
|
|
// Pour les additions |
127 |
|
|
// Initialisation des tableaux |
128 |
|
|
$tab_date_dep = array(); |
129 |
|
|
$tab_delay = array(); |
130 |
|
|
$tab_date_fin = array(); |
131 |
|
|
|
132 |
|
|
// Tableau des date de départ |
133 |
|
|
$tab_date_dep = array( |
134 |
|
|
0 => "2013-12-31", |
135 |
|
|
1 => "2014-01-31", |
136 |
|
|
2 => "2014-01-01", |
137 |
|
|
3 => "2014-01-31", |
138 |
|
|
4 => "2015-12-31", |
139 |
|
|
5 => "", |
140 |
|
|
6 => "", |
141 |
|
|
7 => "", |
142 |
|
|
8 => "2015-12-31", |
143 |
|
|
9 => "2015-12-31", |
144 |
|
|
10 => "openADS", |
145 |
|
|
11 => "openADS", |
146 |
|
|
12 => "openADS", |
147 |
|
|
); |
148 |
|
|
// Tableau des delais |
149 |
|
|
$tab_delay = array( |
150 |
|
|
0 => "2", |
151 |
|
|
1 => "5", |
152 |
|
|
2 => "12", |
153 |
|
|
3 => "27", |
154 |
|
|
4 => "2", |
155 |
|
|
5 => "2", |
156 |
|
|
6 => "openads", |
157 |
|
|
7 => "", |
158 |
|
|
8 => "openADS", |
159 |
|
|
9 => "", |
160 |
|
|
10 => "2", |
161 |
|
|
11 => "openads", |
162 |
|
|
12 => "", |
163 |
|
|
); |
164 |
|
|
// Tableau des dates résultats |
165 |
|
|
$tab_date_fin = array( |
166 |
|
|
0 => "2014-01-02", |
167 |
|
|
1 => "2014-02-05", |
168 |
|
|
2 => "2014-01-13", |
169 |
|
|
3 => "2014-02-27", |
170 |
|
|
4 => "2016-01-02", |
171 |
|
|
5 => null, |
172 |
|
|
6 => null, |
173 |
|
|
7 => null, |
174 |
|
|
8 => "2015-12-31", |
175 |
|
|
9 => "2015-12-31", |
176 |
|
|
10 => null, |
177 |
|
|
11 => null, |
178 |
|
|
12 => null, |
179 |
|
|
); |
180 |
|
|
|
181 |
|
|
// Pour chaque date |
182 |
|
|
foreach ($tab_date_dep as $key => $date_dep) { |
183 |
|
|
// Calcul la date résultat |
184 |
|
|
$date_fin = $f->mois_date($date_dep, $tab_delay[$key], "+", "jour"); |
185 |
|
|
// Vérifie que la date résultat est correct |
186 |
|
|
$this->assertEquals($date_fin, $tab_date_fin[$key]); |
187 |
|
|
} |
188 |
|
|
|
189 |
|
|
// Pour les soustractions |
190 |
|
|
// Initialisation des tableaux |
191 |
|
|
$tab_date_dep = array(); |
192 |
|
|
$tab_delay = array(); |
193 |
|
|
$tab_date_fin = array(); |
194 |
|
|
|
195 |
|
|
// Tableau des date de départ |
196 |
|
|
$tab_date_dep = array( |
197 |
|
|
0 => "2014-01-31", |
198 |
|
|
); |
199 |
|
|
// Tableau des delais |
200 |
|
|
$tab_delay = array( |
201 |
|
|
0 => "4", |
202 |
|
|
); |
203 |
|
|
// Tableau des date résultat |
204 |
|
|
$tab_date_fin = array( |
205 |
|
|
0 => "2014-01-27", |
206 |
|
|
); |
207 |
|
|
|
208 |
|
|
// Pour chaque date |
209 |
|
|
foreach ($tab_date_dep as $key => $date_dep) { |
210 |
|
|
// Calcul la date résultat |
211 |
|
|
$date_fin = $f->mois_date($date_dep, $tab_delay[$key], "-", "jour"); |
212 |
|
|
// Vérifie que la date résultat est correct |
213 |
|
|
$this->assertEquals($date_fin, $tab_date_fin[$key]); |
214 |
|
|
} |
215 |
softime |
9282 |
// Destruction de la classe *om_application* |
216 |
fmichon |
9227 |
$f->__destruct(); |
217 |
|
|
} |
218 |
|
|
|
219 |
|
|
|
220 |
|
|
/** |
221 |
|
|
* Vérification de la méthode permettant de selectionner le logo de la bonne |
222 |
|
|
* collectivité. |
223 |
|
|
*/ |
224 |
|
|
function test_02_TNR_selection_du_logo_dans_les_editions() { |
225 |
softime |
9282 |
// Instanciation de la classe *om_application* |
226 |
|
|
$f = $this->get_inst_om_application(); |
227 |
fmichon |
9227 |
$f->disableLog(); |
228 |
|
|
// Vérification du logo de collectivité mono dans le cas où : |
229 |
|
|
// - un logo multi actif est défini |
230 |
|
|
// - un logo actif pour la collectivité est défini |
231 |
softime |
17036 |
$edition = $f->get_inst__om_edition(); |
232 |
fmichon |
9227 |
$logo = $edition->get_logo_from_collectivite("logopdf.png", 2); |
233 |
|
|
// XXX le double // dans le path est nécessaire |
234 |
|
|
$logo_valid = array( |
235 |
|
|
"file" => "../var/filestorage//88/8815/88154c6f68d3a0e1928c84fc0187993d", |
236 |
|
|
"w" => 43.349333333333334, |
237 |
|
|
"h" => 43.349333333333334, |
238 |
|
|
"type" => "png", |
239 |
|
|
); |
240 |
|
|
// Le logo commune doit être retourné par la méthode |
241 |
|
|
$this->assertEquals($logo, $logo_valid); |
242 |
|
|
|
243 |
|
|
// Désactivation du logo de la commune |
244 |
|
|
$val_logo["actif"] = 'f'; |
245 |
|
|
$f->db->autoExecute(DB_PREFIXE."om_logo", $val_logo, DB_AUTOQUERY_UPDATE, "om_logo=2"); |
246 |
|
|
|
247 |
|
|
// Vérification du logo de collectivité mono dans le cas où : |
248 |
|
|
// - un logo multi actif est défini |
249 |
|
|
// - un logo la collectivité est inactif |
250 |
softime |
17036 |
$edition = $f->get_inst__om_edition(); |
251 |
fmichon |
9227 |
$logo = $edition->get_logo_from_collectivite("logopdf.png", 1); |
252 |
|
|
// XXX le double // dans le path est nécessaire |
253 |
|
|
$logo_valid = array( |
254 |
|
|
"file" => "../var/filestorage//d2/d20a/d20a5c36d3b83464bab63035a7f61901", |
255 |
|
|
"w" => 43.349333333333334, |
256 |
|
|
"h" => 43.349333333333334, |
257 |
|
|
"type" => "png", |
258 |
|
|
); |
259 |
|
|
// Le logo de la collectivité multi doit être retourné |
260 |
|
|
$this->assertEquals($logo, $logo_valid); |
261 |
|
|
|
262 |
|
|
// Désactivation du logo de la commune |
263 |
|
|
$val_logo["actif"] = 'f'; |
264 |
|
|
$f->db->autoExecute(DB_PREFIXE."om_logo", $val_logo, DB_AUTOQUERY_UPDATE, "om_logo=6"); |
265 |
|
|
|
266 |
|
|
// Vérification du logo de collectivité mono dans le cas où aucun logo |
267 |
|
|
// n'est activé |
268 |
softime |
17036 |
$edition = $f->get_inst__om_edition(); |
269 |
fmichon |
9227 |
$logo = $edition->get_logo_from_collectivite("logopdf.png", 1); |
270 |
|
|
$logo_valid = null; |
271 |
|
|
// Un valeur null doit être retournée |
272 |
|
|
$this->assertEquals($logo, $logo_valid); |
273 |
softime |
9282 |
// Destruction de la classe *om_application* |
274 |
fmichon |
9227 |
$f->__destruct(); |
275 |
|
|
} |
276 |
|
|
|
277 |
|
|
/** |
278 |
|
|
* Vérification de la méthode permettant de formater le corps du courriel |
279 |
softime |
12654 |
* notifié. |
280 |
fmichon |
9227 |
*/ |
281 |
|
|
function test_03_instruction_formater_modele() { |
282 |
softime |
9282 |
// Instanciation de la classe *om_application* |
283 |
softime |
12654 |
$f = $this->get_inst_om_application("adminfonct", "adminfonct"); |
284 |
fmichon |
9227 |
$f->disableLog(); |
285 |
|
|
// template du modèle |
286 |
softime |
12654 |
$template = 'DI : <DOSSIER_INSTRUCTION><br/> |
287 |
|
|
LIEN : <URL_INSTRUCTION><br/> |
288 |
|
|
INSTRUCTION : <ID_INSTRUCTION><br/> |
289 |
|
|
LIEN DOSSIER : [URL_DOSSIER]<br/> |
290 |
|
|
LIEN TELECHARGEMENT DOCUMENT : [LIEN_TELECHARGEMENT_DOCUMENT]<br/> |
291 |
|
|
LIEN TELECHARGEMENT ANNEXE : [LIEN_TELECHARGEMENT_ANNEXE]<br/>'; |
292 |
fmichon |
9227 |
// résultat attendu |
293 |
softime |
12654 |
$di = 'PC0130551200001P0'; |
294 |
fmichon |
9227 |
$inst = 7; |
295 |
softime |
12654 |
$urlInstr = 'http://localhost/openads/app/index.php?module=form&direct_link=true&obj=dossier_instruction&action=3'. |
296 |
|
|
'&direct_field=dossier&direct_form=instruction&direct_action=3&direct_idx='. |
297 |
|
|
$inst; |
298 |
|
|
$link = '<a href="'.$urlInstr.'">'.$urlInstr.'</a>'; |
299 |
|
|
$urlDossier = 'http://localhost/openads/app/index.php?module=form&obj=dossier_instruction&action=3&idx='. |
300 |
|
|
$di. |
301 |
|
|
'&retour=tab'; |
302 |
|
|
$expected = sprintf( |
303 |
|
|
'DI : %1$s<br/> |
304 |
|
|
LIEN : %2$s<br/> |
305 |
|
|
INSTRUCTION : %3$s<br/> |
306 |
|
|
LIEN DOSSIER : %4$s<br/> |
307 |
|
|
LIEN TELECHARGEMENT DOCUMENT : lien_telechargement_document<br/> |
308 |
|
|
LIEN TELECHARGEMENT ANNEXE : lien_telechargement_annexe<br/>', |
309 |
|
|
$di, |
310 |
|
|
$link, |
311 |
|
|
$inst, |
312 |
|
|
$urlDossier |
313 |
|
|
); |
314 |
fmichon |
9227 |
// Instance de la classe instruction |
315 |
softime |
12654 |
$instrNotif = $f->get_inst__om_dbform(array( |
316 |
|
|
"obj" => "instruction_notification", |
317 |
fmichon |
9227 |
"idx" => "]", |
318 |
|
|
)); |
319 |
softime |
12654 |
// Tableau de valeur servant à formater le modèle |
320 |
|
|
$val = array( |
321 |
|
|
'instruction_notification' => array( |
322 |
|
|
'instruction' => $inst, |
323 |
|
|
'lien_telechargement_document' => 'lien_telechargement_document', |
324 |
|
|
'annexes' => array( |
325 |
|
|
array( |
326 |
|
|
'lien' => 'lien_telechargement_annexe' |
327 |
|
|
) |
328 |
|
|
) |
329 |
|
|
), |
330 |
|
|
'dossier' => array('dossier' => $di) |
331 |
|
|
); |
332 |
fmichon |
9227 |
// Traitement |
333 |
softime |
12654 |
$result = $instrNotif->get_message_notification($template, 'notification_commune', $val); |
334 |
fmichon |
9227 |
// Vérification du traitement |
335 |
softime |
9282 |
$this->assertEquals($expected, $result, "Les modèles sont différents."); |
336 |
|
|
// Destruction de la classe *om_application* |
337 |
fmichon |
9227 |
$f->__destruct(); |
338 |
|
|
} |
339 |
|
|
|
340 |
|
|
|
341 |
|
|
/** |
342 |
|
|
* TNR du bug de champs de fusion [*_correspondant] dans la om_requete n°7 "dossier". |
343 |
|
|
* Le test vérifie qu'une seule ligne est retournée par la requête et qu'elle contient |
344 |
|
|
* bien le nom du pétitionnaire principal |
345 |
|
|
*/ |
346 |
|
|
function test_05_TNR_om_requete_dossier() { |
347 |
softime |
9282 |
// Instanciation de la classe *om_application* |
348 |
|
|
$f = $this->get_inst_om_application("admin", "admin"); |
349 |
|
|
$this->assertTrue($f->authenticated, "Erreur d'authentification."); |
350 |
fmichon |
9227 |
$f->disableLog(); |
351 |
softime |
9282 |
// |
352 |
fmichon |
9227 |
$om_requete = $f->get_inst__om_dbform(array( |
353 |
|
|
"obj" => "om_requete", |
354 |
|
|
"idx" => 7, |
355 |
|
|
)); |
356 |
|
|
|
357 |
|
|
// récupération de la requête SQL |
358 |
|
|
$sql = $om_requete->getVal('requete'); |
359 |
|
|
// remplacement des &idx par la valeur du dossier |
360 |
|
|
$sql = str_replace('&idx', "AT0130551300001P0", $sql); |
361 |
|
|
// définition du schéma |
362 |
|
|
$sql = str_replace('&DB_PREFIXE', DB_PREFIXE, $sql); |
363 |
|
|
// exécution de la requête |
364 |
softime |
15835 |
$qres = $f->get_all_results_from_db_query($sql, array( |
365 |
|
|
'origin' => __METHOD__, |
366 |
|
|
'force_return' => true |
367 |
|
|
)); |
368 |
|
|
$this->assertEquals($qres['code'], 'OK', "Erreur de base de données"); |
369 |
|
|
if ($qres['code'] !== 'OK') { |
370 |
softime |
9282 |
// Destruction de la classe *om_application* |
371 |
|
|
$f->__destruct(); |
372 |
|
|
return; |
373 |
|
|
} |
374 |
softime |
15835 |
$count = $qres['row_count']; |
375 |
fmichon |
9227 |
// La om_requete doit retourner une seule ligne |
376 |
|
|
$this->assertEquals(1, $count); |
377 |
|
|
// récupération du résultat de la om_requete |
378 |
softime |
15835 |
$values = array_shift($qres['result']); |
379 |
fmichon |
9227 |
// La valeur de la colonne nom_correspondant doit être le nom du pétitionnaire |
380 |
|
|
// principal |
381 |
|
|
$this->assertEquals("Dupont Jean", $values['nom_correspondant']); |
382 |
softime |
9282 |
// Destruction de la classe *om_application* |
383 |
fmichon |
9227 |
$f->__destruct(); |
384 |
|
|
} |
385 |
|
|
|
386 |
|
|
/** |
387 |
|
|
* TNR de la methode factorisé de création de dossier_message |
388 |
|
|
*/ |
389 |
|
|
function test_06_TNR_dossier_message() { |
390 |
softime |
9282 |
// Instanciation de la classe *om_application* |
391 |
|
|
$f = $this->get_inst_om_application("adminfonct", "adminfonct"); |
392 |
|
|
$this->assertTrue($f->authenticated, "Erreur d'authentification."); |
393 |
fmichon |
9227 |
$f->disableLog(); |
394 |
softime |
9282 |
// Instanciation de la classe *dossier_message* |
395 |
fmichon |
9227 |
$dossier_message_factory = $f->get_inst__om_dbform(array( |
396 |
|
|
"obj" => "dossier_message", |
397 |
|
|
"idx" => 0, |
398 |
|
|
)); |
399 |
|
|
$dossier_message_val = array(); |
400 |
|
|
|
401 |
|
|
$dossier_message_val['contenu'] = 'Test Success'; |
402 |
|
|
$dossier_message_val['dossier'] = 'AT0130551200001P0'; |
403 |
softime |
18876 |
$dossier_message_val['type'] = __('Ajout de pièce(s)'); |
404 |
fmichon |
9227 |
$dossier_message_val['emetteur'] = 'instr'; |
405 |
|
|
$dossier_message_val['login'] = 'instr'; |
406 |
|
|
$dossier_message_val['date_emission'] = date('Y-m-d H:i:s'); |
407 |
|
|
$add = $dossier_message_factory->add_notification_message($dossier_message_val); |
408 |
|
|
$this->assertEquals(true, $add); |
409 |
|
|
$this->assertEquals(true, isset($dossier_message_factory->valF[$dossier_message_factory->clePrimaire])); |
410 |
|
|
$dossier_message = $f->get_inst__om_dbform(array( |
411 |
|
|
"obj" => "dossier_message", |
412 |
|
|
"idx" => $dossier_message_factory->valF[$dossier_message_factory->clePrimaire], |
413 |
|
|
)); |
414 |
|
|
$this->assertEquals($dossier_message_val['dossier'], $dossier_message->getVal('dossier')); |
415 |
|
|
$this->assertEquals('t', $dossier_message->getVal('lu')); |
416 |
|
|
|
417 |
|
|
$dossier_message_val['contenu'] = 'Test Duplicata'; |
418 |
|
|
$add = $dossier_message_factory->add_notification_message($dossier_message_val); |
419 |
|
|
$this->assertEquals(true, $add); |
420 |
|
|
|
421 |
|
|
$dossier_message_val['contenu'] = 'Test nouveau type même dossier'; |
422 |
softime |
18876 |
$dossier_message_val['type'] = __('Autorisation contestée'); |
423 |
fmichon |
9227 |
$add = $dossier_message_factory->add_notification_message($dossier_message_val); |
424 |
|
|
$this->assertEquals(true, $add); |
425 |
|
|
|
426 |
|
|
$dossier_message_val['contenu'] = 'Test message non lu'; |
427 |
|
|
$dossier_message_val['dossier'] = 'AZ0130551200001P0'; |
428 |
|
|
$dossier_message_val['emetteur'] = $f->get_connected_user_login_name(); |
429 |
|
|
$dossier_message_val['login'] = $_SESSION['login']; |
430 |
|
|
$add = $dossier_message_factory->add_notification_message($dossier_message_val); |
431 |
|
|
$this->assertEquals(true, $add); |
432 |
|
|
$dossier_message = $f->get_inst__om_dbform(array( |
433 |
|
|
"obj" => "dossier_message", |
434 |
|
|
"idx" => $dossier_message_factory->valF[$dossier_message_factory->clePrimaire], |
435 |
|
|
)); |
436 |
|
|
$this->assertEquals('f', $dossier_message->getVal('lu')); |
437 |
softime |
9282 |
// Destruction de la classe *om_application* |
438 |
fmichon |
9227 |
$f->__destruct(); |
439 |
|
|
} |
440 |
softime |
15650 |
|
441 |
|
|
|
442 |
|
|
/** |
443 |
|
|
* TNR du suivi de notification |
444 |
|
|
* |
445 |
|
|
* Teste 3 cas : |
446 |
|
|
* 1- Vérifie, pour une instruction, qu'il n'y a que les tableaux de suivi de notification |
447 |
|
|
* ayant des notifications associées qui sont affichés |
448 |
|
|
* 2- L'ajout d'une tâche ayant le même object_id qu'une notification, sans tâche associée, |
449 |
|
|
* ne dois pas empêcher l'affichage du suivi de cette notification. |
450 |
|
|
* 3- L'ajout d'une tâche ayant le même object_id qu'une notification, sans tâche associée, |
451 |
|
|
* ne dois pas empêcher la suppression de l'instruction notifiée |
452 |
|
|
*/ |
453 |
|
|
function test_07_TNR_suivi_notification() { |
454 |
|
|
// Instanciation de la classe *om_application* (connexion à l'application) |
455 |
|
|
$f = $this->get_inst_om_application("admin", "admin"); |
456 |
|
|
$f->disableLog(); |
457 |
|
|
|
458 |
|
|
// PARAMÉTRAGE |
459 |
|
|
// Modification d'un événement existant pour autoriser toutes les notifications et donc |
460 |
|
|
// pouvoir afficher tous les suivis |
461 |
|
|
$f->execute_db_query( |
462 |
|
|
sprintf( |
463 |
|
|
"UPDATE %1\$sevenement |
464 |
|
|
SET (notification_service, notification, notification_tiers) = (true, 'notification_automatique', 'notification_manuelle') |
465 |
|
|
WHERE evenement = 89", |
466 |
|
|
DB_PREFIXE |
467 |
|
|
), |
468 |
|
|
array( |
469 |
|
|
'origin' => __METHOD__ |
470 |
|
|
) |
471 |
|
|
); |
472 |
|
|
// Ajout d'une instruction, lié à l'événement modifié précedemment, sur un dossier existant. |
473 |
|
|
$instruction = $f->get_inst__om_dbform(array( |
474 |
|
|
"obj" => "instruction", |
475 |
|
|
"idx" => "]" |
476 |
|
|
)); |
477 |
|
|
$val = array_combine($instruction->champs, $instruction->val); |
478 |
|
|
$dossier = 'PC0130551200001P0'; |
479 |
|
|
$val['dossier'] = $dossier; |
480 |
|
|
$val['evenement'] = '89'; |
481 |
|
|
$val['date_evenement'] = date('Y-m-d'); |
482 |
|
|
$res = $instruction->ajouter($val); |
483 |
|
|
$this->assertEquals($res, true); |
484 |
|
|
|
485 |
|
|
// Ajout d'un notification de demandeur, sans tâche associée, sur cette instruction |
486 |
|
|
$instruction_notification = $f->get_inst__om_dbform(array( |
487 |
|
|
"obj" => "instruction_notification", |
488 |
|
|
"idx" => "]", |
489 |
|
|
)); |
490 |
|
|
$val = array( |
491 |
|
|
'instruction_notification' => null, |
492 |
|
|
'instruction' => $instruction->getVal($instruction->clePrimaire), |
493 |
|
|
'automatique' => false, |
494 |
|
|
'emetteur' => 'PHP UNIT', |
495 |
|
|
'date_envoi' => date("Y-m-d"), |
496 |
|
|
'destinataire' => '[email protected]', |
497 |
|
|
'date_premier_acces' => null, |
498 |
|
|
'statut' => 'envoyé', |
499 |
|
|
'commentaire' => null, |
500 |
|
|
'courriel' => '[email protected]' |
501 |
|
|
); |
502 |
|
|
$res = $instruction_notification->ajouter($val); |
503 |
|
|
$this->assertEquals($res, true); |
504 |
|
|
|
505 |
|
|
// Création d'une tâche ayant un object_id de même valeur que l'id de la notification |
506 |
|
|
// mais n'étant pas lié à la notification |
507 |
|
|
$task = $f->get_inst__om_dbform(array( |
508 |
|
|
"obj" => "task", |
509 |
|
|
"idx" => 0, |
510 |
|
|
)); |
511 |
|
|
$res = $task->add_task(array('val' => array( |
512 |
|
|
'stream' => 'input', |
513 |
|
|
'json_payload' => json_encode( |
514 |
|
|
array( |
515 |
|
|
'external_uids' => array( |
516 |
|
|
'dossier' => 'TST_PHP_UNIT' |
517 |
|
|
) |
518 |
|
|
) |
519 |
|
|
), |
520 |
softime |
18436 |
'type' => 'PHPUNIT_TST07', |
521 |
softime |
15650 |
'category' => 'platau', |
522 |
|
|
'object_id' => $instruction_notification->getVal($instruction_notification->clePrimaire) |
523 |
|
|
))); |
524 |
|
|
$this->assertEquals($res, true); |
525 |
|
|
|
526 |
|
|
// TEST |
527 |
|
|
// 1- Vérifie qu'il n'y a que le suivi des notifications des demandeurs qui est affiché |
528 |
|
|
$this->assertTrue($instruction->can_display_notification_demandeur()); |
529 |
|
|
$this->assertFalse($instruction->can_display_notification_service()); |
530 |
|
|
$this->assertFalse($instruction->can_display_notification_tiers()); |
531 |
|
|
$this->assertFalse($instruction->can_display_notification_commune()); |
532 |
|
|
// 2- Vérifie que le suivi de notification des demandeurs contiens bien la notification sans tâche |
533 |
|
|
$this->assertStringContainsString('[email protected]', $instruction->get_json_suivi_notification( |
534 |
|
|
array( |
535 |
|
|
'notification_recepisse', |
536 |
|
|
'notification_instruction', |
537 |
|
|
'notification_decision', |
538 |
|
|
), |
539 |
|
|
true |
540 |
|
|
)); |
541 |
|
|
// 3- Vérifie que l'instruction peut être supprimée |
542 |
softime |
18436 |
// XXX - Solution temporaire : la propriété val à une entrée instruction en fin de tableau. |
543 |
|
|
// val et champs devrait avoir le même nombre d'entrée. En attendant qu'une correction |
544 |
|
|
// soit faite on retire l'entrée à la main |
545 |
|
|
if (! empty($instruction->val['instruction'])) { |
546 |
|
|
unset($instruction->val['instruction']); |
547 |
|
|
} |
548 |
softime |
15650 |
$val = array_combine($instruction->champs, $instruction->val); |
549 |
|
|
$instruction->parameters['idxformulaire'] = $dossier; |
550 |
|
|
$res = $instruction->supprimer($val); |
551 |
|
|
$this->assertNotEquals(false, $res); |
552 |
|
|
|
553 |
|
|
// RÉTABLISSEMENT DU PARAMÉTRAGE |
554 |
softime |
18436 |
// XXX - Solution temporaire : la propriété val à une entrée task en début de tableau. |
555 |
|
|
// val et champs devrait avoir le même nombre d'entrée. En attendant qu'une correction |
556 |
|
|
// soit faite on retire l'entrée à la main |
557 |
|
|
if (! empty($task->val['task'])) { |
558 |
|
|
unset($task->val['task']); |
559 |
|
|
} |
560 |
softime |
15650 |
// Suppression de la tâche |
561 |
|
|
$this->assertEquals($task->supprimer(array_combine($task->champs, $task->val)), true); |
562 |
|
|
// Réinitilisation de l'évènement |
563 |
|
|
$f->execute_db_query( |
564 |
|
|
sprintf( |
565 |
|
|
"UPDATE %1\$sevenement |
566 |
|
|
SET (notification_service, notification, notification_tiers) = (false, null, null) |
567 |
|
|
WHERE evenement = 89", |
568 |
|
|
DB_PREFIXE |
569 |
|
|
), |
570 |
|
|
array( |
571 |
|
|
'origin' => __METHOD__ |
572 |
|
|
) |
573 |
|
|
); |
574 |
|
|
// Destruction de la classe *om_application* |
575 |
|
|
$f->__destruct(); |
576 |
|
|
} |
577 |
softime |
15835 |
|
578 |
|
|
/** |
579 |
|
|
* TNR : taxe_amenagement::compute_ta() |
580 |
|
|
* |
581 |
|
|
* Description : |
582 |
|
|
* - Case 1 : if the required values are null the method should return null |
583 |
|
|
* - Case 3 : if the required values are empty the method should return null |
584 |
|
|
* - Case 4 : if the required values are set the method should return an array even |
585 |
|
|
* if the other values are empty |
586 |
|
|
*/ |
587 |
|
|
function test_08_taxe_amenagement_compute_ta() { |
588 |
|
|
// PARAMÉTRAGE |
589 |
|
|
|
590 |
|
|
// Instanciation de la classe *om_application* (connexion à l'application) |
591 |
|
|
$f = $this->get_inst_om_application("admin", "admin"); |
592 |
|
|
$f->disableLog(); |
593 |
|
|
|
594 |
|
|
$val_with_null_required_fields = array( |
595 |
|
|
"tax_surf_tot_cstr" => null, |
596 |
|
|
"tax_empl_ten_carav_mobil_nb_cr" => null, |
597 |
|
|
"tax_empl_hll_nb_cr" => null, |
598 |
|
|
"tax_sup_bass_pisc_cr" => null, |
599 |
|
|
"tax_eol_haut_nb_cr" => null, |
600 |
|
|
"tax_pann_volt_sup_cr" => null, |
601 |
|
|
"tax_am_statio_ext_cr" => null |
602 |
|
|
); |
603 |
|
|
|
604 |
|
|
$val_with_empty_values = array( |
605 |
|
|
'tax_surf_tot_cstr' => '', |
606 |
|
|
'tax_empl_ten_carav_mobil_nb_cr' => '', |
607 |
|
|
'tax_empl_hll_nb_cr' => '', |
608 |
|
|
'tax_sup_bass_pisc_cr' => '', |
609 |
|
|
'tax_eol_haut_nb_cr' => '', |
610 |
|
|
'tax_pann_volt_sup_cr' => '', |
611 |
|
|
'tax_am_statio_ext_cr' => '', |
612 |
|
|
'tx_comm_secteur_plop' => '', |
613 |
|
|
'tx_depart' => '', |
614 |
|
|
'tx_reg' => '', |
615 |
|
|
'tax_su_princ_surf1' => '', |
616 |
|
|
'tax_su_princ_surf2' => '', |
617 |
|
|
'tax_su_non_habit_surf2' => '', |
618 |
|
|
'tax_su_heber_surf3' => '', |
619 |
|
|
'tax_su_princ_surf3' => '', |
620 |
|
|
'tax_su_non_habit_surf3' => '', |
621 |
|
|
'tax_su_heber_surf3' => '', |
622 |
|
|
'tax_su_princ_surf4' => '', |
623 |
|
|
'tax_su_non_habit_surf4' => '', |
624 |
|
|
'tax_su_parc_statio_expl_comm_surf' => '', |
625 |
|
|
'mtn_exo_ta_part_commu' => '', |
626 |
|
|
'mtn_exo_ta_part_depart' => '', |
627 |
|
|
'mtn_exo_ta_part_reg' => '', |
628 |
|
|
); |
629 |
|
|
|
630 |
|
|
$taxe_amenagement = $f->get_inst__om_dbform(array( |
631 |
|
|
"obj" => "taxe_amenagement", |
632 |
|
|
"idx" => "]", |
633 |
|
|
)); |
634 |
|
|
|
635 |
|
|
// TEST |
636 |
|
|
// Case 1 |
637 |
|
|
$this->assertEquals(null, $taxe_amenagement->compute_ta('plop', $val_with_null_required_fields)); |
638 |
|
|
// Case 2 |
639 |
|
|
$this->assertEquals(null, $taxe_amenagement->compute_ta('plop', $val_with_empty_values)); |
640 |
|
|
|
641 |
|
|
$val_with_empty_values['tax_surf_tot_cstr'] = 1; |
642 |
|
|
$val_with_empty_values['tax_empl_ten_carav_mobil_nb_cr'] = 1; |
643 |
|
|
$val_with_empty_values['tax_empl_hll_nb_cr'] = 1; |
644 |
|
|
$val_with_empty_values['tax_sup_bass_pisc_cr'] = 1; |
645 |
|
|
$val_with_empty_values['tax_eol_haut_nb_cr'] = 1; |
646 |
|
|
$val_with_empty_values['tax_pann_volt_sup_cr'] = 1; |
647 |
|
|
$val_with_empty_values['tax_am_statio_ext_cr'] = 1; |
648 |
|
|
// Case 3 |
649 |
|
|
$this->assertTrue(is_array($taxe_amenagement->compute_ta('plop', $val_with_empty_values))); |
650 |
|
|
|
651 |
|
|
// RÉTABLISSEMENT DU PARAMÉTRAGE |
652 |
|
|
$f->__destruct(); |
653 |
|
|
} |
654 |
|
|
|
655 |
|
|
/** |
656 |
|
|
* TNR : taxe_amenagement::compute_rap() |
657 |
|
|
* |
658 |
|
|
* Description : |
659 |
|
|
* - Case 1 : if the required "terr_rap" values are null the method should return null |
660 |
|
|
* - Case 2 : if the required "cn_ta_rap" values are null the method should return null |
661 |
|
|
* - Case 3 : if the required values are empty the method should return null |
662 |
|
|
* - Case 4 : if the required values are set the method should return an array even |
663 |
|
|
* if the other values are empty |
664 |
|
|
*/ |
665 |
|
|
function test_09_taxe_amenagement_compute_rap() { |
666 |
|
|
// PARAMÉTRAGE |
667 |
|
|
|
668 |
|
|
// Instanciation de la classe *om_application* (connexion à l'application) |
669 |
|
|
$f = $this->get_inst_om_application("admin", "admin"); |
670 |
|
|
$f->disableLog(); |
671 |
|
|
|
672 |
|
|
$val_with_null_terr_rap_required_fields = array( |
673 |
|
|
"tax_terrassement_arch" => null |
674 |
|
|
); |
675 |
|
|
|
676 |
|
|
$val_with_null_cn_ta_rap_required_fields = array( |
677 |
|
|
"tax_terrassement_arch" => 'Oui', |
678 |
|
|
"tax_surf_tot_cstr" => null, |
679 |
|
|
"tax_empl_ten_carav_mobil_nb_cr" => null, |
680 |
|
|
"tax_empl_hll_nb_cr" => null, |
681 |
|
|
"tax_sup_bass_pisc_cr" => null, |
682 |
|
|
"tax_eol_haut_nb_cr" => null, |
683 |
|
|
"tax_pann_volt_sup_cr" => null, |
684 |
|
|
"tax_am_statio_ext_cr" => null |
685 |
|
|
); |
686 |
|
|
|
687 |
|
|
$val_with_empty_values = array( |
688 |
|
|
"tax_terrassement_arch" => '', |
689 |
|
|
'tax_surf_tot_cstr' => '', |
690 |
|
|
'tax_empl_ten_carav_mobil_nb_cr' => '', |
691 |
|
|
'tax_empl_hll_nb_cr' => '', |
692 |
|
|
'tax_sup_bass_pisc_cr' => '', |
693 |
|
|
'tax_eol_haut_nb_cr' => '', |
694 |
|
|
'tax_pann_volt_sup_cr' => '', |
695 |
|
|
'tax_am_statio_ext_cr' => '', |
696 |
|
|
'tx_comm_secteur_plop' => '', |
697 |
|
|
'tx_depart' => '', |
698 |
|
|
'tx_reg' => '', |
699 |
|
|
'tax_su_princ_surf1' => '', |
700 |
|
|
'tax_su_princ_surf2' => '', |
701 |
|
|
'tax_su_non_habit_surf2' => '', |
702 |
|
|
'tax_su_heber_surf3' => '', |
703 |
|
|
'tax_su_princ_surf3' => '', |
704 |
|
|
'tax_su_non_habit_surf3' => '', |
705 |
|
|
'tax_su_heber_surf3' => '', |
706 |
|
|
'tax_su_princ_surf4' => '', |
707 |
|
|
'tax_su_non_habit_surf4' => '', |
708 |
|
|
'tax_su_parc_statio_expl_comm_surf' => '', |
709 |
|
|
'mtn_exo_rap' => '', |
710 |
|
|
); |
711 |
|
|
|
712 |
|
|
$taxe_amenagement = $f->get_inst__om_dbform(array( |
713 |
|
|
"obj" => "taxe_amenagement", |
714 |
|
|
"idx" => "]", |
715 |
|
|
)); |
716 |
|
|
$val = array( |
717 |
|
|
'val_forf_surf_cstr' => 1, |
718 |
|
|
'val_forf_empl_tente_carav_rml' => 1, |
719 |
|
|
'val_forf_empl_hll' => 1, |
720 |
|
|
'val_forf_surf_piscine' => 1, |
721 |
|
|
'val_forf_nb_eolienne' => 1, |
722 |
|
|
'val_forf_surf_pann_photo' => 1, |
723 |
|
|
'val_forf_nb_parking_ext' => 1 |
724 |
|
|
); |
725 |
|
|
// Remplissage des valeurs obligatoirement rempli lors du paramétrage de la taxe |
726 |
|
|
foreach ($val as $key => $value) { |
727 |
|
|
$taxe_amenagement->val[array_search($key, $taxe_amenagement->champs)] = $value; |
728 |
|
|
} |
729 |
|
|
|
730 |
|
|
// TEST |
731 |
|
|
// Case 1 |
732 |
|
|
$this->assertEquals(null, $taxe_amenagement->compute_rap($val_with_null_terr_rap_required_fields)); |
733 |
|
|
// Case 2 |
734 |
|
|
$this->assertEquals(null, $taxe_amenagement->compute_rap($val_with_null_cn_ta_rap_required_fields)); |
735 |
|
|
// Case 3 |
736 |
|
|
$this->assertEquals(null, $taxe_amenagement->compute_rap($val_with_empty_values)); |
737 |
|
|
|
738 |
|
|
$val_with_empty_values['tax_terrassement_arch'] = 'Oui'; |
739 |
|
|
$val_with_empty_values['tax_surf_tot_cstr'] = 1; |
740 |
|
|
$val_with_empty_values['tax_empl_ten_carav_mobil_nb_cr'] = 1; |
741 |
|
|
$val_with_empty_values['tax_empl_hll_nb_cr'] = 1; |
742 |
|
|
$val_with_empty_values['tax_sup_bass_pisc_cr'] = 1; |
743 |
|
|
$val_with_empty_values['tax_eol_haut_nb_cr'] = 1; |
744 |
|
|
$val_with_empty_values['tax_pann_volt_sup_cr'] = 1; |
745 |
|
|
$val_with_empty_values['tax_am_statio_ext_cr'] = 1; |
746 |
|
|
// Case 4 |
747 |
|
|
$this->assertTrue(is_array($taxe_amenagement->compute_rap($val_with_empty_values))); |
748 |
|
|
|
749 |
|
|
// RÉTABLISSEMENT DU PARAMÉTRAGE |
750 |
|
|
$f->__destruct(); |
751 |
|
|
} |
752 |
fmichon |
9227 |
} |