145 |
jpm |
1 |
<?php
|
|
|
2 |
|
158 |
jpm |
3 |
class ResultatFormateurInitialisation extends PHPUnit_Framework_TestCase {
|
145 |
jpm |
4 |
const TPL_URL_FICHE = 'http://localhost/eflore/eflore-consultation/index_botanique.php?referentiel=bdtfx&module=fiche&action=fiche&nn=%s';
|
205 |
delphine |
5 |
const TPL_URL_BASE_DOSSIER = 'http://localhost/eflore-consultation/';
|
|
|
6 |
|
157 |
jpm |
7 |
public static function setUpBeforeClass() {
|
|
|
8 |
error_reporting(E_ALL);
|
|
|
9 |
|
|
|
10 |
// Enregistrement en première position des autoload de la méthode gérant les classes des services
|
|
|
11 |
spl_autoload_register(array(get_class(), 'chargerClasseAuto'));
|
|
|
12 |
}
|
|
|
13 |
|
|
|
14 |
public static function chargerClasseAuto($classe) {
|
158 |
jpm |
15 |
$cheminBase = dirname(__FILE__).'/../../../';
|
157 |
jpm |
16 |
$cheminBiblio = $cheminBase.'bibliotheque/';
|
|
|
17 |
$cheminModule = $cheminBase.'modules/resultat/';
|
|
|
18 |
$cheminModuleFormateurs = $cheminModule.'formateurs/';
|
164 |
jpm |
19 |
$cheminModuleFormateursNs = $cheminModuleFormateurs.'nom_scientifique/';
|
|
|
20 |
$cheminModuleFormateursNv = $cheminModuleFormateurs.'nom_vernaculaire/';
|
|
|
21 |
$chemins = array($cheminBiblio, $cheminModule, $cheminModuleFormateurs,
|
|
|
22 |
$cheminModuleFormateursNs, $cheminModuleFormateursNv);
|
157 |
jpm |
23 |
foreach ($chemins as $chemin) {
|
|
|
24 |
$chemin = $chemin.$classe.'.php';
|
|
|
25 |
if (file_exists($chemin)) {
|
|
|
26 |
require_once $chemin;
|
|
|
27 |
}
|
|
|
28 |
}
|
|
|
29 |
}
|
|
|
30 |
|
145 |
jpm |
31 |
protected function getParametres($type, $masque) {
|
|
|
32 |
$parametres = new ParametresResultats();
|
|
|
33 |
$parametres->type = $type;
|
|
|
34 |
$parametres->masqueRecherche = $masque;
|
|
|
35 |
return $parametres;
|
|
|
36 |
}
|
|
|
37 |
|
|
|
38 |
protected function getResultatsPourMasque($masque) {
|
152 |
jpm |
39 |
$resultatsJson = file_get_contents(dirname(__FILE__).'/resultats.json');
|
|
|
40 |
$resultats = json_decode($resultatsJson, true);
|
145 |
jpm |
41 |
return $resultats[$masque];
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
protected function getSurligneur() {
|
|
|
45 |
$surligneur = new Surligneur();
|
|
|
46 |
return $surligneur;
|
|
|
47 |
}
|
|
|
48 |
|
|
|
49 |
protected function getTrieur() {
|
|
|
50 |
$trieur = new Trieur();
|
|
|
51 |
return $trieur;
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
protected function getAppUrls() {
|
205 |
delphine |
55 |
$AppUrls = $this->getMock('AppUrls', array('obtenirUrlFiche', 'obtenirUrlBaseDossier'), array(), '', false);
|
145 |
jpm |
56 |
$AppUrls->expects($this->any())
|
|
|
57 |
->method('obtenirUrlFiche')
|
|
|
58 |
->will($this->returnCallback(array($this, 'genererUrlFiche')));
|
205 |
delphine |
59 |
$AppUrls->expects($this->any())
|
|
|
60 |
->method('obtenirUrlBaseDossier')
|
|
|
61 |
->will($this->returnCallback(array($this, 'genererUrlBaseDossier')));
|
145 |
jpm |
62 |
return $AppUrls;
|
|
|
63 |
}
|
|
|
64 |
|
|
|
65 |
public function genererUrlFiche($id) {
|
|
|
66 |
return sprintf(self::TPL_URL_FICHE, $id);
|
|
|
67 |
}
|
205 |
delphine |
68 |
|
|
|
69 |
public function genererUrlBaseDossier() {
|
|
|
70 |
return self::TPL_URL_BASE_DOSSIER;
|
|
|
71 |
}
|
145 |
jpm |
72 |
}
|
|
|
73 |
?>
|