summaryrefslogtreecommitdiff
path: root/modules/simpletest/tests/form.test
diff options
context:
space:
mode:
Diffstat (limited to 'modules/simpletest/tests/form.test')
-rw-r--r--modules/simpletest/tests/form.test47
1 files changed, 46 insertions, 1 deletions
diff --git a/modules/simpletest/tests/form.test b/modules/simpletest/tests/form.test
index 5aa7e4aa3..d1bb171e1 100644
--- a/modules/simpletest/tests/form.test
+++ b/modules/simpletest/tests/form.test
@@ -589,7 +589,7 @@ class FormValidationTestCase extends DrupalWebTestCase {
*/
function testValidateLimitErrors() {
$edit = array(
- 'test' => 'invalid',
+ 'test' => 'invalid',
'test_numeric_index[0]' => 'invalid',
'test_substring[foo]' => 'invalid',
);
@@ -1170,6 +1170,51 @@ class FormStateValuesCleanTestCase extends DrupalWebTestCase {
}
/**
+ * Tests $form_state clearance with form elements having buttons.
+ */
+class FormStateValuesCleanAdvancedTestCase extends DrupalWebTestCase {
+ /**
+ * An image file path for uploading.
+ */
+ protected $image;
+
+ public static function getInfo() {
+ return array(
+ 'name' => 'Form state values clearance (advanced)',
+ 'description' => 'Test proper removal of submitted form values using form_state_values_clean() when having forms with elements containing buttons like "managed_file".',
+ 'group' => 'Form API',
+ );
+ }
+
+ function setUp() {
+ parent::setUp('form_test');
+ }
+
+ /**
+ * Tests form_state_values_clean().
+ */
+ function testFormStateValuesCleanAdvanced() {
+
+ // Get an image for uploading.
+ $image_files = $this->drupalGetTestFiles('image');
+ $this->image = current($image_files);
+
+ // Check if the physical file is there.
+ $this->assertTrue(is_file($this->image->uri), t("The image file we're going to upload exists."));
+
+ // "Browse" for the desired file.
+ $edit = array('files[image]' => drupal_realpath($this->image->uri));
+
+ // Post the form.
+ $this->drupalPost('form_test/form-state-values-clean-advanced', $edit, t('Submit'));
+
+ // Expecting a 200 HTTP code.
+ $this->assertResponse(200, t('Received a 200 response for posted test file.'));
+ $this->assertRaw(t('You WIN!'), t('Found the success message.'));
+ }
+}
+
+/**
* Tests form rebuilding.
*
* @todo Add tests for other aspects of form rebuilding.