248 |
$_SESSION['login'] = "admin"; |
$_SESSION['login'] = "admin"; |
249 |
$_SERVER['REQUEST_URI'] = ""; |
$_SERVER['REQUEST_URI'] = ""; |
250 |
$f = new utils("nohtml"); |
$f = new utils("nohtml"); |
251 |
|
$GLOBALS['f'] = $f; |
252 |
$f->disableLog(); |
$f->disableLog(); |
253 |
|
|
254 |
require_once "../core/om_edition.class.php"; |
$edition = $f->get_inst__om_edition(); |
|
$edition = new edition(); |
|
|
$edition->f = $f; |
|
255 |
// Vérification du logo de collectivité mono dans le cas où : |
// Vérification du logo de collectivité mono dans le cas où : |
256 |
// - un logo multi actif est défini |
// - un logo multi actif est défini |
257 |
// - un logo actif pour la collectivité est défini |
// - un logo actif pour la collectivité est défini |
319 |
// résultat attendu |
// résultat attendu |
320 |
$di = 'PC01'; |
$di = 'PC01'; |
321 |
$inst = 7; |
$inst = 7; |
322 |
$url = 'http://localhost/openads/spg/direct_link.php?obj=dossier_instruction&action=3'; |
$url = 'http://localhost/openads/app/index.php?module=form&direct_link=true&obj=dossier_instruction&action=3'; |
323 |
$url .= '&direct_field=dossier&direct_form=instruction&direct_action=3&direct_idx='.$inst; |
$url .= '&direct_field=dossier&direct_form=instruction&direct_action=3&direct_idx='.$inst; |
324 |
$link = '<a href="'.$url.'">'.$url.'</a>'; |
$link = '<a href="'.$url.'">'.$url.'</a>'; |
325 |
$expected = 'DI : '.$di.'<br/>'; |
$expected = 'DI : '.$di.'<br/>'; |
326 |
$expected .= 'LIEN : '.$link.'<br/>'; |
$expected .= 'LIEN : '.$link.'<br/>'; |
327 |
$expected .= 'INSTRUCTION : '.$inst; |
$expected .= 'INSTRUCTION : '.$inst; |
328 |
// Instance de la classe instruction |
// Instance de la classe instruction |
329 |
require_once "../obj/instruction.class.php"; |
$instr = $f->get_inst__om_dbform(array( |
330 |
$instr = new instruction(']', $f->db, DEBUG); |
"obj" => "instruction", |
331 |
|
"idx" => "]", |
332 |
|
)); |
333 |
// Traitement |
// Traitement |
334 |
$result = $instr->formater_modele($template, $di, $inst); |
$result = $instr->formater_modele($template, $di, $inst); |
335 |
// Vérification du traitement |
// Vérification du traitement |
338 |
$f->__destruct(); |
$f->__destruct(); |
339 |
} |
} |
340 |
|
|
|
/** |
|
|
* Teste la fonction sendMail() de la classe Utils. |
|
|
*/ |
|
|
public function test_04_utils_sendmail() { |
|
|
|
|
|
// Instance de la classe Utils |
|
|
require_once "../obj/utils.class.php"; |
|
|
@session_start(); |
|
|
$_SESSION['collectivite'] = 1; |
|
|
$_SESSION['login'] = "admin"; |
|
|
$_SERVER['REQUEST_URI'] = ""; |
|
|
$f = new utils("nohtml"); |
|
|
$f->disableLog(); |
|
|
|
|
|
// Paramétrage |
|
|
$objet = '[openADS] Test de l\'envoi de mail'; |
|
|
$corps = 'Ne pas répondre.'; |
|
|
$email = '[email protected]'; |
|
|
|
|
|
// Succès |
|
|
$case_1 = $f->sendMail( |
|
|
iconv('UTF-8', 'CP1252', $objet), |
|
|
iconv('UTF-8', 'CP1252', $corps), |
|
|
iconv('UTF-8', 'CP1252', $email)); |
|
|
$this->assertEquals(true, $case_1); |
|
|
|
|
|
// Échec cause email invalide |
|
|
$case_2 = $f->sendMail( |
|
|
iconv('UTF-8', 'CP1252', $objet), |
|
|
iconv('UTF-8', 'CP1252', $corps), |
|
|
iconv('UTF-8', 'CP1252', 'email_incorrect')); |
|
|
$this->assertEquals(false, $case_2); |
|
|
|
|
|
// Échec cause mauvaise configuration du compte mail |
|
|
$file_path = PATH_OPENMAIRIE.'../dyn/mail.inc.php'; |
|
|
$old_file_content = file_get_contents($file_path); |
|
|
$line_password = array(); |
|
|
preg_match_all("/^.*mail_pass.*,$/m", $old_file_content, $line_password); |
|
|
$old_line_password = $line_password[0]; |
|
|
$new_line_password = ' \'mail_pass\' => \'1234\','; |
|
|
$new_file_content = str_replace($old_line_password, $new_line_password, $old_file_content); |
|
|
// Reconfiguration incorrecte pour ce test |
|
|
file_put_contents($file_path, $new_file_content); |
|
|
$f->__destruct(); |
|
|
$f = new utils("nohtml"); |
|
|
$f->disableLog(); |
|
|
// Tentative d'envoi |
|
|
$case_3 = $f->sendMail( |
|
|
iconv('UTF-8', 'CP1252', $objet), |
|
|
iconv('UTF-8', 'CP1252', $corps), |
|
|
iconv('UTF-8', 'CP1252', $email)); |
|
|
// Reconfiguration valide pour la suite des tests |
|
|
file_put_contents($file_path, $old_file_content); |
|
|
$f->__destruct(); |
|
|
$f = new utils("nohtml"); |
|
|
$f->disableLog(); |
|
|
// Vérification |
|
|
$this->assertEquals(false, $case_3); |
|
|
// Destruction de la classe Utils |
|
|
$f->__destruct(); |
|
|
} |
|
341 |
|
|
342 |
/** |
/** |
343 |
* TNR du bug de champs de fusion [*_correspondant] dans la om_requete n°7 "dossier". |
* TNR du bug de champs de fusion [*_correspondant] dans la om_requete n°7 "dossier". |
355 |
$f->disableLog(); |
$f->disableLog(); |
356 |
$GLOBALS["f"] = $f; |
$GLOBALS["f"] = $f; |
357 |
|
|
358 |
require_once "../obj/om_requete.class.php"; |
$om_requete = $f->get_inst__om_dbform(array( |
359 |
$om_requete = new om_requete(7); |
"obj" => "om_requete", |
360 |
|
"idx" => 7, |
361 |
|
)); |
362 |
|
|
363 |
// récupération de la requête SQL |
// récupération de la requête SQL |
364 |
$sql = $om_requete->getVal('requete'); |
$sql = $om_requete->getVal('requete'); |
394 |
$f = new utils("nohtml"); |
$f = new utils("nohtml"); |
395 |
$f->disableLog(); |
$f->disableLog(); |
396 |
$GLOBALS["f"] = $f; |
$GLOBALS["f"] = $f; |
397 |
require_once "../obj/dossier_message.class.php"; |
$dossier_message_factory = $f->get_inst__om_dbform(array( |
398 |
$dossier_message_factory = new dossier_message(0, $f->db, 0); |
"obj" => "dossier_message", |
399 |
|
"idx" => 0, |
400 |
|
)); |
401 |
$dossier_message_val = array(); |
$dossier_message_val = array(); |
402 |
|
|
403 |
$dossier_message_val['contenu'] = 'Test Success'; |
$dossier_message_val['contenu'] = 'Test Success'; |
409 |
$add = $dossier_message_factory->add_notification_message($dossier_message_val); |
$add = $dossier_message_factory->add_notification_message($dossier_message_val); |
410 |
$this->assertEquals(true, $add); |
$this->assertEquals(true, $add); |
411 |
$this->assertEquals(true, isset($dossier_message_factory->valF[$dossier_message_factory->clePrimaire])); |
$this->assertEquals(true, isset($dossier_message_factory->valF[$dossier_message_factory->clePrimaire])); |
412 |
$dossier_message = new dossier_message($dossier_message_factory->valF[$dossier_message_factory->clePrimaire], $f->db, 0); |
$dossier_message = $f->get_inst__om_dbform(array( |
413 |
|
"obj" => "dossier_message", |
414 |
|
"idx" => $dossier_message_factory->valF[$dossier_message_factory->clePrimaire], |
415 |
|
)); |
416 |
$this->assertEquals($dossier_message_val['dossier'], $dossier_message->getVal('dossier')); |
$this->assertEquals($dossier_message_val['dossier'], $dossier_message->getVal('dossier')); |
417 |
$this->assertEquals('t', $dossier_message->getVal('lu')); |
$this->assertEquals('t', $dossier_message->getVal('lu')); |
418 |
|
|
431 |
$dossier_message_val['login'] = $_SESSION['login']; |
$dossier_message_val['login'] = $_SESSION['login']; |
432 |
$add = $dossier_message_factory->add_notification_message($dossier_message_val); |
$add = $dossier_message_factory->add_notification_message($dossier_message_val); |
433 |
$this->assertEquals(true, $add); |
$this->assertEquals(true, $add); |
434 |
$dossier_message = new dossier_message($dossier_message_factory->valF[$dossier_message_factory->clePrimaire], $f->db, 0); |
$dossier_message = $f->get_inst__om_dbform(array( |
435 |
|
"obj" => "dossier_message", |
436 |
|
"idx" => $dossier_message_factory->valF[$dossier_message_factory->clePrimaire], |
437 |
|
)); |
438 |
$this->assertEquals('f', $dossier_message->getVal('lu')); |
$this->assertEquals('f', $dossier_message->getVal('lu')); |
439 |
|
|
440 |
// Destruction de la classe Utils |
// Destruction de la classe Utils |