Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 60 | Rev 94 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 60 Rev 61
Line 1... Line 1...
1
<?php
1
<?php
2
class EfloreScriptTest extends PHPUnit_Framework_TestCase {
2
require_once dirname(__FILE__).'/../EfloreScriptPhpUnitTestCase.php';
Line -... Line 3...
-
 
3
 
Line -... Line 4...
-
 
4
class EfloreScriptTest extends EfloreScriptPhpUnitTestCase {
-
 
5
 
-
 
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
		}
-
 
13
 
-
 
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');
Line 3... Line 21...
3
 
21
		$this->assertEquals('OK', $parametreConfig);
4
 
22
	}
5
 
23
 
6
	public function testGetBdd() {
24
	public function testGetBdd() {
7
		$nomDuScript = 'Test';
25
		$nomDuScript = 'Test';
8
		$parametresCli = array('-a' => 'tester', '-v' => '3');
26
		$parametresCli = array('-a' => 'tester', '-v' => '3');
Line 9... Line 27...
9
		$script = $this->getClasseAbstraite(array($nomDuScript, $parametresCli));
27
		$script = $this->getClasseAbstraite('EfloreScript', array($nomDuScript, $parametresCli));
10
		$getBdd = self::getProtectedMethode($script, 'getBdd');
28
		$getBdd = self::getProtectedMethode($script, 'getBdd');
11
		$bdd = $getBdd->invoke($script);
29
		$bdd = $getBdd->invoke($script);
Line -... Line 30...
-
 
30
 
-
 
31
		$this->assertTrue(is_object($bdd));
-
 
32
		$this->assertEquals('Bdd', get_class($bdd));
-
 
33
	}
-
 
34
 
-
 
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++) {
12
 
41
			if ($stopperLaBoucle->invoke($script, '10')) {
Line 13... Line 42...
13
		$this->assertTrue(is_object($bdd));
42
				break;
Line 14... Line 43...
14
		$this->assertEquals('Bdd', get_class($bdd));
43
			}
15
	}
44
		}