diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-09-19 18:38:58 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-09-19 18:38:58 +0000 |
commit | 8580169d0e05e25cd1791f538c0a32ec45082642 (patch) | |
tree | 7642fe7555e601566d91ff4468b3c825388867c5 /modules/simpletest/tests/ajax.test | |
parent | 5c4dfd44f956cbffd7d201fd6c47e9a37e86ad2d (diff) | |
download | brdo-8580169d0e05e25cd1791f538c0a32ec45082642.tar.gz brdo-8580169d0e05e25cd1791f538c0a32ec45082642.tar.bz2 |
- Patch #789186 by effulgentsia: improve drupalPostAJAX() to be used more easily, leading to better AJAX test coverage. (Rollback)
Diffstat (limited to 'modules/simpletest/tests/ajax.test')
-rw-r--r-- | modules/simpletest/tests/ajax.test | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/modules/simpletest/tests/ajax.test b/modules/simpletest/tests/ajax.test index 9377f4cdb..91572bda0 100644 --- a/modules/simpletest/tests/ajax.test +++ b/modules/simpletest/tests/ajax.test @@ -269,17 +269,24 @@ 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_html_id => $field_xpath) { + foreach ($field_xpaths as $form_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. - foreach ($field_xpaths as $form_html_id => $field_xpath) { + // 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) { for ($i=0; $i<2; $i++) { - $this->drupalPostAJAX(NULL, array(), array($button_name => $button_value), 'system/ajax', array(), array(), $form_html_id); + $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->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'); |