Rev 1141 | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?phprequire_once __DIR__ . '/../ConsultationEflorePhpUnit.php';class RechercheTest extends ConsultationEflorePhpUnit {/*** @backupGlobals # avoid $_REQUEST leaks*/public function testExecuterRechercheSimple() {$_REQUEST['type_nom'] = 'nom_scientifique';$_REQUEST['nom'] = 'acer mons';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');$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']));$this->assertArrayNotHasKey('auteur', $resultat['resultat']['182'], print_r($resultat, true));$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() {$_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éfautAppControleur::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']));}}?>