setEntryCallable() public method

set the entry callable, the callable to be called when entering this state
public setEntryCallable ( callable $callable )
$callable callable
 /**
  * @test
  */
 public function shouldEnterWithCallable()
 {
     $state = new State('a');
     $context = new Context(new Identifier('123', 'foo-machine'));
     $event = 'foo';
     $callable = function ($entity) {
         $entity->setEntityId('234');
     };
     $state->setEntryCallable($callable);
     $this->assertEquals('123', $context->getEntityId());
     $state->exitAction($context);
     $this->assertEquals('123', $context->getEntityId());
     $state->entryAction($context);
     $this->assertEquals('234', $context->getEntityId());
 }
 /**
  * @test
  */
 public function shouldFailEntryAndExitWithNonCallable()
 {
     $state = new State('a');
     $context = new Context(new Identifier('123', 'foo-machine'));
     $event = 'foo';
     $callable = "Foo::BarEntry";
     $state->setEntryCallable($callable);
     $callable = "Foo::BarExit";
     $state->setExitCallable($callable);
     try {
         $state->entryAction($context);
         $this->fail('should not come here');
     } catch (Exception $e) {
         $this->assertEquals(Exception::CALLABLE_FAILURE, $e->getCode());
     }
     try {
         $state->exitAction($context);
         $this->fail('should not come here');
     } catch (Exception $e) {
         $this->assertEquals(Exception::CALLABLE_FAILURE, $e->getCode());
     }
 }
 /**
  * https://github.com/rolfvreijdenberger/izzum-statemachine/issues/7
  * @test
  */
 public function shouldFailConfigurationCheckForMachineWithBadCallables()
 {
     $transitions = array();
     $s1 = new State("1");
     $s1->setEntryCallable('foobar');
     $s2 = new State("2");
     $s2->setEntryCallable('foobar');
     $s3 = new State("3");
     $s3->setEntryCallable('foobar');
     $transitions[] = new Transition($s1, $s2);
     $transitions[] = new Transition($s2, $s3);
     //3 states, 3 bad callables
     //2 transitions, 4 bad callables
     //total of 7
     foreach ($transitions as $transition) {
         $transition->setGuardCallable('foobar');
         $transition->setTransitionCallable('foobar');
     }
     $loader = new LoaderArray($transitions);
     $context = new Context(new Identifier(Identifier::NULL_ENTITY_ID, Identifier::NULL_STATEMACHINE));
     $machine = new StateMachine($context);
     $loader->load($machine);
     $exceptions = Utils::checkConfiguration($machine);
     $this->assertEquals(7, count($exceptions));
     $this->assertTrue(true, 'basic machine with bad callables will be configured incorrectly');
 }