Updated frameworktest to allow for testing of DateField_Disabled, and to allow for testing both inside and outside the CMS

This commit is contained in:
Sam Minnee 2008-10-02 22:38:34 +00:00
parent 236711fe4d
commit 32730154e1
2 changed files with 19 additions and 1 deletions

View File

@ -9,6 +9,7 @@ class BasicFieldsTestPage extends TestPage {
'CalendarDate' => 'Date', 'CalendarDate' => 'Date',
'CompositeDate' => 'Date', 'CompositeDate' => 'Date',
'Date' => 'Date', 'Date' => 'Date',
"DateDisabled" => "Date",
'DMYCalendarDate' => 'Date', 'DMYCalendarDate' => 'Date',
'DMYDate' => 'Date', 'DMYDate' => 'Date',
'DropdownTime' => 'Time', 'DropdownTime' => 'Time',
@ -46,6 +47,7 @@ class BasicFieldsTestPage extends TestPage {
static $defaults = array( static $defaults = array(
'Readonly' => 'Default value for \'readonly\'', 'Readonly' => 'Default value for \'readonly\'',
"DateDisabled" => "2002-10-23",
); );
function getCMSFields() { function getCMSFields() {
@ -83,6 +85,7 @@ class BasicFieldsTestPage extends TestPage {
new CalendarDateField('CalendarDate','CalendarDateField'), new CalendarDateField('CalendarDate','CalendarDateField'),
new CompositeDateField('CompositeDate','CompsiteDateField'), new CompositeDateField('CompositeDate','CompsiteDateField'),
new DateField('Date','DateField'), new DateField('Date','DateField'),
new DateField_Disabled("DateDisabled","DateField_Disabled (should be 2002-10-23)"),
new DMYCalendarDateField('DMYCalendarDate','DMYCalendarDateField'), new DMYCalendarDateField('DMYCalendarDate','DMYCalendarDateField'),
new DMYDateField('DMYDate','DMYDateField'), new DMYDateField('DMYDate','DMYDateField'),
new DropdownTimeField('DropdownTime','DropdownTimeField'), new DropdownTimeField('DropdownTime','DropdownTimeField'),
@ -114,4 +117,4 @@ class BasicFieldsTestPage_Controller extends TestPage_Controller {
} }
} }
?> ?>

View File

@ -31,6 +31,21 @@ class TestPage extends Page {
* Parent class of all test page controllers * Parent class of all test page controllers
*/ */
class TestPage_Controller extends Page_Controller { class TestPage_Controller extends Page_Controller {
/**
* This form is exactly like the CMS form. It gives us an opportunity to test the fields outside of the CMS context
*/
function Form() {
$fields = $this->getCMSFields();
$actions = new FieldSet(new FormAction("save", "Save"));
$form = new Form($this, "Form", $fields, $actions);
$form->loadDataFrom($this->dataRecord);
return $form;
}
function save($data, $form) {
$form->saveInto($this->dataRecord);
$this->dataRecord->write();
Director::redirectBack();
}
} }
?> ?>