diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-11-21 00:43:42 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-11-21 00:43:42 +0000 |
commit | 59ceca0caf52002cf44206feec7c7213bc079939 (patch) | |
tree | 795bbe8ed9a00e4d55ce47516d5c6b4aa589c5e0 /modules/field/tests/field.test | |
parent | 34119ba98b9e7b412ed7efdcf7b9e9b704f790c7 (diff) | |
download | brdo-59ceca0caf52002cf44206feec7c7213bc079939.tar.gz brdo-59ceca0caf52002cf44206feec7c7213bc079939.tar.bz2 |
#633156 follow-up by effulgentsia and yched: Clean up AJAX tests, add sister function to drupal_js_encode().
Diffstat (limited to 'modules/field/tests/field.test')
-rw-r--r-- | modules/field/tests/field.test | 43 |
1 files changed, 6 insertions, 37 deletions
diff --git a/modules/field/tests/field.test b/modules/field/tests/field.test index 5fffe3a39..8de70bfe5 100644 --- a/modules/field/tests/field.test +++ b/modules/field/tests/field.test @@ -1552,8 +1552,8 @@ class FieldFormTestCase extends FieldTestCase { $this->drupalGet('test-entity/add/test-bundle'); // Press 'add more' button a couple times -> 3 widgets. - // The drupalPostAhah() helper will not work iteratively, so we add those. - // through non-'JS' submission. + // drupalPostAJAX() will not work iteratively, so we add those through + // non-JS submission. $this->drupalPost(NULL, array(), t('Add another item')); $this->drupalPost(NULL, array(), t('Add another item')); @@ -1575,8 +1575,10 @@ class FieldFormTestCase extends FieldTestCase { $field_values[$weight]['value'] = (string)$value; $pattern[$weight] = "<input [^>]*value=\"$value\" [^>]*"; } - // Press 'add more' button through AHAH. - $this->_fieldPostAhah($edit, t('Add another item')); + // Press 'add more' button through AJAX, and place the expected HTML result + // as the tested content. + $commands = $this->drupalPostAJAX(NULL, $edit, $this->field_name . '_add_more'); + $this->content = $commands[1]['data']; ksort($values); $values = array_values($values); @@ -1650,39 +1652,6 @@ class FieldFormTestCase extends FieldTestCase { $this->assertEqual($entity->{$field_name_no_access}[$langcode][0]['value'], 99, t('New revision has the expected value for the field with no edit access.')); $this->assertEqual($entity->{$field_name}[$langcode][0]['value'], 2, t('New revision has the expected value for the field with edit access.')); } - - /** - * Execute a POST request on a AHAH callback. - * - * Stolen from poll.test. The JSON result is parsed into HTML and placed in - * $this->content, so that regular asserts can be performed. - * - * Since the result is generally not a full-fledged form, this cannot be - * called iteratively. - */ - function _fieldPostAhah($edit, $submit, array $options = array(), array $headers = array()) { - $this->additionalCurlOptions[CURLOPT_URL] = url('system/ajax', array('absolute' => TRUE)); - $this->drupalPost(NULL, $edit, $submit); - unset($this->additionalCurlOptions[CURLOPT_URL]); - - // The response is drupal_json_output, so we need to undo some escaping. - $commands = json_decode(str_replace(array('\x3c', '\x3e', '\x26'), array("<", ">", "&"), $this->drupalGetContent())); - - // The JSON response will be two AJAX commands. The first is a settings - // command and the second is the replace command. - $settings = reset($commands); - $replace = next($commands); - - $this->assertTrue(is_object($settings), t('The response settings command is an object')); - $this->assertTrue(is_object($replace), t('The response replace command is an object')); - - // This response data is valid HTML so we will can reuse everything we have - // for HTML pages. - $this->content = $replace->data; - - // Needs to be emptied out so the new content will be parsed. - $this->elements = ''; - } } class FieldCrudTestCase extends FieldTestCase { |