mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX: Old version of SimpleTest does not recognise input fields of
type 'email'.
This commit is contained in:
parent
a86b54b3ed
commit
a602ba5941
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?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
|
* 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)");
|
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 {
|
class EmailFieldTest_Validator extends Validator {
|
||||||
@ -49,3 +66,47 @@ class EmailFieldTest_Validator extends Validator {
|
|||||||
public function php($data) {
|
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');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
1
thirdparty/simpletest/page.php
vendored
1
thirdparty/simpletest/page.php
vendored
@ -86,6 +86,7 @@ class SimpleTagBuilder {
|
|||||||
'checkbox' => 'SimpleCheckboxTag',
|
'checkbox' => 'SimpleCheckboxTag',
|
||||||
'radio' => 'SimpleRadioButtonTag',
|
'radio' => 'SimpleRadioButtonTag',
|
||||||
'text' => 'SimpleTextTag',
|
'text' => 'SimpleTextTag',
|
||||||
|
'email' => 'SimpleTextTag',
|
||||||
'hidden' => 'SimpleTextTag',
|
'hidden' => 'SimpleTextTag',
|
||||||
'password' => 'SimpleTextTag',
|
'password' => 'SimpleTextTag',
|
||||||
'file' => 'SimpleUploadTag');
|
'file' => 'SimpleUploadTag');
|
||||||
|
Loading…
Reference in New Issue
Block a user