? .cache
? .settings
Index: modules/field/field.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.test,v
retrieving revision 1.67
diff -u -p -r1.67 field.test
--- modules/field/field.test	12 Nov 2009 20:07:06 -0000	1.67
+++ modules/field/field.test	18 Nov 2009 14:32:35 -0000
@@ -1552,8 +1552,8 @@ class FieldFormTestCase extends FieldTes
     $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 FieldTes
       $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);
@@ -1591,41 +1593,9 @@ class FieldFormTestCase extends FieldTes
     $this->assertFieldByName("$this->field_name[$langcode][$delta][_weight]", $delta, "New widget has the right weight");
     $this->assertNoField("$this->field_name[$langcode][" . ($delta + 1) . '][value]', 'No extraneous widget is displayed');
   }
-
-  /**
-   * 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 {
   public static function getInfo() {
     return array(
Index: modules/poll/poll.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/poll/poll.test,v
retrieving revision 1.25
diff -u -p -r1.25 poll.test
--- modules/poll/poll.test	16 Oct 2009 23:48:37 -0000	1.25
+++ modules/poll/poll.test	18 Nov 2009 14:33:21 -0000
@@ -339,30 +339,11 @@ class PollJSAddChoice extends DrupalWebT
       'choice[new:1][chtext]' => $this->randomName(),
     );
 
-    // @TODO: the framework should make it possible to submit a form to a
-    // different URL than its action or the current. For now, we can just force
-    // it.
-    $this->additionalCurlOptions[CURLOPT_URL] = url('system/ajax', array('absolute' => TRUE));
-    $this->drupalPost(NULL, $edit, t('More choices'));
-    unset($this->additionalCurlOptions[CURLOPT_URL]);
+    // Press 'add choice' button through AJAX, and place the expected HTML result
+    // as the tested content.
+    $commands = $this->drupalPostAJAX(NULL, $edit, 'poll_more');
+    $this->content = $commands[1]['data'];
 
-    // 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 replace 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 = '';
     $this->assertFieldByName('choice[chid:0][chtext]', $edit['choice[new:0][chtext]'], t('Field !i found', array('!i' => 0)));
     $this->assertFieldByName('choice[chid:1][chtext]', $edit['choice[new:1][chtext]'], t('Field !i found', array('!i' => 1)));
     $this->assertFieldByName('choice[new:0][chtext]', '', t('Field !i found', array('!i' => 2)));
Index: modules/simpletest/drupal_web_test_case.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v
retrieving revision 1.171
diff -u -p -r1.171 drupal_web_test_case.php
--- modules/simpletest/drupal_web_test_case.php	18 Nov 2009 04:56:17 -0000	1.171
+++ modules/simpletest/drupal_web_test_case.php	18 Nov 2009 14:31:08 -0000
@@ -1405,7 +1405,9 @@ class DrupalWebTestCase extends DrupalTe
    */
   function drupalGetAJAX($path, array $options = array(), array $headers = array()) {
     $out = $this->drupalGet($path, $options, $headers);
-    return json_decode($out, TRUE);
+    // The response is drupal_json_output, so we need to undo some escaping
+    // before decoding.
+    return json_decode(str_replace(array('\x3c', '\x3e', '\x26'), array("<", ">", "&"), $out), TRUE);
   }
 
   /**
@@ -1546,7 +1548,9 @@ class DrupalWebTestCase extends DrupalTe
    */
   protected function drupalPostAJAX($path, $edit, $triggering_element, $ajax_path = 'system/ajax', array $options = array(), array $headers = array()) {
     $out = $this->drupalPost($path, $edit, array('path' => $ajax_path, 'triggering_element' => $triggering_element), $options, $headers);
-    return json_decode($out, TRUE);
+    // The response is drupal_json_output, so we need to undo some escaping
+    // before decoding.
+    return json_decode(str_replace(array('\x3c', '\x3e', '\x26'), array("<", ">", "&"), $out), TRUE);
   }
 
   /**
