Subversion Repositories eFlore/Projets.eflore-projets

Compare Revisions

Ignore whitespace Rev 60 → Rev 61

/trunk/scripts/tests/bibliotheque/EfloreScriptTest.php
1,12 → 1,30
<?php
class EfloreScriptTest extends PHPUnit_Framework_TestCase {
require_once dirname(__FILE__).'/../EfloreScriptPhpUnitTestCase.php';
 
class EfloreScriptTest extends EfloreScriptPhpUnitTestCase {
 
public function testChargerConfigDuProjetAvecFichiersIni() {
if (!file_exists('tmp/test.defaut.ini')) {
file_put_contents('tmp/test.defaut.ini', '');
}
if (!file_exists('tmp/test.ini')) {
file_put_contents('tmp/test.ini', "[tables]\ntest=OK");
}
 
$script = $this->getMock('EfloreScript', array('getScriptChemin', 'getProjetNom', 'executer'));
$script->expects($this->any())->method('getScriptChemin')->will($this->returnValue('tmp/'));
$script->expects($this->any())->method('getProjetNom')->will($this->returnValue('test'));
$chargerConfigDuProjet = self::getProtectedMethode($script, 'chargerConfigDuProjet');
$chargerConfigDuProjet->invoke($script);
 
$parametreConfig = Config::get('tables.test');
$this->assertEquals('OK', $parametreConfig);
}
 
public function testGetBdd() {
$nomDuScript = 'Test';
$parametresCli = array('-a' => 'tester', '-v' => '3');
$script = $this->getClasseAbstraite(array($nomDuScript, $parametresCli));
$script = $this->getClasseAbstraite('EfloreScript', array($nomDuScript, $parametresCli));
$getBdd = self::getProtectedMethode($script, 'getBdd');
$bdd = $getBdd->invoke($script);
 
14,8 → 32,19
$this->assertEquals('Bdd', get_class($bdd));
}
 
public function testStopperLaBoucle() {
$nomDuScript = 'Test';
$parametresCli = array('-a' => 'tester', '-v' => '3');
$script = $this->getClasseAbstraite('EfloreScript', array($nomDuScript, $parametresCli));
$stopperLaBoucle = self::getProtectedMethode($script, 'stopperLaBoucle');
for ($i = 0; $i < 100; $i++) {
if ($stopperLaBoucle->invoke($script, '10')) {
break;
}
}
$this->assertEquals('9', $i);
}
 
 
}
 
?>