summaryrefslogtreecommitdiff
path: root/modules/simpletest/tests/ajax.test
diff options
context:
space:
mode:
Diffstat (limited to 'modules/simpletest/tests/ajax.test')
-rw-r--r--modules/simpletest/tests/ajax.test45
1 files changed, 45 insertions, 0 deletions
diff --git a/modules/simpletest/tests/ajax.test b/modules/simpletest/tests/ajax.test
index a3471dba5..580cd4add 100644
--- a/modules/simpletest/tests/ajax.test
+++ b/modules/simpletest/tests/ajax.test
@@ -141,3 +141,48 @@ class AJAXCommandsTestCase extends AJAXTestCase {
$this->assertTrue($command['command'] == 'restripe' && $command['selector'] == '#restripe_table', "'restripe' AJAX command issued with correct selector");
}
}
+
+/**
+ * Test that $form_state['values'] is properly delivered to $ajax['callback'].
+ */
+class AJAXFormValuesTestCase extends AJAXTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'AJAX command form values',
+ 'description' => 'Tests that form values are properly delivered to AJAX callbacks.',
+ 'group' => 'AJAX',
+ );
+ }
+
+ function setUp() {
+ parent::setUp();
+
+ $this->web_user = $this->drupalCreateUser(array('access content'));
+ $this->drupalLogin($this->web_user);
+ }
+
+ /**
+ * Create a simple form, then POST to system/ajax to change to it.
+ */
+ function testSimpleAJAXFormValue() {
+ // Verify form values of a select element.
+ foreach(array('red', 'green', 'blue') as $item) {
+ $edit = array(
+ 'select' => $item,
+ );
+ $commands = $this->drupalPostAJAX('ajax_forms_test_get_form', $edit, 'select');
+ $data_command = $commands[2];
+ $this->assertEqual($data_command['value'], $item);
+ }
+
+ // Verify form values of a checkbox element.
+ foreach(array(FALSE, TRUE) as $item) {
+ $edit = array(
+ 'checkbox' => $item,
+ );
+ $commands = $this->drupalPostAJAX('ajax_forms_test_get_form', $edit, 'checkbox');
+ $data_command = $commands[2];
+ $this->assertEqual((int) $data_command['value'], (int) $item);
+ }
+ }
+}