createFromFile() public static method

creates an instance of this class with the data loaded from a file.
public static createFromFile ( string $filename ) : JSON
$filename string eg: __DIR__ . '/../../configuration.json'
return JSON an instance of JSON with the data read from the file
Ejemplo n.º 1
0
 /**
  * @test
  */
 public function shouldThrowExceptionForNoMachineData()
 {
     $machine = new StateMachine(new Context(new Identifier('json-test', 'json-machine')));
     $loader = JSON::createFromFile(__DIR__ . '/fixture-no-machines.json');
     try {
         $loader->load($machine);
         $this->fail('should not come here');
     } catch (Exception $e) {
         $this->assertEquals(Exception::BAD_LOADERDATA, $e->getCode());
         $this->assertContains('no machine data', $e->getMessage());
     }
 }