summaryrefslogtreecommitdiff
path: root/modules/simpletest/tests/form.test
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-03-21 21:31:34 +0000
committerDries Buytaert <dries@buytaert.net>2010-03-21 21:31:34 +0000
commit3a60a9b8cf43b1058070a1b535c0cb729a87fd03 (patch)
tree028db66d78672a88fcfe63e74da12a17f8a2c1ae /modules/simpletest/tests/form.test
parent25feb96f6dd5d5f1a73249a6f63354537db58fd2 (diff)
downloadbrdo-3a60a9b8cf43b1058070a1b535c0cb729a87fd03.tar.gz
brdo-3a60a9b8cf43b1058070a1b535c0cb729a87fd03.tar.bz2
- Patch #735808 by fago: fix multiple field value form to work with form API persistence. Added tests.
Diffstat (limited to 'modules/simpletest/tests/form.test')
-rw-r--r--modules/simpletest/tests/form.test66
1 files changed, 66 insertions, 0 deletions
diff --git a/modules/simpletest/tests/form.test b/modules/simpletest/tests/form.test
index 87dd698d8..b19ca7655 100644
--- a/modules/simpletest/tests/form.test
+++ b/modules/simpletest/tests/form.test
@@ -849,3 +849,69 @@ class FormsProgrammaticTestCase extends DrupalWebTestCase {
}
}
}
+
+
+/**
+ * Tests rebuilding of arbitrary forms by altering them.
+ */
+class FormsArbitraryRebuildTestCase extends DrupalWebTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Rebuild arbitrary forms',
+ 'description' => 'Tests altering forms to be rebuilt so there are multiple steps.',
+ 'group' => 'Form API',
+ );
+ }
+
+ function setUp() {
+ parent::setUp('form_test');
+ // Auto-create a field for testing.
+ $field = array(
+ 'field_name' => 'test_multiple',
+ 'type' => 'text',
+ 'cardinality' => -1,
+ 'translatable' => FALSE,
+ );
+ field_create_field($field);
+
+ $instance = array(
+ 'object_type' => 'node',
+ 'field_name' => 'test_multiple',
+ 'bundle' => 'page',
+ 'label' => 'Test a multiple valued field',
+ 'widget' => array(
+ 'type' => 'text_textfield',
+ 'weight' => 0,
+ ),
+ );
+ field_create_instance($instance);
+ }
+
+ /**
+ * Tests a basic rebuild with the user registration form.
+ */
+ function testUserRegistrationRebuild() {
+ $edit = array(
+ 'name' => 'foo',
+ 'mail' => 'bar@example.com',
+ );
+ $this->drupalPost('user/register', $edit, 'Rebuild');
+ $this->assertText('Form rebuilt.');
+ $this->assertFieldByName('name', 'foo', 'Entered user name has been kept.');
+ $this->assertFieldByName('mail', 'bar@example.com', 'Entered mail address has been kept.');
+ }
+
+ /**
+ * Tests a rebuild caused by a multiple value field.
+ */
+ function testUserRegistrationMultipleField() {
+ $edit = array(
+ 'name' => 'foo',
+ 'mail' => 'bar@example.com',
+ );
+ $this->drupalPost('user/register', $edit, t('Add another item'), array('query' => array('field' => TRUE)));
+ $this->assertText('Test a multiple valued field', 'Form has been rebuilt.');
+ $this->assertFieldByName('name', 'foo', 'Entered user name has been kept.');
+ $this->assertFieldByName('mail', 'bar@example.com', 'Entered mail address has been kept.');
+ }
+}