dox Executable Documentation

Execute actions

Action requests are prepared, executed and then either the result is shown or the user is redirected to the last Action.

Action reaches handler

Given the class 'MyAction'
Given the class 'reach\\MyHandler' with the body ' function myAction() { $GLOBALS["handlerReached"] = true; } '
Given I registered an action representer for 'MyAction'
Given I added the class 'reach\\MyHandler' as handler for 'MyAction'
When I execute the action 'MyAction'
Then '$GLOBALS[\'handlerReached\']' should be true

Store last action in cookie

Given the class 'MyAction'
Given an object 'myHandler'
Given I registered an action representer for 'MyAction'
Given I set 'myHandler' as handler for 'MyAction'
Given the action argument 'one' is 'uno'
Given the action argument 'two' is 'dos'
When I execute the action 'MyAction'
Then 'MyAction' with arguments array('one' => 'uno', 'two' => 'dos') should be stored as last action

Redirect to last action from cookie

Given the last action was 'MyAction' with arguments array('one' => 'eins', 'two' => 'zwei')
Given I registered an action representer for 'MyAction'
Given I set an empty handler for 'MyAction'
When I execute the action 'MyAction'
Then I should be redirected to 'execute?action=MyAction&args[one]=eins&args[two]=zwei'

Do not redirect if result is empty array

Given the last action was 'MyAction' with arguments array('one' => 'eins', 'two' => 'zwei')
Given I added the closure function () { return array(); } as handler for 'MyAction'
When I execute the action 'MyAction'
Then an alert should say 'Empty result.'

Action with constructor arguments

Given the class 'test\\ConstructorAction' with the body ' function __construct($one, $two) { $GLOBALS["one"] = $one; $GLOBALS["two"] = $two; } '
Given I registered an action representer for 'test\\ConstructorAction'
Given I set an empty handler for 'test\\ConstructorAction'
Given the action argument 'one' is 'uno'
Given the action argument 'two' is 'dos'
When I execute the action 'test\\ConstructorAction'
Then '$GLOBALS[\'one\']' should be 'uno'
Then '$GLOBALS[\'two\']' should be 'dos'

Follow up action

Given the class 'ActionWithFollowUp'
Given the class 'FollowUpAction'
Given I set 'FollowUpAction' to follow after 'ActionWithFollowUp'
Given I set an empty handler for 'ActionWithFollowUp'
When I execute the action 'ActionWithFollowUp'
Then I should be redirected to 'execute?action=FollowUpAction'

Follow up action generator get result of followed action

Given the class 'FollowUpActionWithProperty' with the body 'public $foo;'
Given the class 'FollowUpAction'
Given I set 'FollowUpActionWithProperty' to follow after 'ActionWithFollowUp' with '["foo" => $result]'
Given I added the closure function () { return 'baz'; } as handler for 'ActionWithFollowUp'
When I execute the action 'ActionWithFollowUp'
Then I should be redirected to 'execute?action=FollowUpActionWithProperty&args[foo]=baz'

Throw exceptions

Given I added the closure function () { throw new \Exception('Something went wrong'); } as handler for 'MyAction'
When I execute the action 'MyAction'
Then it should show the error 'Something went wrong'

Edge case do not redirect on injection exception during execution

Given I added the closure function () { throw new InjectionException('Something went wrong'); } as handler for 'MyAction'
When I execute the action 'MyAction'
Then it should show the error 'Something went wrong'