From 8c08ea2561b6da5a97777312ebf60d295dbbdb1e Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Fri, 30 Apr 2010 08:07:55 +0000 Subject: - Patch #645800 by katbailey, effulgentsia, rfay: ajax_deliver() ignores #ajax['method'] and incorrectly forces 'replaceWith' for simple AJAX callbacks, D6->D7 regression. --- modules/simpletest/tests/ajax.test | 5 +++++ modules/simpletest/tests/ajax_forms_test.module | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) (limited to 'modules/simpletest/tests') diff --git a/modules/simpletest/tests/ajax.test b/modules/simpletest/tests/ajax.test index 80ea29f58..97cd2f5d2 100644 --- a/modules/simpletest/tests/ajax.test +++ b/modules/simpletest/tests/ajax.test @@ -146,6 +146,11 @@ class AJAXCommandsTestCase extends AJAXTestCase { $command = $commands[0]; $this->assertTrue($command['command'] == 'insert' && $command['method'] == 'html' && $command['data'] == 'replacement text', "'html' AJAX command issued with correct data"); + // Tests the 'insert' command. + $commands = $this->discardSettings($this->drupalPostAJAX($form_path, $edit, array('op' => t("AJAX insert: Let client insert based on #ajax['method'].")))); + $command = $commands[0]; + $this->assertTrue($command['command'] == 'insert' && $command['method'] == NULL && $command['data'] == 'insert replacement text', "'insert' AJAX command issued with correct data"); + // Tests the 'prepend' command. $commands = $this->discardSettings($this->drupalPostAJAX($form_path, $edit, array('op' => t("AJAX 'prepend': Click to prepend something")))); $command = $commands[0]; diff --git a/modules/simpletest/tests/ajax_forms_test.module b/modules/simpletest/tests/ajax_forms_test.module index 5de2b842c..db8aa3b92 100644 --- a/modules/simpletest/tests/ajax_forms_test.module +++ b/modules/simpletest/tests/ajax_forms_test.module @@ -186,6 +186,17 @@ function ajax_forms_test_ajax_commands_form($form, &$form_state) { '#suffix' => '
Original contents
', ); + // Shows the AJAX 'insert' command. + $form['insert_command_example'] = array( + '#value' => t("AJAX insert: Let client insert based on #ajax['method']."), + '#type' => 'submit', + '#ajax' => array( + 'callback' => 'ajax_forms_test_advanced_commands_insert_callback', + 'method' => 'prepend', + ), + '#suffix' => '
Original contents
', + ); + // Shows the AJAX 'prepend' command. $form['prepend_command_example'] = array( '#value' => t("AJAX 'prepend': Click to prepend something"), @@ -320,6 +331,15 @@ function ajax_forms_test_advanced_commands_html_callback($form, $form_state) { return array('#type' => 'ajax', '#commands' => $commands); } +/** + * AJAX callback for 'insert'. + */ +function ajax_forms_test_advanced_commands_insert_callback($form, $form_state) { + $commands = array(); + $commands[] = ajax_command_insert('#insert_div', 'insert replacement text'); + return array('#type' => 'ajax', '#commands' => $commands); +} + /** * AJAX callback for 'prepend'. */ -- cgit v1.2.3