Permalink
Browse files

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

type 'email'.
  • Loading branch information...
1 parent a86b54b commit a602ba5941286bc57934c9b60c2edbb150f03aed @frankmullenger frankmullenger committed Sep 28, 2012
Showing with 63 additions and 1 deletion.
  1. +62 −1 tests/forms/EmailFieldTest.php
  2. +1 −0 thirdparty/simpletest/page.php
@@ -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 @@ public function internalCheck($email, $checkText, $expectSuccess) {
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 @@ public function javascript() {
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');
+ }
+
+}
@@ -86,6 +86,7 @@ function _createInputTag($attributes) {
'checkbox' => 'SimpleCheckboxTag',
'radio' => 'SimpleRadioButtonTag',
'text' => 'SimpleTextTag',
+ 'email' => 'SimpleTextTag',
'hidden' => 'SimpleTextTag',
'password' => 'SimpleTextTag',
'file' => 'SimpleUploadTag');

0 comments on commit a602ba5

Please sign in to comment.