Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 61 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
60 jpm 1
<?php
94 jpm 2
require_once dirname(__FILE__).'/../ScriptEflorePhpUnit.php';
60 jpm 3
 
94 jpm 4
class EfloreScriptTest extends ScriptEflorePhpUnit {
60 jpm 5
 
61 jpm 6
	public function testChargerConfigDuProjetAvecFichiersIni() {
94 jpm 7
		$cheminRacine = realpath(dirname(__FILE__).'/../tmp/').'/';
8
		if (!file_exists($cheminRacine.'test.defaut.ini')) {
9
			file_put_contents($cheminRacine.'test.defaut.ini', '');
61 jpm 10
		}
94 jpm 11
		if (!file_exists($cheminRacine.'test.ini')) {
12
			file_put_contents($cheminRacine.'test.ini', "[tables]\ntest=OK");
61 jpm 13
		}
60 jpm 14
 
61 jpm 15
		$script = $this->getMock('EfloreScript', array('getScriptChemin', 'getProjetNom', 'executer'));
94 jpm 16
		$script->expects($this->any())->method('getScriptChemin')->will($this->returnValue($cheminRacine));
61 jpm 17
		$script->expects($this->any())->method('getProjetNom')->will($this->returnValue('test'));
18
		$chargerConfigDuProjet = self::getProtectedMethode($script, 'chargerConfigDuProjet');
19
		$chargerConfigDuProjet->invoke($script);
20
 
21
		$parametreConfig = Config::get('tables.test');
22
		$this->assertEquals('OK', $parametreConfig);
23
	}
24
 
60 jpm 25
	public function testGetBdd() {
26
		$nomDuScript = 'Test';
27
		$parametresCli = array('-a' => 'tester', '-v' => '3');
61 jpm 28
		$script = $this->getClasseAbstraite('EfloreScript', array($nomDuScript, $parametresCli));
60 jpm 29
		$getBdd = self::getProtectedMethode($script, 'getBdd');
30
		$bdd = $getBdd->invoke($script);
31
 
32
		$this->assertTrue(is_object($bdd));
33
		$this->assertEquals('Bdd', get_class($bdd));
34
	}
35
 
61 jpm 36
	public function testStopperLaBoucle() {
37
		$nomDuScript = 'Test';
38
		$parametresCli = array('-a' => 'tester', '-v' => '3');
39
		$script = $this->getClasseAbstraite('EfloreScript', array($nomDuScript, $parametresCli));
40
		$stopperLaBoucle = self::getProtectedMethode($script, 'stopperLaBoucle');
41
		for ($i = 0; $i < 100; $i++) {
42
			if ($stopperLaBoucle->invoke($script, '10')) {
43
				break;
44
			}
45
		}
46
		$this->assertEquals('9', $i);
47
	}
60 jpm 48
 
49
}
50
 
51
?>