Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 880 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php
class GenerateurNomSciHtmlTest extends PHPUnit_Framework_TestCase {

        public static function setUpBeforeClass() {
                error_reporting(E_ALL);
                define('DS', DIRECTORY_SEPARATOR);
                require_once dirname(__FILE__).DS.'..'.DS.'..'.DS.'bibliotheque'.DS.'GenerateurNomSciHtml.php';
        }

        public function testGenerer() {
                $nomsDecomposes[] = array(
                        'num_nom' => 1009,
                        'rang' => 340,
                        'nom_supra_generique' => '',
                        'genre' => 'Aegilops',
                        'epithete_infra_generique' => '',
                        'epithete_sp' => 'triuncialis',
            'type_epithete' => 'var.',
            'epithete_infra_sp' => 'nigroferruginea',
            'cultivar_groupe' => '',
            'nom_commercial' => '',
            'cultivar' => '',
                        'annee' => '1923',
                        'auteur' => 'Popova',
                        'biblio_origine' => 'Trudy Prikl. Bot. Selekc., 13 : 476');
                $generateur = new GenerateurNomSciHtml();
                $nomsSciHtml = $generateur->generer($nomsDecomposes);
                $nomSciHtmlGenere = $nomsSciHtml[1009];
                $nomSciHtmlAttendu = '<span class="sci"><span class="gen">Aegilops</span> <span class="sp">triuncialis</span> <abbr class="type_epithete" title="Variété">var.</abbr> <span class="infra-sp">nigroferruginea</span></span>';
                $this->assertEquals($nomSciHtmlAttendu, $nomSciHtmlGenere);
        }

        public function testGenererHybride() {
                $nomsDecomposes[] = array(
                        'num_nom' => 179,
                        'rang' => 290,
                        'nom_supra_generique' => '',
                        'genre' => 'Acer',
                        'epithete_infra_generique' => '',
                        'epithete_sp' => 'x martinii',
            'type_epithete' => '',
            'epithete_infra_sp' => '',
            'cultivar_groupe' => '',
            'nom_commercial' => '',
            'cultivar' => '',
                        'annee' => '1852',
                        'auteur' => 'Jord.',
                        'biblio_origine' => 'Pugill. Pl. Nov., 52'
                        );
                $generateur = new GenerateurNomSciHtml();
                $nomsSciHtml = $generateur->generer($nomsDecomposes);
                $nomSciHtmlGenere = $nomsSciHtml[179];
                $nomSciHtmlAttendu = '<span class="sci"><span class="gen">Acer</span> <span class="hyb">x <span class="sp">martinii</span></span></span>';
                $this->assertEquals($nomSciHtmlAttendu, $nomSciHtmlGenere);
        }

        public function testGenererChimere() {

                $nomsDecomposes[] = array(
                        'num_nom' => 80380,
                        'rang' => 290,
                        'nom_supra_generique' => '',
                        'genre' => '+ Cytisus',
                        'epithete_infra_generique' => '',
                        'epithete_sp' => 'adami',
            'type_epithete' => '',
            'epithete_infra_sp' => '',
            'cultivar_groupe' => '',
            'nom_commercial' => '',
            'cultivar' => '',
            'annee' => '1830',
                        'auteur' => 'Poit.',
                        'biblio_origine' => 'Ann. Soc. Hort. Paris, 7 : 96'
                        );
                $generateur = new GenerateurNomSciHtml();
                $nomsSciHtml = $generateur->generer($nomsDecomposes);
                $nomSciHtmlGenere = $nomsSciHtml[80380];
                $nomSciHtmlAttendu = '<span class="sci"><span class="chimere">+ <span class="gen">Cytisus</span></span> <span class="sp">adami</span></span>';
                $this->assertEquals($nomSciHtmlAttendu, $nomSciHtmlGenere);
        }
}
?>