153 |
jpm |
1 |
<?php
|
158 |
jpm |
2 |
include_once dirname(__FILE__).'/../ResultatFormateurInitialisation.php';
|
153 |
jpm |
3 |
|
158 |
jpm |
4 |
class DecompoFormateurTest extends ResultatFormateurInitialisation {
|
153 |
jpm |
5 |
|
|
|
6 |
public function testerFormater() {
|
|
|
7 |
$formateur = $this->initialiserDecompoFormateur();
|
|
|
8 |
|
|
|
9 |
$formateur->formater();
|
|
|
10 |
$infos = $formateur->getTplInfos();
|
|
|
11 |
|
|
|
12 |
$this->assertArrayHasKey('noms', $infos, print_r($infos, true));
|
|
|
13 |
foreach ($infos['noms'] as $id => $nom) {
|
|
|
14 |
$this->assertTrue(is_int($id), "L'id '$id' doit ĂȘtre un nombre entier.");
|
|
|
15 |
$this->assertCount(8, $nom);
|
|
|
16 |
$this->assertArrayHasKey('nomSci', $nom, print_r($infos, true));
|
|
|
17 |
$this->assertFalse(empty($nom['nomSci']), print_r($infos, true));
|
|
|
18 |
$this->assertArrayHasKey('retenu', $nom, print_r($infos, true));
|
|
|
19 |
$this->assertArrayHasKey('auteur', $nom, print_r($infos, true));
|
|
|
20 |
$this->assertArrayHasKey('annee', $nom, print_r($infos, true));
|
|
|
21 |
$this->assertArrayHasKey('biblio', $nom, print_r($infos, true));
|
|
|
22 |
$this->assertArrayHasKey('addendum', $nom, print_r($infos, true));
|
|
|
23 |
$this->assertArrayHasKey('nn', $nom, print_r($infos, true));
|
|
|
24 |
$this->assertTrue(is_int($nom['nn']), "nn '{$nom['nn']}' doit ĂȘtre un nombre entier.");
|
|
|
25 |
$this->assertArrayHasKey('urlFiche', $nom, print_r($infos, true));
|
1149 |
raphael |
26 |
$urlFicheAttendue = sprintf(ConsultationEflorePhpUnit::TPL_URL_FICHE, $id);
|
153 |
jpm |
27 |
$this->assertEquals($urlFicheAttendue, $nom['urlFiche'], print_r($infos, true));
|
|
|
28 |
}
|
|
|
29 |
}
|
|
|
30 |
|
|
|
31 |
public function testerTrier() {
|
|
|
32 |
$formateur = $this->initialiserDecompoFormateur();
|
|
|
33 |
|
|
|
34 |
$formateur->formater();
|
|
|
35 |
$formateur->trier();
|
|
|
36 |
$infos = $formateur->getTplInfos();
|
|
|
37 |
|
|
|
38 |
$this->assertArrayHasKey('noms', $infos, print_r($infos, true));
|
|
|
39 |
$ordreClesAttendu = array(86402, 25024, 25025, 75113, 103076, 25026, 25027, 25028);
|
|
|
40 |
$ordreClesTriees = array_keys($infos['noms']);
|
|
|
41 |
$this->assertEquals($ordreClesAttendu, $ordreClesTriees, print_r($ordreClesTriees, true));
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
public function testerSurligner() {
|
|
|
45 |
$formateur = $this->initialiserDecompoFormateur();
|
|
|
46 |
|
|
|
47 |
$formateur->formater();
|
|
|
48 |
$formateur->surligner();
|
|
|
49 |
$infos = $formateur->getTplInfos();
|
|
|
50 |
|
|
|
51 |
$this->assertArrayHasKey('noms', $infos, print_r($infos, true));
|
|
|
52 |
foreach ($infos['noms'] as $id => $nom) {
|
|
|
53 |
$this->assertArrayHasKey($id, $infos['noms'], print_r($infos, true));
|
|
|
54 |
$this->assertArrayHasKey('nomSci', $infos['noms'][$id], print_r($infos, true));
|
|
|
55 |
$this->assertContains('<span class="surlignage">Eritrichium</span>', $infos['noms'][$id]['nomSci'], print_r($infos, true));
|
|
|
56 |
}
|
|
|
57 |
}
|
|
|
58 |
|
|
|
59 |
private function initialiserDecompoFormateur($masque = 'eritrichium') {
|
|
|
60 |
$parametres = $this->getParametres('decompo', $masque);
|
|
|
61 |
$resultats = $this->getResultatsPourMasque($masque);
|
|
|
62 |
$surligneur = $this->getSurligneur();
|
|
|
63 |
$trieur = $this->getTrieur();
|
|
|
64 |
$appsUrls = $this->getAppUrls();
|
|
|
65 |
return new DecompoFormateur($parametres, $resultats, $surligneur, $trieur, $appsUrls);
|
|
|
66 |
}
|
|
|
67 |
}
|
|
|
68 |
?>
|