Exemple #1
0
 public function testLoadFromFile()
 {
     $path = __DIR__ . '/config-valid.php';
     // valid
     $loader = new ArrayLoader();
     $loader->loadFromFile($path);
     $this->assertEquals($this->array, $loader->get());
     // file not exist
     try {
         $loader->loadFromFile('notexist.php');
         $this->fail();
     } catch (FileIsNotReadableException $e) {
         $this->assertTrue(true);
     }
     // invalid config
     try {
         $path = __DIR__ . '/config-invalid.php';
         $loader->loadFromFile($path);
         $this->fail();
     } catch (FileNotReturnAnArrayException $e) {
         $this->assertTrue(true);
     }
 }
Exemple #2
0
 /**
  * @param string $path
  * @return ArrayLoader
  */
 public static function createFromFile($path)
 {
     $instance = new ArrayLoader();
     $instance->loadFromFile($path);
     return $instance;
 }