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