Example #1
0
 /**
  * Contrôle des getters & setters
  *
  * @return void
  */
 public function testLoad()
 {
     $data = ['test' => 'plop', 'foo' => ['bar' => 'foobar']];
     $confResult = new \Solire\Conf\Conf();
     $confResult->set('plop', 'test')->set('foobar', 'foo', 'bar');
     $this->assert('$data est un un objet conf')->object(TestClass::load($confResult))->isEqualTo($confResult)->assert('$data est un tableau')->object(TestClass::load($data))->isEqualTo($confResult)->assert('$data est un chemin vers un .ini')->if($confIniRef = new IniToConf($this->localIni))->given($confIni = TestClass::load($this->localIni))->object($confIni->get('database'))->isEqualTo($confIniRef->get('database'))->assert('$data est un chemin vers un .yml')->if($confYmlRef = new YmlToConf($this->localYml))->given($confYml = TestClass::load($this->localYml))->object($confYml->get('database'))->isEqualTo($confYmlRef->get('database'))->assert('$data n\'est pas exploitable')->exception(function () {
         TestClass::load('Data');
     })->hasMessage('Aucune données exploitable pour charger une Conf')->isInstanceOf('\\Solire\\Conf\\Exception')->exception(function () {
         TestClass::load(TEST_DATA_DIR . '/foo.falsext');
     })->hasMessage('Aucune données exploitable pour charger une Conf')->isInstanceOf('\\Solire\\Conf\\Exception')->assert('$data multiple')->if($conf = TestClass::load($data, $this->localIni, $this->localYml))->string($conf->database->host)->isEqualTo('localhost')->string($conf->get('foo', 'bar'))->isEqualTo('foobar');
 }
Example #2
0
 /**
  * Contrôle chargement d'un yml classique
  */
 public function testLoadVars()
 {
     $this->if($conf = new TestClass($this->testLocal))->integer($conf->get('database', 'port'))->isEqualTo(3306)->integer($conf->database->port)->isEqualTo(3306)->integer($conf['database']['port'])->isEqualTo(3306)->object($conf->get('base'))->isInstanceOf('\\Solire\\Conf\\Conf')->array((array) $conf->get('base'))->isEqualTo(['url' => 'http://localhost/'])->string($conf->get('test')->get('foo')->get('bar'))->isEqualTo('foobar');
 }