diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-09-19 18:39:18 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-09-19 18:39:18 +0000 |
commit | 64fc9813b4a225bba8ab56bae0ca3b1db756121a (patch) | |
tree | b43e41a42c4a7dc664ec5f3d705217662f40df3e /modules/simpletest/tests/ajax.test | |
parent | 8580169d0e05e25cd1791f538c0a32ec45082642 (diff) | |
download | brdo-64fc9813b4a225bba8ab56bae0ca3b1db756121a.tar.gz brdo-64fc9813b4a225bba8ab56bae0ca3b1db756121a.tar.bz2 |
- Patch #789186 by effulgentsia: improve drupalPostAJAX() to be used more easily, leading to better AJAX test coverage. (Actual commit so we have proper credit.)
Diffstat (limited to 'modules/simpletest/tests/ajax.test')
-rw-r--r-- | modules/simpletest/tests/ajax.test | 15 |
1 files changed, 4 insertions, 11 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'); |