summaryrefslogtreecommitdiff
path: root/modules/simpletest/tests
diff options
context:
space:
mode:
Diffstat (limited to 'modules/simpletest/tests')
-rw-r--r--modules/simpletest/tests/ajax.test15
-rw-r--r--modules/simpletest/tests/form.test6
-rw-r--r--modules/simpletest/tests/form_test.file.inc13
3 files changed, 16 insertions, 18 deletions
diff --git a/modules/simpletest/tests/ajax.test b/modules/simpletest/tests/ajax.test
index 91572bda0..9377f4cdb 100644
--- a/modules/simpletest/tests/ajax.test
+++ b/modules/simpletest/tests/ajax.test
@@ -269,24 +269,17 @@ class AJAXMultiFormTestCase extends AJAXTestCase {
// of field items and "add more" button for the multi-valued field within
// each form.
$this->drupalGet('form-test/two-instances-of-same-form');
- foreach ($field_xpaths as $form_id => $field_xpath) {
+ foreach ($field_xpaths as $form_html_id => $field_xpath) {
$this->assert(count($this->xpath($field_xpath . $field_items_xpath_suffix)) == 1, t('Found the correct number of field items on the initial page.'));
$this->assertFieldByXPath($field_xpath . $button_xpath_suffix, NULL, t('Found the "add more" button on the initial page.'));
}
$this->assertNoDuplicateIds(t('Initial page contains unique IDs'), 'Other');
// Submit the "add more" button of each form twice. After each corresponding
- // page update, ensure the same as above. To successfully implement
- // consecutive AJAX submissions, we need to manage $settings as ajax.js
- // does for Drupal.settings.
- preg_match('/jQuery\.extend\(Drupal\.settings, (.*?)\);/', $this->content, $matches);
- $settings = drupal_json_decode($matches[1]);
- foreach ($field_xpaths as $form_id => $field_xpath) {
+ // page update, ensure the same as above.
+ foreach ($field_xpaths as $form_html_id => $field_xpath) {
for ($i=0; $i<2; $i++) {
- $button = $this->xpath($field_xpath . $button_xpath_suffix);
- $button_id = (string) $button[0]['id'];
- $commands = $this->drupalPostAJAX(NULL, array(), array($button_name => $button_value), 'system/ajax', array(), array(), $form_id, $settings['ajax'][$button_id]);
- $settings = array_merge_recursive($settings, $commands[0]['settings']);
+ $this->drupalPostAJAX(NULL, array(), array($button_name => $button_value), 'system/ajax', array(), array(), $form_html_id);
$this->assert(count($this->xpath($field_xpath . $field_items_xpath_suffix)) == $i+2, t('Found the correct number of field items after an AJAX submission.'));
$this->assertFieldByXPath($field_xpath . $button_xpath_suffix, NULL, t('Found the "add more" button after an AJAX submission.'));
$this->assertNoDuplicateIds(t('Updated page contains unique IDs'), 'Other');
diff --git a/modules/simpletest/tests/form.test b/modules/simpletest/tests/form.test
index c3ef7fd9d..969f3f398 100644
--- a/modules/simpletest/tests/form.test
+++ b/modules/simpletest/tests/form.test
@@ -996,11 +996,7 @@ class FormsRebuildTestCase extends DrupalWebTestCase {
// submission and verify it worked by ensuring the updated page has two text
// field items in the field for which we just added an item.
$this->drupalGet('node/add/page');
- preg_match('/jQuery\.extend\(Drupal\.settings, (.*?)\);/', $this->content, $matches);
- $settings = drupal_json_decode($matches[1]);
- $button = $this->xpath('//input[@name="field_ajax_test_add_more"]');
- $button_id = (string) $button[0]['id'];
- $this->drupalPostAJAX(NULL, array(), array('field_ajax_test_add_more' => t('Add another item')), 'system/ajax', array(), array(), 'page-node-form', $settings['ajax'][$button_id]);
+ $this->drupalPostAJAX(NULL, array(), array('field_ajax_test_add_more' => t('Add another item')), 'system/ajax', array(), array(), 'page-node-form');
$this->assert(count($this->xpath('//div[contains(@class, "field-name-field-ajax-test")]//input[@type="text"]')) == 2, t('AJAX submission succeeded.'));
// Submit the form with the non-AJAX "Save" button, leaving the title field
diff --git a/modules/simpletest/tests/form_test.file.inc b/modules/simpletest/tests/form_test.file.inc
index 96681eaa8..808863ede 100644
--- a/modules/simpletest/tests/form_test.file.inc
+++ b/modules/simpletest/tests/form_test.file.inc
@@ -13,11 +13,17 @@
function form_test_load_include_menu($form, &$form_state) {
// Submit the form via AJAX. That way the FAPI has to care about including
// the file specified in hook_menu().
+ $ajax_wrapper_id = drupal_html_id('form-test-load-include-menu-ajax-wrapper');
+ $form['ajax_wrapper'] = array(
+ '#markup' => '<div id="' . $ajax_wrapper_id . '"></div>',
+ );
$form['button'] = array(
'#type' => 'submit',
'#value' => t('Save'),
'#submit' => array('form_test_load_include_submit'),
'#ajax' => array(
+ 'wrapper' => $ajax_wrapper_id,
+ 'method' => 'append',
'callback' => 'form_test_load_include_menu_ajax',
),
);
@@ -32,9 +38,12 @@ function form_test_load_include_submit($form, $form_state) {
}
/**
- * Ajax callback for the file inclusion via menu test. We don't need to return
- * anything as the messages are added automatically.
+ * Ajax callback for the file inclusion via menu test.
*/
function form_test_load_include_menu_ajax($form) {
+ // We don't need to return anything, since #ajax['method'] is 'append', which
+ // does not remove the original #ajax['wrapper'] element, and status messages
+ // are automatically added by the AJAX framework as long as there's a wrapper
+ // element to add them to.
return '';
}