dox Executable Documentation

Show preparation form

The only reason a form is ever presented is to fill the missing properties of an Action during preparation.

Input for missing properties

Given the action argument 'one' is 'uno'
When I execute 'PrepareAction'
Then the title should be 'Prepare Action'
Then there should be a hidden field 'action' with value 'PrepareAction'
Then there should be 2 fields
Then field 1 should have the label 'One'
Then field 1 should be have the name 'args[one]'
Then field 1 should the value 'uno'
Then field 2 should be have the name 'args[two]'
Then field 2 should have no value

Un camel case labels

Given the class 'camelCase\\Action' with the body ' public $someProperty; '
Given I set an empty handler for 'camelCase\\Action'
When I execute 'camelCase\\Action'
Then there should be 1 fields
Then field 1 should have the label 'Some Property'

Get form definition from representer

Given the class 'MySpecialField' extending '\\watoki\\qrator\\form\\Field' with the body ' public function render() { return "Hello World"; } '
Given I registered an action representer for 'PrepareAction'
Given I set the field for 'one' to 'MySpecialField' for 'PrepareAction'
When I execute 'PrepareAction'
Then field 1 should be rendered as 'Hello World'

Pre fill form

Given the class 'PreFillingAction' with the body ' public $one; public $two; public $three; '
Given I set an empty handler for 'PreFillingAction'
Given the action argument 'two' is 'SeventyThree'
Given I registered an action representer for 'PreFillingAction'
Given I have set for 'PreFillingAction' the prefiller function ($fields) { /** @var \watoki\qrator\form\Field[] $fields */ $fields['one']->setValue('FortyTwo'); }
When I execute 'PreFillingAction'
Then field 1 should the value 'FortyTwo'
Then field 2 should the value 'SeventyThree'
Then field 3 should have no value

Pre fill form without action instance

Given the class 'PreFillingActionWithoutInstance' with the body ' public $two; function __construct($one) {} '
Given I set an empty handler for 'PreFillingActionWithoutInstance'
Given the action argument 'one' is 'FortyTwo'
When I execute 'PreFillingActionWithoutInstance'
Then field 1 should the value 'FortyTwo'

Hide label of hidden fields

Given the class 'ActionWithHiddenField' with the body ' public $foo; '
Given I set an empty handler for 'ActionWithHiddenField'
Given I set the field 'foo' of 'ActionWithHiddenField' to new HiddenField('foo')
When I execute 'ActionWithHiddenField'
Then there should be 1 fields
Then field 1 should be invisible

Make fields required

Given the class 'preparation\\ActionWithConstructor' with the body ' public $one; public $two; public $three; function __construct($one, $two = null) {} '
Given I set an empty handler for 'preparation\\ActionWithConstructor'
Given the action argument 'one' is 'uno'
When I execute 'preparation\\ActionWithConstructor'
Then there should be 3 fields
Then field 1 should be required
Then field 2 should not be required
Then field 3 should not be required

Action with missing constructor arguments

Given the class 'preparation\\IncompleteConstructor' with the body ' public $three; function __construct($one, $two) {} function setFour($f) {} '
When I execute 'preparation\\IncompleteConstructor'
Then there should be 4 fields

Fill form with default values

Given the class 'defaultValue\\SomeAction' with the body ' public $three = "tres"; public $two; function __construct($one, $two = "dos") {} '
When I execute 'defaultValue\\SomeAction'
Then there should be 3 fields
Then field 1 should have no value
Then field 2 should the value 'dos'
Then field 3 should the value 'tres'

background

Given the class 'PrepareAction' with the body ' public $one; public $two; '
Given I set an empty handler for 'PrepareAction'