diff --git a/tests/forms/EmailFieldTest.php b/tests/forms/EmailFieldTest.php index 62ee7c8db..c5019b0bf 100644 --- a/tests/forms/EmailFieldTest.php +++ b/tests/forms/EmailFieldTest.php @@ -1,6 +1,6 @@ assertTrue(false, $checkText . ": " . $e->GetMessage() . " (/$email/ did not pass validation, but was expected to)"); } } + + /** + * Check that input type='email' fields are submitted by SimpleTest + * + * @see SimpleTagBuilder::_createInputTag() + */ + function testEmailFieldPopulation() { + + $this->get('EmailFieldTest_Controller'); + $this->submitForm('Form_Form', null, array( + 'Email' => 'test@test.com' + )); + + $this->assertPartialMatchBySelector('p.good',array( + 'Test save was successful' + )); + } } class EmailFieldTest_Validator extends Validator { @@ -49,3 +66,47 @@ class EmailFieldTest_Validator extends Validator { public function php($data) { } } + +class EmailFieldTest_Controller extends Controller implements TestOnly { + + static $url_handlers = array( + '$Action//$ID/$OtherID' => "handleAction", + ); + + protected $template = 'BlankPage'; + + function Link($action = null) { + return Controller::join_links('EmailFieldTest_Controller', $this->request->latestParam('Action'), $this->request->latestParam('ID'), $action); + } + + function Form() { + $form = new Form( + $this, + 'Form', + new FieldList( + new EmailField('Email') + ), + new FieldList( + new FormAction('doSubmit') + ), + new RequiredFields( + 'Email' + ) + ); + + // Disable CSRF protection for easier form submission handling + $form->disableSecurityToken(); + + return $form; + } + + function doSubmit($data, $form, $request) { + $form->sessionMessage('Test save was successful', 'good'); + return $this->redirectBack(); + } + + function getViewer($action = null) { + return new SSViewer('BlankPage'); + } + +} diff --git a/thirdparty/simpletest/page.php b/thirdparty/simpletest/page.php index 54b26acfd..add422371 100644 --- a/thirdparty/simpletest/page.php +++ b/thirdparty/simpletest/page.php @@ -86,6 +86,7 @@ class SimpleTagBuilder { 'checkbox' => 'SimpleCheckboxTag', 'radio' => 'SimpleRadioButtonTag', 'text' => 'SimpleTextTag', + 'email' => 'SimpleTextTag', 'hidden' => 'SimpleTextTag', 'password' => 'SimpleTextTag', 'file' => 'SimpleUploadTag');