Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 790 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
258 jpm 1
<?php
2
require_once dirname(__FILE__).'/../ServiceEflorePhpUnit.php';
3
 
4
class ChorodepCartesTest extends ServiceEflorePhpUnit {
5
 
6
	private $retour = '';
7
	private $svg = '';
8
 
9
	public function __construct() {
10
		$this->projet = 'chorodep';
11
		$this->service = 'cartes';
12
	}
13
 
14
	public function setUp() {
15
		$this->retour = '';
16
		$this->svg = '';
17
	}
18
 
19
	public function testCarteGenerique() {
20
		$ressources = array();
21
		$parametres = array('version.projet' => '2012.01');
22
 
790 raphael 23
		$this->retour = ServiceEflorePhpUnit::consulterBrut($this->service, $this->projet, $ressources, $parametres);
258 jpm 24
 
25
		$this->verifierPresenceMessage("A implémenter : carte proportionnelle ensemble des infos");
26
	}
27
 
28
	public function testCarteGeneriqueLegende() {
29
		$ressources = array('legende');
30
		$parametres = array('version.projet' => '2012.01');
31
 
790 raphael 32
		$this->retour = ServiceEflorePhpUnit::consulterBrut($this->service, $this->projet, $ressources, $parametres);
258 jpm 33
 
34
		$this->verifierPresenceMessage("A implémenter : légende carte proportionnelle ensemble des infos");
35
	}
36
 
37
	public function testErreurRessource1() {
38
		$ressources = array('ressource1Erreur');
39
		$parametres = array('version.projet' => '2012.01');
40
 
790 raphael 41
		$this->retour = ServiceEflorePhpUnit::consulterBrut($this->service, $this->projet, $ressources, $parametres);
258 jpm 42
 
43
		$this->verifierPresenceMessage("La ressource n°1 '{$ressources[0]} indiquée n'est pas valable.");
44
	}
45
 
46
	public function testCarteSvgIdentifiants() {
47
		$ressourcesListe = array(
48
			array('3237'),
49
			array('nn:3237'),
50
			array('bdtfx.nn:3237')
51
		);
52
		$parametres = array('version.projet' => '2012.01',
53
			'retour' => 'image/svg+xml');
54
 
55
		foreach ($ressourcesListe as $ressources) {
790 raphael 56
			$this->retour = ServiceEflorePhpUnit::consulterBrut($this->service, $this->projet, $ressources, $parametres);
258 jpm 57
 
58
			$this->chargerXml();
59
			$this->etreSvg();
60
			$this->verifierDepartementsPresence(array(63, 81));
61
		}
62
	}
63
 
64
	public function testCarteSvgPlusieursLegendes() {
65
		$ressources = array('bdtfx.nn:71574');
66
		$parametres = array('version.projet' => '2012.01',
67
				'retour' => 'image/svg+xml');
68
 
790 raphael 69
		$this->retour = ServiceEflorePhpUnit::consulterBrut($this->service, $this->projet, $ressources, $parametres);
258 jpm 70
		$this->chargerXml();
71
		$this->etreSvg();
72
		$this->verifierDepartementsPresence(array('02', '07', '57', '67', '88', '68', '90', '25', '21', '39', '01', '74', '73', '38', '46', '83'));
73
		$this->verifierDepartementsPresenceAConfirmer(array('62', '71'));
74
		$this->verifierDepartementsDisparu(array('70'));
75
		$this->verifierDepartementsErreur(array('06'));
76
	}
77
 
78
	private function verifierPresenceMessage($messageAttendu) {
79
		$this->assertEquals($messageAttendu, $this->retour);
80
	}
81
 
82
	private function chargerXml() {
83
		$this->svg = new DOMDocument();
84
		$chargement = $this->svg->loadXML($this->retour);
85
		$this->assertTrue($chargement);
86
	}
87
 
88
	private function etreSvg() {
89
		$racineElement = $this->svg->documentElement;
90
		$this->assertEquals('svg', $racineElement->tagName);
91
	}
92
	private function verifierDepartementsPresence($departements) {
93
		$this->verifierReglesCssCouleur('A0FF7D', $departements);
94
	}
95
 
96
	private function verifierDepartementsPresenceAConfirmer($departements) {
97
		$this->verifierReglesCssCouleur('FFFF32', $departements);
98
	}
99
 
100
	private function verifierDepartementsDouteux($departements) {
101
		$this->verifierReglesCssCouleur('FFCB30', $departements);
102
	}
103
 
104
	private function verifierDepartementsDisparu($departements) {
105
		$this->verifierReglesCssCouleur('F88017', $departements);
106
	}
107
 
108
	private function verifierDepartementsErreur($departements) {
109
		$this->verifierReglesCssCouleur('FF2850', $departements);
110
	}
111
 
112
	private function verifierDepartementsErreurAConfirmer($departements) {
113
		$this->verifierReglesCssCouleur('9F0016', $departements);
114
	}
115
 
116
	private function verifierReglesCssCouleur($couleur, $departements) {
117
		sort($departements);
118
		$cssRegles = $this->getListeReglesCss($departements);
119
		$cssAttendu = "$cssRegles{\nfill:#$couleur;\n}";
120
 
121
		$cssPresent = $this->svg->getElementsByTagName('style')->item(0)->nodeValue;
122
 
123
		$this->assertContains($cssAttendu, $cssPresent);
124
	}
125
 
126
	private function getListeReglesCss($departements) {
127
		foreach ($departements as $id => $val) {
128
			$departements[$id] = '.departement'.$val;
129
		}
130
		$cssRegle = implode(', ', $departements);
131
		return $cssRegle;
132
	}
133
}
134
?>