Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 207 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 207 Rev 1141
Line 1... Line 1...
1
<?php
1
<?php
2
require_once dirname(__FILE__).'/../ConsultationEflorePhpUnit.php';
2
require_once __DIR__ . '/../ConsultationEflorePhpUnit.php';
Line 3... Line 3...
3
 
3
 
Line -... Line 4...
-
 
4
class RechercheTest extends ConsultationEflorePhpUnit {
-
 
5
 
-
 
6
	/**
4
class RechercheTest extends ConsultationEflorePhpUnit {
7
	 * @backupGlobals # avoid $_REQUEST leaks
5
 
8
	 */
6
	public function testExecuterRechercheSimple() {
9
	public function testExecuterRechercheSimple() {
Line 7... Line 10...
7
		$_GET['type_nom'] = 'nom_scientifique';
10
		$_REQUEST['type_nom'] = 'nom_scientifique';
8
		$_GET['nom'] = 'acer mons';
11
		$_REQUEST['nom'] = 'acer mons';
9
 
12
 
10
		Registre::set('niveau', '1');
13
		Registre::set('parametres.niveau', '1');
11
		$cheminRacine = realpath(dirname(__FILE__).'/../configurations/').'/';
14
		$cheminRacine = realpath(__DIR__ . '/../../configurations/').'/';
Line 12... Line 15...
12
		Config::charger($cheminRacine.'bdtfx.ini');
15
		Config::charger($cheminRacine.'bdtfx.ini');
13
		Registre::set('eFlore.urlBase', new Url(Config::get('base_url_application_index')));
16
		Registre::set('eFlore.urlBase', new Url(Config::get('base_url_application_index')));
14
		Registre::set('parametres.referentiel', 'bdtfx');
17
		Registre::set('parametres.referentiel', 'bdtfx');
Line 15... Line -...
15
 
-
 
16
		$recherche = new Recherche();
18
 
-
 
19
		$recherche = new Recherche();
17
		$recherche->initialiser();
20
		$recherche->initialiser();
18
		$recherche->executerRechercheSimple();
-
 
19
 
21
		$recherche->executerRechercheSimple();
20
		$donnees = Registre::get('donneesMoteur');
22
 
21
		$resultat = Registre::get('resultats');
23
		$resultat = Registre::get('resultats');
22
		$sortie = implode('', $recherche->getSortie());
24
 
23
		$this->assertEmpty($donnees, print_r($donnees, true));
25
		$sortie = implode('', $recherche->getSortie());
24
		$this->assertNotEmpty($resultat, print_r($resultat, true));
26
		$this->assertNotEmpty($resultat);
25
		$this->assertEquals('6', $resultat['entete']['total']);
27
		$this->assertEquals('6', $resultat['entete']['total']);
26
		$this->assertEquals('6', count($resultat['resultat']));
28
		$this->assertEquals('6', count($resultat['resultat']));
Line -... Line 29...
-
 
29
		$this->assertArrayNotHasKey('auteur', $resultat['resultat']['182'], print_r($resultat, true));
-
 
30
		$this->assertNotEmpty($sortie);
-
 
31
		$this->assertContains('<input id="nom" name="nom" class="champ" size="30" maxlength="255" type="text" value="acer mons" />', $sortie);
27
		$this->assertArrayNotHasKey('auteur', $resultat['resultat']['182'], print_r($resultat, true));
32
		$this->assertContains('<strong class="nom-sci-retenu"><span class="surlignage">Acer</span> <span class="surlignage">mons</span>pessulanum</strong>', $sortie);
28
		$this->assertNotEmpty($sortie, print_r($sortie, true));
33
	}
29
		$this->assertContains('<input id="nom" name="nom" class="champ" size="30" maxlength="255" type="text" autocomplete="off" value="acer mons" />', $sortie);
34
 
30
		$this->assertContains('<strong class="nom-sci-retenu"><span class="surlignage">Acer</span> <span class="surlignage">mons</span>pessulanum</strong>', $sortie);
35
	/**
Line 31... Line 36...
31
	}
36
	 * @backupGlobals # avoid $_REQUEST leaks
32
	
37
	 */
33
	public function testExecuterRechercheSimpleAlphab() {
38
	public function testExecuterRechercheSimpleAlphab() {
34
		$_GET['type_nom'] = 'nom_scientifique';
39
		$_REQUEST['type_nom'] = 'nom_scientifique';
Line -... Line 40...
-
 
40
		$_REQUEST['nom'] = 'acer mons';
-
 
41
		$_REQUEST['resultat'] = 'alphab';
-
 
42
 
-
 
43
		$cheminRacine = realpath(__DIR__ . '/../../configurations/') . '/';
-
 
44
		Config::charger($cheminRacine.'bdtfx.ini');
-
 
45
		Registre::set('eFlore.urlBase', new Url(Config::get('base_url_application_index')));
-
 
46
		Registre::set('parametres.referentiel', 'bdtfx');
-
 
47
 
35
		$_GET['nom'] = 'acer mons';
48
		// initialise les valeurs par défaut (notamment de "niveau")
36
		$_GET['resultat'] = 'alphab';
49
		AppControleur::verifierCreationInstance();
37
		
50
		// initialise le registre à partir des valeurs par défaut
Line 38... Line -...
38
		$cheminRacine = realpath(dirname(__FILE__).'/../configurations/').'/';
-
 
39
		Config::charger($cheminRacine.'bdtfx.ini');
51
		AppControleur::initialiserRegistre();
40
		Registre::set('eFlore.urlBase', new Url(Config::get('base_url_application_index')));
52
		// à partir de là, par exemple Registre::get('parametres.niveau') doit retourner un entier
41
		Registre::set('parametres.referentiel', 'bdtfx');
-
 
42
		
53
		// (alternative à Registre::set('niveau', 'X'))
43
		$recherche = new Recherche();
54
 
44
		$recherche->initialiser();
55
		// et la recherche ne risque plus de manquer des paramètres nécessaires
45
		$recherche->executerRechercheSimple();
56
		$recherche = new Recherche();
Line -... Line 57...
-
 
57
		$recherche->initialiser();
-
 
58
		$recherche->executerRechercheSimple();
-
 
59
		
46
		
60
		$resultat = Registre::get('resultats');
47
		$donnees = Registre::get('donneesMoteur');
61
		$sortie = implode('', $recherche->getSortie());
48
		$resultat = Registre::get('resultats');
62
		$this->assertNotEmpty($resultat, $resultat);
49
		$sortie = implode('', $recherche->getSortie());
63
		$this->assertEquals('6', $resultat['entete']['total']);
-
 
64
		$this->assertEquals('6', count($resultat['resultat']));
Line -... Line 65...
-
 
65
	}
50
		$this->assertEmpty($donnees, print_r($donnees, true));
66
	
51
		$this->assertNotEmpty($resultat, print_r($resultat, true));
67
	/**
52
		$this->assertEquals('6', $resultat['entete']['total']);
68
	 * @backupGlobals # avoid $_REQUEST leaks
53
		$this->assertEquals('6', count($resultat['resultat']));
69
	 */
Line 54... Line 70...
54
	}
70
	public function testExecuterRechercheSimpleRetenu() {
55
	
71
		$_REQUEST['type_nom'] = 'nom_scientifique';
56
	public function testExecuterRechercheSimpleRetenu() {
72
		$_REQUEST['nom'] = 'acer mons';
Line 57... Line -...
57
		$_GET['type_nom'] = 'nom_scientifique';
-
 
58
		$_GET['nom'] = 'acer mons';
73
		$_REQUEST['resultat'] = 'retenu';
59
		$_GET['resultat'] = 'retenu';
74
		$_REQUEST['niveau'] = 2;
60
	
-
 
61
		$cheminRacine = realpath(dirname(__FILE__).'/../configurations/').'/';
75
 
62
		Config::charger($cheminRacine.'bdtfx.ini');
76
		Registre::set('parametres.niveau', '2');
63
		Registre::set('eFlore.urlBase', new Url(Config::get('base_url_application_index')));
77
		$cheminRacine = realpath(__DIR__ . '/../../configurations/').'/';
64
		Registre::set('parametres.referentiel', 'bdtfx');
78
		Config::charger($cheminRacine.'bdtfx.ini');
Line -... Line 79...
-
 
79
		Registre::set('eFlore.urlBase', new Url(Config::get('base_url_application_index')));
-
 
80
		Registre::set('parametres.referentiel', 'bdtfx');
-
 
81
 
65
	
82
		$recherche = new Recherche();
66
		$recherche = new Recherche();
83
		$recherche->initialiser();
67
		$recherche->initialiser();
84
		$recherche->executerRechercheSimple();
68
		$recherche->executerRechercheSimple();
85
	
Line -... Line 86...
-
 
86
		$resultat = Registre::get('resultats');
69
	
87
		$sortie = implode('', $recherche->getSortie());
70
		$donnees = Registre::get('donneesMoteur');
88
		$this->assertNotEmpty($resultat);
71
		$resultat = Registre::get('resultats');
89
		$this->assertEquals('6', $resultat['entete']['total']);
72
		$sortie = implode('', $recherche->getSortie());
90
		$this->assertEquals('6', count($resultat['resultat']));
Line 73... Line 91...
73
		$this->assertEmpty($donnees, print_r($donnees, true));
91
	}
74
		$this->assertNotEmpty($resultat, print_r($resultat, true));
92
 
75
		$this->assertEquals('6', $resultat['entete']['total']);
93
	/**
Line 76... Line -...
76
		$this->assertEquals('6', count($resultat['resultat']));
-
 
77
	}
94
	 * @backupGlobals # avoid $_REQUEST leaks
78
	
95
	 */
79
	public function testExecuterRechercheSimpleSynonyme() {
-
 
80
		$_GET['type_nom'] = 'nom_scientifique';
96
	public function testExecuterRechercheSimpleSynonyme() {
81
		$_GET['nom'] = 'acer mons';
97
		$_REQUEST['type_nom'] = 'nom_scientifique';
82
		$_GET['resultat'] = 'retenu';
98
		$_REQUEST['nom'] = 'acer mons';
83
	
99
		$_REQUEST['resultat'] = 'retenu';
84
		$cheminRacine = realpath(dirname(__FILE__).'/../configurations/').'/';
-
 
85
		Config::charger($cheminRacine.'bdtfx.ini');
-
 
86
		Registre::set('eFlore.urlBase', new Url(Config::get('base_url_application_index')));
100
 
87
		Registre::set('parametres.referentiel', 'bdtfx');
101
		Registre::set('parametres.niveau', '2');	
88
	
102
		$cheminRacine = realpath(__DIR__ . '/../../configurations/').'/';