Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 880 | 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.ini')) {
9
			file_put_contents($cheminRacine.'test.ini', "[tables]\ntest=OK");
61 jpm 10
		}
60 jpm 11
 
61 jpm 12
		$script = $this->getMock('EfloreScript', array('getScriptChemin', 'getProjetNom', 'executer'));
94 jpm 13
		$script->expects($this->any())->method('getScriptChemin')->will($this->returnValue($cheminRacine));
61 jpm 14
		$script->expects($this->any())->method('getProjetNom')->will($this->returnValue('test'));
15
		$chargerConfigDuProjet = self::getProtectedMethode($script, 'chargerConfigDuProjet');
16
		$chargerConfigDuProjet->invoke($script);
17
 
18
		$parametreConfig = Config::get('tables.test');
19
		$this->assertEquals('OK', $parametreConfig);
20
	}
21
 
60 jpm 22
	public function testGetBdd() {
23
		$nomDuScript = 'Test';
24
		$parametresCli = array('-a' => 'tester', '-v' => '3');
61 jpm 25
		$script = $this->getClasseAbstraite('EfloreScript', array($nomDuScript, $parametresCli));
60 jpm 26
		$getBdd = self::getProtectedMethode($script, 'getBdd');
27
		$bdd = $getBdd->invoke($script);
28
 
29
		$this->assertTrue(is_object($bdd));
30
		$this->assertEquals('Bdd', get_class($bdd));
31
	}
32
 
61 jpm 33
	public function testStopperLaBoucle() {
34
		$nomDuScript = 'Test';
35
		$parametresCli = array('-a' => 'tester', '-v' => '3');
36
		$script = $this->getClasseAbstraite('EfloreScript', array($nomDuScript, $parametresCli));
37
		$stopperLaBoucle = self::getProtectedMethode($script, 'stopperLaBoucle');
38
		for ($i = 0; $i < 100; $i++) {
39
			if ($stopperLaBoucle->invoke($script, '10')) {
40
				break;
41
			}
42
		}
43
		$this->assertEquals('9', $i);
44
	}
60 jpm 45
 
46
}
47
 
48
?>