function performMapDataspaceToEntity()
 {
     $state_machine = new StateMachineCommand($this);
     $state_machine->registerState('PutSomeDataToDataspace', array(LIMB_STATUS_OK => 'DefaultMapDataspaceToEntity', LIMB_STATUS_ERROR => 'Error'));
     $state_machine->registerState('DefaultMapDataspaceToEntity');
     return $state_machine->perform();
 }
  function StateMachineForFormProcessing(&$factory)
  {
    parent :: StateMachineCommand($factory);

    $this->registerState('Init',
                          array(LIMB_STATUS_FORM_SUBMITTED => 'Validate'));

    $this->registerState('Validate');
  }
  function StateMachineForPageRendering(&$factory)
  {
    parent :: StateMachineCommand($factory);

    $this->registerState('Initial',
                          array(LIMB_STATUS_OK => 'Render'));

    $this->registerState('Render');
  }
 function StateMachineForDeleteEntity(&$factory)
 {
     parent::StateMachineCommand($factory);
     $this->registerState('InitEntity', array(LIMB_STATUS_OK => 'DeleteEntity', LIMB_STATUS_ERROR => 'NotFound'));
     $this->registerState('DeleteEntity', array(LIMB_STATUS_OK => 'Redirect', LIMB_STATUS_ERROR => 'Error'));
     $this->registerState('Error', array(LIMB_STATUS_OK => 'Render'));
     $this->registerState('Redirect');
     $this->registerState('NotFound', array(LIMB_STATUS_OK => 'Render'));
     $this->registerState('Render');
 }
 function StateMachineForEditEntityDialog(&$factory)
 {
     parent::StateMachineCommand($factory);
     $this->registerState('InitDialog', array(LIMB_STATUS_OK => 'InitEntity'));
     $this->registerState('InitEntity', array(LIMB_STATUS_OK => 'FormProcessing', LIMB_STATUS_ERROR => 'NotFound'));
     $this->registerState('FormProcessing', array(LIMB_STATUS_OK => 'MapDataspaceToEntity', LIMB_STATUS_FORM_DISPLAYED => 'InitDataspace', LIMB_STATUS_FORM_NOT_VALID => 'Render'));
     $this->registerState('InitDataspace', array(LIMB_STATUS_OK => 'Render', LIMB_STATUS_ERROR => 'Error'));
     $this->registerState('MapDataspaceToEntity', array(LIMB_STATUS_OK => 'Redirect'));
     $this->registerState('Redirect');
     $this->registerState('Error', array(LIMB_STATUS_OK => 'Render'));
     $this->registerState('NotFound', array(LIMB_STATUS_OK => 'Render'));
     $this->registerState('Render');
 }
  function testGetStateHistoryAllCommandsInHistory()
  {
    $factory = new MockCommandsFactory($this);
    $state_machine = new StateMachineCommand($factory);

    $state_machine->registerState('Initial', array('foo' => 'NextState'));
    $state_machine->registerState('NextState', array('bar' => 'ExtraState'));
    $state_machine->registerState('ExtraState');

    $factory->expectOnce('performInitial');
    $factory->setReturnValue('performInitial', 'foo');
    $factory->expectOnce('performNextState');
    $factory->setReturnValue('performNextState', 'bar');
    $factory->expectOnce('performExtraState');
    $factory->setReturnValue('performExtraState', 'some_result');

    $this->assertEqual($state_machine->perform(), 'some_result');

    $this->assertEqual($state_machine->getStateHistory(),
                       array(array('Initial' => 'foo'),
                             array('NextState' => 'bar'),
                             array('ExtraState' => 'some_result')));

    $this->assertEqual($state_machine->getEndState(), array('ExtraState' => 'some_result'));

    $factory->tally();
  }