Subversion Repositories eFlore/Applications.eflore-consultation

Compare Revisions

Ignore whitespace Rev 1140 → Rev 1141

/trunk/tests/modules/RechercheTest.php
1,14 → 1,17
<?php
require_once dirname(__FILE__).'/../ConsultationEflorePhpUnit.php';
require_once __DIR__ . '/../ConsultationEflorePhpUnit.php';
 
class RechercheTest extends ConsultationEflorePhpUnit {
 
/**
* @backupGlobals # avoid $_REQUEST leaks
*/
public function testExecuterRechercheSimple() {
$_GET['type_nom'] = 'nom_scientifique';
$_GET['nom'] = 'acer mons';
$_REQUEST['type_nom'] = 'nom_scientifique';
$_REQUEST['nom'] = 'acer mons';
 
Registre::set('niveau', '1');
$cheminRacine = realpath(dirname(__FILE__).'/../configurations/').'/';
Registre::set('parametres.niveau', '1');
$cheminRacine = realpath(__DIR__ . '/../../configurations/').'/';
Config::charger($cheminRacine.'bdtfx.ini');
Registre::set('eFlore.urlBase', new Url(Config::get('base_url_application_index')));
Registre::set('parametres.referentiel', 'bdtfx');
17,71 → 20,86
$recherche->initialiser();
$recherche->executerRechercheSimple();
 
$donnees = Registre::get('donneesMoteur');
$resultat = Registre::get('resultats');
 
$sortie = implode('', $recherche->getSortie());
$this->assertEmpty($donnees, print_r($donnees, true));
$this->assertNotEmpty($resultat, print_r($resultat, true));
$this->assertNotEmpty($resultat);
$this->assertEquals('6', $resultat['entete']['total']);
$this->assertEquals('6', count($resultat['resultat']));
$this->assertArrayNotHasKey('auteur', $resultat['resultat']['182'], print_r($resultat, true));
$this->assertNotEmpty($sortie, print_r($sortie, true));
$this->assertContains('<input id="nom" name="nom" class="champ" size="30" maxlength="255" type="text" autocomplete="off" value="acer mons" />', $sortie);
$this->assertNotEmpty($sortie);
$this->assertContains('<input id="nom" name="nom" class="champ" size="30" maxlength="255" type="text" value="acer mons" />', $sortie);
$this->assertContains('<strong class="nom-sci-retenu"><span class="surlignage">Acer</span> <span class="surlignage">mons</span>pessulanum</strong>', $sortie);
}
 
/**
* @backupGlobals # avoid $_REQUEST leaks
*/
public function testExecuterRechercheSimpleAlphab() {
$_GET['type_nom'] = 'nom_scientifique';
$_GET['nom'] = 'acer mons';
$_GET['resultat'] = 'alphab';
$cheminRacine = realpath(dirname(__FILE__).'/../configurations/').'/';
$_REQUEST['type_nom'] = 'nom_scientifique';
$_REQUEST['nom'] = 'acer mons';
$_REQUEST['resultat'] = 'alphab';
 
$cheminRacine = realpath(__DIR__ . '/../../configurations/') . '/';
Config::charger($cheminRacine.'bdtfx.ini');
Registre::set('eFlore.urlBase', new Url(Config::get('base_url_application_index')));
Registre::set('parametres.referentiel', 'bdtfx');
 
// initialise les valeurs par défaut (notamment de "niveau")
AppControleur::verifierCreationInstance();
// initialise le registre à partir des valeurs par défaut
AppControleur::initialiserRegistre();
// à partir de là, par exemple Registre::get('parametres.niveau') doit retourner un entier
// (alternative à Registre::set('niveau', 'X'))
 
// et la recherche ne risque plus de manquer des paramètres nécessaires
$recherche = new Recherche();
$recherche->initialiser();
$recherche->executerRechercheSimple();
$donnees = Registre::get('donneesMoteur');
$resultat = Registre::get('resultats');
$sortie = implode('', $recherche->getSortie());
$this->assertEmpty($donnees, print_r($donnees, true));
$this->assertNotEmpty($resultat, print_r($resultat, true));
$this->assertNotEmpty($resultat, $resultat);
$this->assertEquals('6', $resultat['entete']['total']);
$this->assertEquals('6', count($resultat['resultat']));
}
/**
* @backupGlobals # avoid $_REQUEST leaks
*/
public function testExecuterRechercheSimpleRetenu() {
$_GET['type_nom'] = 'nom_scientifique';
$_GET['nom'] = 'acer mons';
$_GET['resultat'] = 'retenu';
$cheminRacine = realpath(dirname(__FILE__).'/../configurations/').'/';
$_REQUEST['type_nom'] = 'nom_scientifique';
$_REQUEST['nom'] = 'acer mons';
$_REQUEST['resultat'] = 'retenu';
$_REQUEST['niveau'] = 2;
 
Registre::set('parametres.niveau', '2');
$cheminRacine = realpath(__DIR__ . '/../../configurations/').'/';
Config::charger($cheminRacine.'bdtfx.ini');
Registre::set('eFlore.urlBase', new Url(Config::get('base_url_application_index')));
Registre::set('parametres.referentiel', 'bdtfx');
 
$recherche = new Recherche();
$recherche->initialiser();
$recherche->executerRechercheSimple();
$donnees = Registre::get('donneesMoteur');
$resultat = Registre::get('resultats');
$sortie = implode('', $recherche->getSortie());
$this->assertEmpty($donnees, print_r($donnees, true));
$this->assertNotEmpty($resultat, print_r($resultat, true));
$this->assertNotEmpty($resultat);
$this->assertEquals('6', $resultat['entete']['total']);
$this->assertEquals('6', count($resultat['resultat']));
}
 
/**
* @backupGlobals # avoid $_REQUEST leaks
*/
public function testExecuterRechercheSimpleSynonyme() {
$_GET['type_nom'] = 'nom_scientifique';
$_GET['nom'] = 'acer mons';
$_GET['resultat'] = 'retenu';
$cheminRacine = realpath(dirname(__FILE__).'/../configurations/').'/';
$_REQUEST['type_nom'] = 'nom_scientifique';
$_REQUEST['nom'] = 'acer mons';
$_REQUEST['resultat'] = 'retenu';
 
Registre::set('parametres.niveau', '2');
$cheminRacine = realpath(__DIR__ . '/../../configurations/').'/';
Config::charger($cheminRacine.'bdtfx.ini');
Registre::set('eFlore.urlBase', new Url(Config::get('base_url_application_index')));
Registre::set('parametres.referentiel', 'bdtfx');
90,15 → 108,11
$recherche->initialiser();
$recherche->executerRechercheSimple();
$donnees = Registre::get('donneesMoteur');
$resultat = Registre::get('resultats');
$sortie = implode('', $recherche->getSortie());
$this->assertEmpty($donnees, print_r($donnees, true));
$this->assertNotEmpty($resultat, print_r($resultat, true));
$this->assertNotEmpty($resultat);
$this->assertEquals('6', $resultat['entete']['total']);
$this->assertEquals('6', count($resultat['resultat']));
}
 
}
?>