/** * @test */ public function shouldLoadTransitionsFromYAMLString() { $machine = new StateMachine(new Context(new Identifier('yaml-test', 'yaml-machine'))); $this->assertCount(0, $machine->getTransitions()); $yaml = $this->getYAML(); $loader = new YAML($yaml); $this->assertEquals($this->getYAML(), $loader->getYAML()); $count = $loader->load($machine); $this->assertCount(2, $machine->getTransitions()); $this->assertEquals(2, $count); $tbd = $machine->getTransition('b_to_done'); $b = $tbd->getStateFrom(); $d = $tbd->getStateTo(); $tab = $machine->getTransition('a_to_b'); $a = $tab->getStateFrom(); $this->assertEquals($b, $tab->getStateTo()); $this->assertSame($b, $tab->getStateTo()); $this->assertTrue($a->isInitial()); $this->assertTrue($b->isNormal()); $this->assertTrue($d->isFinal()); }