BUGFIX: Old version of SimpleTest does not recognise input fields of

type 'email'.
This commit is contained in:
Frank Mullenger 2012-09-28 12:02:13 +12:00
parent a86b54b3ed
commit a602ba5941
2 changed files with 63 additions and 1 deletions

View File

@ -1,6 +1,6 @@
<?php
class EmailFieldTest extends SapphireTest {
class EmailFieldTest extends FunctionalTest {
/**
* Check the php validator for email addresses. We should be checking against RFC 5322 which defines email address
@ -36,6 +36,23 @@ class EmailFieldTest extends SapphireTest {
else if ($expectSuccess) $this->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');
}
}

View File

@ -86,6 +86,7 @@ class SimpleTagBuilder {
'checkbox' => 'SimpleCheckboxTag',
'radio' => 'SimpleRadioButtonTag',
'text' => 'SimpleTextTag',
'email' => 'SimpleTextTag',
'hidden' => 'SimpleTextTag',
'password' => 'SimpleTextTag',
'file' => 'SimpleUploadTag');