izzum\statemachine\StateTest::shouldExecuteEntryAndExitAction PHP Method

shouldExecuteEntryAndExitAction() public method

    public function shouldExecuteEntryAndExitAction()
    {
        // scenario 1
        $context = new Context(new Identifier('1', 'test'));
        $command_name = 'izzum\\command\\ExceptionCommand';
        $state = new State('a', State::TYPE_INITIAL, $command_name);
        $this->assertEquals($command_name, $state->getEntryCommandName());
        $this->assertEquals('', $state->getExitCommandName());
        try {
            $state->entryAction($context);
            $this->fail('should not come here');
        } catch (\Exception $e) {
            $this->assertEquals(Exception::COMMAND_EXECUTION_FAILURE, $e->getCode());
        }
        // null command
        $state->exitAction($context);
        // scenario 2
        $context = new Context(new Identifier('1', 'test'));
        $command_name = 'izzum\\command\\ExceptionCommand';
        $state = new State('a', State::TYPE_INITIAL, State::COMMAND_EMPTY, $command_name);
        $this->assertEquals($command_name, $state->getExitCommandName());
        $this->assertEquals('', $state->getEntryCommandName());
        // null command
        $state->entryAction($context);
        try {
            $state->exitAction($context);
            $this->fail('should not come here');
        } catch (\Exception $e) {
            $this->assertEquals(Exception::COMMAND_EXECUTION_FAILURE, $e->getCode());
        }
    }