initialiser(); $recherche->executerRechercheSimple(); $resultat = Registre::get('resultats'); $sortie = implode('', $recherche->getSortie()); $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); $this->assertContains('', $sortie); $this->assertContains('Acer monspessulanum', $sortie); } /** * @backupGlobals # avoid $_REQUEST leaks */ public function testExecuterRechercheSimpleAlphab() { $_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(); $resultat = Registre::get('resultats'); $sortie = implode('', $recherche->getSortie()); $this->assertNotEmpty($resultat, $resultat); $this->assertEquals('6', $resultat['entete']['total']); $this->assertEquals('6', count($resultat['resultat'])); } /** * @backupGlobals # avoid $_REQUEST leaks */ public function testExecuterRechercheSimpleRetenu() { $_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(); $resultat = Registre::get('resultats'); $sortie = implode('', $recherche->getSortie()); $this->assertNotEmpty($resultat); $this->assertEquals('6', $resultat['entete']['total']); $this->assertEquals('6', count($resultat['resultat'])); } /** * @backupGlobals # avoid $_REQUEST leaks */ public function testExecuterRechercheSimpleSynonyme() { $_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'); $recherche = new Recherche(); $recherche->initialiser(); $recherche->executerRechercheSimple(); $resultat = Registre::get('resultats'); $sortie = implode('', $recherche->getSortie()); $this->assertNotEmpty($resultat); $this->assertEquals('6', $resultat['entete']['total']); $this->assertEquals('6', count($resultat['resultat'])); } } ?>