Subversion Repositories eFlore/Projets.eflore-projets

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

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