Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

Rev Author Line No. Line
215 jpm 1
<?php
2
require_once dirname(__FILE__).'/../ServicePhpUnit.php';
3
 
4
class ProjetTest extends ServicePhpUnit {
5
 
6
	private function initialiser($ressourcesUrl = array()) {
7
		$ressources = new Ressources($ressourcesUrl);
8
		$projet = new Projet($ressources);
9
		$projet->setCheminBase(realpath(dirname(__FILE__).'/../../../modules/0.2').'/');
10
		$projet->setCheminConfig(realpath(dirname(__FILE__).'/../../../configurations').'/');
11
		$projet->setCheminBiblio(realpath(dirname(__FILE__).'/../../../bibliotheque').'/');
12
		$paramsVerif = $this->getMock('ParametresVerificateur');
13
		$projet->setParamsVerif($paramsVerif);
14
		$ressourcesVerif = $this->getMock('RessourcesVerificateur');
15
		$projet->setRessourcesVerif($ressourcesVerif);
216 jpm 16
		$versionVerif = $this->getMock('VersionVerificateur');
17
		$projet->setVersionVerif($versionVerif);
215 jpm 18
		return $projet;
19
	}
20
 
21
	public function testerInitialiserAutoLoad() {
22
		$ressourcesUrl = array('fournier', 'noms', '1');
23
 
24
		$projet = $this->initialiser($ressourcesUrl);
25
		$projet->initialiser();
26
 
27
		$nomDetails = $this->getMock('NomDetailsGenerique');
28
		$test = new NomDetailsFournier($nomDetails);
29
	}
30
 
31
	public function testerInitialiserConfig() {
32
		$ressourcesUrl = array('fournier', 'noms', '1');
33
 
34
		$projet = $this->initialiser($ressourcesUrl);
35
		$projet->initialiser();
36
 
37
		$this->assertNotNull(Config::get('nomProjet'));
38
		$this->assertNotNull(Config::get('bddTable'));
39
		$this->assertNotNull(Config::get('bddTableMeta'));
40
		$this->assertNotNull(Config::get('baseServiceUrl'));
41
		$this->assertNotNull(Config::get('baseProjetUrl'));
42
		$this->assertNotNull(Config::get('listeUrl'));
43
		$this->assertNotNull(Config::get('detailsHrefTpl'));
44
		$this->assertNotNull(Config::get('ontologieHrefTpl'));
45
		$this->assertNotNull(Config::get('servicesDispo'));
46
		$this->assertNotNull(Config::get('parametresAPI'));
47
		$this->assertNotNull(Config::get('champsProjet'));
48
	}
49
 
50
	public function testerVerifierExistanceClasseService() {
51
		$ressourcesUrl = array('fournier', 'ServiceInexistant', '1');
52
 
53
		$projet = $this->initialiser($ressourcesUrl);
54
 
55
		try {
56
			$projet->verifier();
57
		} catch(Exception $e) {
58
			$messageAttendu = "La classe du service demandé 'ServiceInexistant' n'existe pas dans le projet 'fournier' !";
59
			$this->assertEquals($messageAttendu, $e->getMessage());
60
			$this->assertEquals(404, $e->getCode());
61
			return null;
62
		}
63
		$this->fail("Aucune exception n'a été soulevée.");
64
	}
65
}
66
?>