dox Executable Documentation

Show action result

Actions are executed and the object or array ob objects presented together with their actions.

No actions

Given I added the closure function () { return new \StdClass(); } as handler for 'MyAction'
When I show the results of 'MyAction'
Then the title shouldbe 'My Action'
Then the name should be 'std Class'
Then there should be no actions
Then the 'table' should not be shown

Display actions

Given I added the closure function () { return new \DateTime(); } as handler for 'MyAction'
Given I registered an entity representer for 'DateTime'
Given I added the action 'ActionOne' to the representer of 'DateTime'
Given I added the action 'ActionTwo' to the representer of 'DateTime'
Given I added the action 'AnotherOne' to the representer of 'DateTime'
Given I added the action 'AnotherTwo' to the representer of 'DateTime'
Given I added the action 'AnotherThree' to the representer of 'DateTime'
When I show the results of 'MyAction'
Then there should be 5 actions
Then action 1 should have the caption 'Action One'
Then action 1 should link to 'execute?action=ActionOne'
Then action 3 should have the caption 'Another One'
Then action 3 should link to 'execute?action=AnotherOne'

Actions with confirmation

Given I added the closure function () { return new \DateTime(); } as handler for 'MyAction'
Given I registered an entity representer for 'DateTime'
Given I added the action 'ActionOne' to the representer of 'DateTime'
Given I added the action 'ActionTwo' to the representer of 'DateTime'
Given I added the action 'ActionThree' to the representer of 'DateTime'
Given I set 'ActionOne' to require confirmation
Given I set 'ActionTwo' to require confirmation with 'Really?'
When I show the results of 'MyAction'
Then there should be 3 actions
Then action 1 should require confirming 'Really Action One?'
Then action 2 should require confirming 'Really?'
Then action 3 should not require confirmation

Display collection

Given I added the closure function () { return array(new \DateTime(), new \DateTime(), new \DateTime()); } as handler for 'MyAction'
Given I registered an entity representer for 'DateTime'
Given I added the action 'ActionOne' to the representer of 'DateTime'
Given I added the action 'AnotherOne' to the representer of 'DateTime'
When I show the results of 'MyAction'
Then there should be 3 entities
Then entity 1 should have 3 properties
Then entity 1 should have 2 actions
Then the 'list' should not be shown

Display collection object

Given I added the closure function () { return new Liste(array(new \StdClass(), new \StdClass())); } as handler for 'MyAction'
When I show the results of 'MyAction'
Then there should be 2 entities

Entity actions with argument

Given the class 'property\\Entity' with the body ' public $id = "42"; '
Given the class 'property\\MyHandler' with the body ' function myAction() { return new Entity(); } '
Given I added the class 'property\\MyHandler' as handler for 'MyAction'
Given I registered an entity representer for 'property\\Entity'
Given I added the action 'SomeAction' to the representer of 'property\\Entity'
Given I added the action 'SomeAnother' to the representer of 'property\\Entity'
When I show the results of 'MyAction'
Then action 1 should link to 'execute?action=SomeAction&args[id]=42'
Then action 2 should link to 'execute?action=SomeAnother&args[id]=42'

No result

Given I added the closure function () { return null; } as handler for 'MyAction'
When I show the results of 'MyAction'
Then an alert should say 'Empty result.'
Then 'isPreparing' should be false

Result is a response

Given I added the closure function () { return new WebResponse('Hello World'); } as handler for 'MyAction'
When I show the results of 'MyAction'
Then the response body should be 'Hello World'

Result is a responder

Given I added the closure function () { return new MultiResponder('Hey there'); } as handler for 'MyAction'
When I show the results of 'MyAction'
Then it should return new MultiResponder('Hey there')

background

Given the class 'MyAction'