The xml string can contain one or more machine definitions. The correct machine will be found from the xml structure. This class also provides a way to load xml from a file. The format of the data to be loaded is specified via an xml schema definition. see getXSD
Author: Rolf Vreijdenberger
Inheritance: implements izzum\statemachine\loader\Loader
 /**
  * @test
  */
 public function shouldBehave()
 {
     $loader = XML::createFromFile(__DIR__ . '/../../../../assets/xml/example.xml');
     $writer = new Memory();
     $delegator = new ReaderWriterDelegator($loader, $writer);
     $this->assertSame($loader, $delegator->getReader());
     $this->assertSame($writer, $delegator->getWriter());
     $this->assertContains('Memory', $delegator->toString());
     $this->assertContains('XML', $delegator->toString());
     $this->assertContains('Memory', $delegator . '');
     $this->assertContains('XML', $delegator . '');
 }
 /**
  * @test
  */
 public function shouldBehave()
 {
     $loader = XML::createFromFile(__DIR__ . '/../../../../assets/xml/example.xml');
     $writer = new Memory();
     Memory::clear();
     $delegator = new ReaderWriterDelegator($loader, $writer);
     $this->assertSame($loader, $delegator->getReader());
     $this->assertSame($writer, $delegator->getWriter());
     $this->assertContains('Memory', $delegator->toString());
     $this->assertContains('XML', $delegator->toString());
     $this->assertContains('Memory', $delegator . '');
     $this->assertContains('XML', $delegator . '');
     $this->assertCount(0, $delegator->getEntityIds('test'));
     $this->assertFalse($delegator->isPersisted(new Identifier('123', 'bogus')));
     $delegator->setFailedTransition(new Identifier('foo', 'bar'), new Transition(new State('foo'), new State('bar')), new \Exception('bogus'));
 }
 /**
  * @test
  */
 public function shouldThrowExceptionForNoMachineData()
 {
     $machine = new StateMachine(new Context(new Identifier('xml-test', 'xml-machine')));
     $loader = XML::createFromFile(__DIR__ . '/fixture-no-machines.xml');
     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());
     }
 }