Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 157 | Rev 205 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php

class ResultatFormateurInitialisation extends PHPUnit_Framework_TestCase {
        const TPL_URL_FICHE = 'http://localhost/eflore/eflore-consultation/index_botanique.php?referentiel=bdtfx&module=fiche&action=fiche&nn=%s';

        public static function setUpBeforeClass() {
                error_reporting(E_ALL);

                // Enregistrement en première position des autoload de la méthode gérant les classes des services
                spl_autoload_register(array(get_class(), 'chargerClasseAuto'));
        }

        public static function chargerClasseAuto($classe) {
                $cheminBase = dirname(__FILE__).'/../../../';
                $cheminBiblio = $cheminBase.'bibliotheque/';
                $cheminModule = $cheminBase.'modules/resultat/';
                $cheminModuleFormateurs = $cheminModule.'formateurs/';
                $chemins = array($cheminBiblio, $cheminModule, $cheminModuleFormateurs);
                foreach ($chemins as $chemin) {
                        $chemin = $chemin.$classe.'.php';
                        if (file_exists($chemin)) {
                                require_once $chemin;
                        }
                }
        }

        protected function getParametres($type, $masque) {
                $parametres = new ParametresResultats();
                $parametres->type = $type;
                $parametres->masqueRecherche = $masque;
                return $parametres;
        }

        protected function getResultatsPourMasque($masque) {
                $resultatsJson = file_get_contents(dirname(__FILE__).'/resultats.json');
                $resultats = json_decode($resultatsJson, true);
                return $resultats[$masque];
        }

        protected function getSurligneur() {
                $surligneur = new Surligneur();
                return $surligneur;
        }

        protected function getTrieur() {
                $trieur = new Trieur();
                return $trieur;
        }

        protected function getAppUrls() {
                $AppUrls = $this->getMock('AppUrls', array('obtenirUrlFiche'), array(), '', false);
                $AppUrls->expects($this->any())
                ->method('obtenirUrlFiche')
                ->will($this->returnCallback(array($this, 'genererUrlFiche')));
                return $AppUrls;
        }

        public function genererUrlFiche($id) {
                return sprintf(self::TPL_URL_FICHE, $id);
        }
}
?>