| 210 | delphine | 1 | <?php
 | 
        
           |  |  | 2 | include_once dirname(__FILE__).'/../ResultatFormateurInitialisation.php';
 | 
        
           |  |  | 3 |   | 
        
           |  |  | 4 | class DeterminationVernaFormateurTest extends ResultatFormateurInitialisation {
 | 
        
           |  |  | 5 |   | 
        
           |  |  | 6 | 	public function testerFormater() {
 | 
        
           |  |  | 7 | 		$Formateur = $this->initialiserDeterminationVernaFormateur();
 | 
        
           |  |  | 8 |   | 
        
           |  |  | 9 | 		$Formateur->formater();
 | 
        
           |  |  | 10 | 		$infos = $Formateur->getTplInfos();
 | 
        
           |  |  | 11 |   | 
        
           |  |  | 12 | 		$this->assertArrayHasKey('noms', $infos, print_r($infos, true));
 | 
        
           |  |  | 13 | 		foreach ($infos['noms'] as $id => $nom) {
 | 
        
           |  |  | 14 | 			$this->assertTrue(is_int($id), "L'id '$id' doit être un nombre entier.");
 | 
        
           |  |  | 15 | 			$this->assertCount(3, $nom);
 | 
        
           |  |  | 16 | 			$this->assertArrayHasKey('nomSci', $infos['noms'][$id], print_r($infos, true));
 | 
        
           |  |  | 17 | 			$this->assertArrayHasKey('urlFiche', $infos['noms'][$id], print_r($infos, true));
 | 
        
           | 1149 | raphael | 18 | 			$urlFicheAttendue = sprintf(ConsultationEflorePhpUnit::TPL_URL_FICHE, $id);
 | 
        
           | 210 | delphine | 19 | 			$this->assertEquals($urlFicheAttendue, $infos['noms'][$id]['urlFiche'], print_r($infos, true));
 | 
        
           |  |  | 20 | 			if (array_key_exists('nomVerna', $infos['noms'][$id])) {
 | 
        
           |  |  | 21 | 				$nomsVernas = $infos['noms'][$id]['nomVerna'];
 | 
        
           |  |  | 22 | 				$this->assertTrue(is_array($nomsVernas));
 | 
        
           |  |  | 23 | 				foreach ($nomsVernas as $nomVerna) {
 | 
        
           |  |  | 24 | 					$this->assertCount(2, $nomVerna, print_r($nomVerna, true));
 | 
        
           |  |  | 25 | 					$this->assertArrayHasKey('nn', $nomVerna, print_r($nomVerna, true));
 | 
        
           |  |  | 26 | 					$this->assertTrue(is_int($nomVerna['nn']), "La valeur nn (num_nom) '{$nomVerna['nn']}' doit être un nombre entier.");
 | 
        
           |  |  | 27 | 					$this->assertArrayHasKey('nom_vernaculaire', $nomVerna, print_r($nomVerna, true));
 | 
        
           |  |  | 28 | 				}
 | 
        
           |  |  | 29 | 			}
 | 
        
           |  |  | 30 | 		}
 | 
        
           |  |  | 31 |   | 
        
           |  |  | 32 | 		$this->assertArrayHasKey('imagesUrls', $infos, print_r($infos, true));
 | 
        
           |  |  | 33 | 		$this->assertTrue(is_array($infos['imagesUrls']), "'imagesUrls' doit être un tableau");
 | 
        
           |  |  | 34 | 		$this->assertArrayHasKey('51299', $infos['imagesUrls'], print_r($infos['imagesUrls'], true));
 | 
        
           |  |  | 35 | 		$this->assertArrayHasKey('18669', $infos['imagesUrls'], print_r($infos['imagesUrls'], true));
 | 
        
           |  |  | 36 | 		foreach ($infos['imagesUrls'] as $imgUrl) {
 | 
        
           |  |  | 37 | 			$this->assertTrue(is_array($imgUrl), "Chaque taxon doit avoir un tableau d'url d'images");
 | 
        
           |  |  | 38 | 			foreach ($imgUrl as $url) {
 | 
        
           |  |  | 39 | 				$this->assertRegExp('/^http:\/\/www\.tela-botanica\.org\/appli:cel-img:[0-9]{9}CS\.jpg$/', $url);
 | 
        
           |  |  | 40 | 			}
 | 
        
           |  |  | 41 | 		}
 | 
        
           |  |  | 42 | 	}
 | 
        
           |  |  | 43 |   | 
        
           |  |  | 44 | 	public function testerSurligner() {
 | 
        
           |  |  | 45 | 		$Formateur = $this->initialiserDeterminationVernaFormateur();
 | 
        
           |  |  | 46 |   | 
        
           |  |  | 47 | 		$Formateur->formater();
 | 
        
           |  |  | 48 | 		$Formateur->surligner();
 | 
        
           |  |  | 49 | 		$infos = $Formateur->getTplInfos();
 | 
        
           |  |  | 50 |   | 
        
           |  |  | 51 | 		$this->assertArrayHasKey('noms', $infos, print_r($infos, true));
 | 
        
           |  |  | 52 | 		foreach ($infos['noms'] as $nom) {
 | 
        
           |  |  | 53 | 			foreach ($nom['nomVerna'] as $id => $nomVerna) {
 | 
        
           |  |  | 54 | 				$this->assertArrayHasKey('nom_vernaculaire', $nomVerna, print_r($nomVerna, true));
 | 
        
           |  |  | 55 | 				$this->assertContains('<span class="surlignage">Muguet</span>', $nomVerna['nom_vernaculaire'], print_r($infos, true));
 | 
        
           |  |  | 56 | 			}
 | 
        
           |  |  | 57 | 		}
 | 
        
           |  |  | 58 | 	}
 | 
        
           |  |  | 59 |   | 
        
           |  |  | 60 | 	private function initialiserDeterminationVernaFormateur($masque = 'Muguet') {
 | 
        
           |  |  | 61 | 		$parametres = $this->getParametres('determination', $masque);
 | 
        
           |  |  | 62 | 		$resultats = $this->getResultatsPourMasque($masque);
 | 
        
           |  |  | 63 | 		$surligneur = $this->getSurligneur();
 | 
        
           |  |  | 64 | 		$trieur = $this->getTrieur();
 | 
        
           |  |  | 65 | 		$appsUrls = $this->getAppUrls();
 | 
        
           |  |  | 66 | 		$images = $this->getImagesService();
 | 
        
           |  |  | 67 | 		return new DeterminationVernaFormateur($parametres, $resultats, $surligneur, $trieur, $appsUrls, null, $images);
 | 
        
           |  |  | 68 | 	}
 | 
        
           |  |  | 69 |   | 
        
           |  |  | 70 | 	protected function getResultatsPourMasque($masque) {
 | 
        
           |  |  | 71 | 		$resultatsJson = file_get_contents(dirname(__FILE__).'/../resultats_verna.json');
 | 
        
           |  |  | 72 | 		$resultats = json_decode($resultatsJson, true);
 | 
        
           |  |  | 73 | 		return $resultats[$masque];
 | 
        
           |  |  | 74 | 	}
 | 
        
           |  |  | 75 |   | 
        
           |  |  | 76 | 	private function getImagesService() {
 | 
        
           |  |  | 77 | 		$retour = Array (
 | 
        
           |  |  | 78 | 			'bdtfx.51299' => Array (
 | 
        
           |  |  | 79 | 				'0' => 'http://www.tela-botanica.org/appli:cel-img:000007275CS.jpg',
 | 
        
           |  |  | 80 | 				'1' => 'http://www.tela-botanica.org/appli:cel-img:000007276CS.jpg',
 | 
        
           |  |  | 81 | 				'2' => 'http://www.tela-botanica.org/appli:cel-img:000007277CS.jpg',
 | 
        
           |  |  | 82 | 				'3' => 'http://www.tela-botanica.org/appli:cel-img:000007278CS.jpg',
 | 
        
           |  |  | 83 | 				'4' => 'http://www.tela-botanica.org/appli:cel-img:000007279CS.jpg',
 | 
        
           |  |  | 84 | 				'5' => 'http://www.tela-botanica.org/appli:cel-img:000021076CS.jpg' ),
 | 
        
           |  |  | 85 | 			'bdtfx.18669' => Array (
 | 
        
           |  |  | 86 | 				'0' => 'http://www.tela-botanica.org/appli:cel-img:000009085CS.jpg',
 | 
        
           |  |  | 87 | 				'1' => 'http://www.tela-botanica.org/appli:cel-img:000009086CS.jpg',
 | 
        
           |  |  | 88 | 				'2' => 'http://www.tela-botanica.org/appli:cel-img:000018652CS.jpg',
 | 
        
           |  |  | 89 | 				'3' => 'http://www.tela-botanica.org/appli:cel-img:000018757CS.jpg',
 | 
        
           |  |  | 90 | 				'4' => 'http://www.tela-botanica.org/appli:cel-img:000018862CS.jpg',
 | 
        
           |  |  | 91 | 				'5' => 'http://www.tela-botanica.org/appli:cel-img:000018865CS.jpg',
 | 
        
           |  |  | 92 | 				'6' => 'http://www.tela-botanica.org/appli:cel-img:000032690CS.jpg' ),
 | 
        
           |  |  | 93 | 			'bdtfx.29125' => Array (
 | 
        
           |  |  | 94 | 				'0' => 'http://www.tela-botanica.org/appli:cel-img:000010721CS.jpg',
 | 
        
           |  |  | 95 | 				'1' => 'http://www.tela-botanica.org/appli:cel-img:000010722CS.jpg',
 | 
        
           |  |  | 96 | 				'2' => 'http://www.tela-botanica.org/appli:cel-img:000013077CS.jpg',
 | 
        
           |  |  | 97 | 				'3' => 'http://www.tela-botanica.org/appli:cel-img:000024697CS.jpg',
 | 
        
           |  |  | 98 | 				'4' => 'http://www.tela-botanica.org/appli:cel-img:000024719CS.jpg',
 | 
        
           |  |  | 99 | 				'5' => 'http://www.tela-botanica.org/appli:cel-img:000024729CS.jpg' ),
 | 
        
           |  |  | 100 | 			'bdtfx.7310' => Array (
 | 
        
           |  |  | 101 | 				'0' => 'http://www.tela-botanica.org/appli:cel-img:000013740CS.jpg',
 | 
        
           |  |  | 102 | 				'1' => 'http://www.tela-botanica.org/appli:cel-img:000013741CS.jpg' ),
 | 
        
           |  |  | 103 | 			'bdtfx.18716' => Array (
 | 
        
           |  |  | 104 | 				'0' => 'http://www.tela-botanica.org/appli:cel-img:000021069CS.jpg',
 | 
        
           |  |  | 105 | 				'1' => 'http://www.tela-botanica.org/appli:cel-img:000021071CS.jpg',
 | 
        
           |  |  | 106 | 				'2' => 'http://www.tela-botanica.org/appli:cel-img:000033834CS.jpg',
 | 
        
           |  |  | 107 | 				'3' => 'http://www.tela-botanica.org/appli:cel-img:000033835CS.jpg' ),
 | 
        
           |  |  | 108 | 			'bdtfx.51311' => Array (
 | 
        
           |  |  | 109 | 				'0' => 'http://www.tela-botanica.org/appli:cel-img:000021070CS.jpg',
 | 
        
           |  |  | 110 | 				'1' => 'http://www.tela-botanica.org/appli:cel-img:000021078CS.jpg' ),
 | 
        
           |  |  | 111 | 			'bdtfx.51306' => Array (
 | 
        
           |  |  | 112 | 				'0' => 'http://www.tela-botanica.org/appli:cel-img:000021072CS.jpg',
 | 
        
           |  |  | 113 | 				'1' => 'http://www.tela-botanica.org/appli:cel-img:000021075CS.jpg',
 | 
        
           |  |  | 114 | 				'2' => 'http://www.tela-botanica.org/appli:cel-img:000021080CS.jpg' ),
 | 
        
           |  |  | 115 | 			'bdtfx.40679' => Array (
 | 
        
           |  |  | 116 | 				'0' => 'http://www.tela-botanica.org/appli:cel-img:000021073CS.jpg',
 | 
        
           |  |  | 117 | 				'1' => 'http://www.tela-botanica.org/appli:cel-img:000021074CS.jpg',
 | 
        
           |  |  | 118 | 				'2' => 'http://www.tela-botanica.org/appli:cel-img:000021077CS.jpg',
 | 
        
           |  |  | 119 | 				'3' => 'http://www.tela-botanica.org/appli:cel-img:000021079CS.jpg' ),
 | 
        
           |  |  | 120 | 			'bdtfx.60062' => Array (
 | 
        
           |  |  | 121 | 				'0' => 'http://www.tela-botanica.org/appli:cel-img:000025283CS.jpg',
 | 
        
           |  |  | 122 | 				'1' => 'http://www.tela-botanica.org/appli:cel-img:000025308CS.jpg',
 | 
        
           |  |  | 123 | 				'2' => 'http://www.tela-botanica.org/appli:cel-img:000025309CS.jpg' ) );
 | 
        
           |  |  | 124 |   | 
        
           |  |  | 125 | 		$Images = $this->getMock('Images', array('getUrlsImagesParIdsNoms'), array(), '', false);
 | 
        
           |  |  | 126 | 		$Images->expects($this->any())
 | 
        
           |  |  | 127 | 			->method('getUrlsImagesParIdsNoms')
 | 
        
           |  |  | 128 | 			->will($this->returnValue($retour));
 | 
        
           |  |  | 129 | 		return $Images;
 | 
        
           |  |  | 130 | 	}
 | 
        
           |  |  | 131 | }
 | 
        
           |  |  | 132 | ?>
 |