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