Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 880 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php
require_once dirname(__FILE__).'/../ScriptEflorePhpUnit.php';

class EfloreScriptTest extends ScriptEflorePhpUnit {

        public function testChargerConfigDuProjetAvecFichiersIni() {
                $cheminRacine = realpath(dirname(__FILE__).'/../tmp/').'/';
                if (!file_exists($cheminRacine.'test.ini')) {
                        file_put_contents($cheminRacine.'test.ini', "[tables]\ntest=OK");
                }

                $script = $this->getMock('EfloreScript', array('getScriptChemin', 'getProjetNom', 'executer'));
                $script->expects($this->any())->method('getScriptChemin')->will($this->returnValue($cheminRacine));
                $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('EfloreScript', array($nomDuScript, $parametresCli));
                $getBdd = self::getProtectedMethode($script, 'getBdd');
                $bdd = $getBdd->invoke($script);

                $this->assertTrue(is_object($bdd));
                $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);
        }

}

?>