/** * @test */ public function shouldNotBeAllowedToTransitionByCallable() { $context = new Context(new Identifier('123', 'foo-machine')); $event = 'foo'; $a = new State('a'); $b = new State('b'); $guard_callable = function ($entity) { return false; }; //scenario 1. inject in constructor $t = new Transition($a, $b, $event, null, null, $guard_callable); $this->assertFalse($t->can($context)); $t->setGuardCallable(Transition::CALLABLE_NULL); $this->assertTrue($t->can($context)); //scenario 2. do not inject in constructor $t = new Transition($a, $b, $event); $this->assertTrue($t->can($context)); $t->setGuardCallable($guard_callable); $this->assertFalse($t->can($context)); //scenario 3. callable does not return a boolean $guard_callable = function ($entity) { }; $t = new Transition($a, $b, $event, null, null, $guard_callable); $this->assertFalse($t->can($context)); }