Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 216 | Go to most recent revision | Details | 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);
16
		return $projet;
17
	}
18
 
19
	public function testerInitialiserAutoLoad() {
20
		$ressourcesUrl = array('fournier', 'noms', '1');
21
 
22
		$projet = $this->initialiser($ressourcesUrl);
23
		$projet->initialiser();
24
 
25
		$nomDetails = $this->getMock('NomDetailsGenerique');
26
		$test = new NomDetailsFournier($nomDetails);
27
	}
28
 
29
	public function testerInitialiserConfig() {
30
		$ressourcesUrl = array('fournier', 'noms', '1');
31
 
32
		$projet = $this->initialiser($ressourcesUrl);
33
		$projet->initialiser();
34
 
35
		$this->assertNotNull(Config::get('nomProjet'));
36
		$this->assertNotNull(Config::get('bddTable'));
37
		$this->assertNotNull(Config::get('bddTableMeta'));
38
		$this->assertNotNull(Config::get('baseServiceUrl'));
39
		$this->assertNotNull(Config::get('baseProjetUrl'));
40
		$this->assertNotNull(Config::get('listeUrl'));
41
		$this->assertNotNull(Config::get('detailsHrefTpl'));
42
		$this->assertNotNull(Config::get('ontologieHrefTpl'));
43
		$this->assertNotNull(Config::get('servicesDispo'));
44
		$this->assertNotNull(Config::get('parametresAPI'));
45
		$this->assertNotNull(Config::get('champsProjet'));
46
	}
47
 
48
	public function testerVerifierExistanceClasseService() {
49
		$ressourcesUrl = array('fournier', 'ServiceInexistant', '1');
50
 
51
		$projet = $this->initialiser($ressourcesUrl);
52
 
53
		try {
54
			$projet->verifier();
55
		} catch(Exception $e) {
56
			$messageAttendu = "La classe du service demandé 'ServiceInexistant' n'existe pas dans le projet 'fournier' !";
57
			$this->assertEquals($messageAttendu, $e->getMessage());
58
			$this->assertEquals(404, $e->getCode());
59
			return null;
60
		}
61
		$this->fail("Aucune exception n'a été soulevée.");
62
	}
63
}
64
?>