summaryrefslogtreecommitdiffstatshomepage
path: root/modules/simpletest
diff options
context:
space:
mode:
Diffstat (limited to 'modules/simpletest')
-rw-r--r--modules/simpletest/tests/ajax.test9
-rw-r--r--modules/simpletest/tests/ajax_forms_test.module19
2 files changed, 28 insertions, 0 deletions
diff --git a/modules/simpletest/tests/ajax.test b/modules/simpletest/tests/ajax.test
index 2788d4f90b77..2a2469334d39 100644
--- a/modules/simpletest/tests/ajax.test
+++ b/modules/simpletest/tests/ajax.test
@@ -211,6 +211,15 @@ class AJAXCommandsTestCase extends AJAXTestCase {
);
$this->assertCommand($commands, $expected, "'data' AJAX command issued with correct key and value");
+ // Tests the 'invoke' command.
+ $commands = $this->drupalPostAJAX($form_path, $edit, array('op' => t("AJAX invoke command: Invoke addClass() method.")));
+ $expected = array(
+ 'command' => 'invoke',
+ 'method' => 'addClass',
+ 'arguments' => array('error'),
+ );
+ $this->assertCommand($commands, $expected, "'invoke' AJAX command issued with correct method and argument");
+
// Tests the 'html' command.
$commands = $this->drupalPostAJAX($form_path, $edit, array('op' => t("AJAX html: Replace the HTML in a selector.")));
$expected = array(
diff --git a/modules/simpletest/tests/ajax_forms_test.module b/modules/simpletest/tests/ajax_forms_test.module
index 531c703fda68..21784dfa353c 100644
--- a/modules/simpletest/tests/ajax_forms_test.module
+++ b/modules/simpletest/tests/ajax_forms_test.module
@@ -176,6 +176,16 @@ function ajax_forms_test_ajax_commands_form($form, &$form_state) {
'#suffix' => '<div id="data_div">Data attached to this div.</div>',
);
+ // Shows the AJAX 'invoke' command.
+ $form['invoke_command_example'] = array(
+ '#value' => t("AJAX invoke command: Invoke addClass() method."),
+ '#type' => 'submit',
+ '#ajax' => array(
+ 'callback' => 'ajax_forms_test_advanced_commands_invoke_callback',
+ ),
+ '#suffix' => '<div id="invoke_div">Original contents</div>',
+ );
+
// Shows the AJAX 'html' command.
$form['html_command_example'] = array(
'#value' => t("AJAX html: Replace the HTML in a selector."),
@@ -332,6 +342,15 @@ function ajax_forms_test_advanced_commands_data_callback($form, $form_state) {
}
/**
+ * AJAX callback for 'invoke'.
+ */
+function ajax_forms_test_advanced_commands_invoke_callback($form, $form_state) {
+ $commands = array();
+ $commands[] = ajax_command_invoke('#invoke_div', 'addClass', array('error'));
+ return array('#type' => 'ajax', '#commands' => $commands);
+}
+
+/**
* AJAX callback for 'html'.
*/
function ajax_forms_test_advanced_commands_html_callback($form, $form_state) {