*** drupal_web_test_case.php	2008-11-07 12:47:44.000000000 -0800
--- /Users/dave/eclipse_projects/imbee2/sites/all/modules/contrib/simpletest/drupal_web_test_case.php	2008-11-25 15:44:51.000000000 -0800
***************
*** 1,5 ****
  <?php
! // $Id: drupal_web_test_case.php,v 1.2.2.3.2.19 2008/10/22 23:16:46 boombatower Exp $
  
  /**
   * Test case for typical Drupal tests.
--- 1,5 ----
  <?php
! // $Id: drupal_web_test_case.php,v 1.1 2008/11/25 23:44:51 dmenefee Exp $
  
  /**
   * Test case for typical Drupal tests.
***************
*** 683,689 ****
      // Store necessary current values before switching to prefixed database.
      $this->db_prefix_original = $db_prefix;
      $clean_url_original = variable_get('clean_url', 0);
! 
      // Generate temporary prefixed database to ensure that tests have a clean starting point.
      $db_prefix = 'simpletest' . mt_rand(1000, 1000000);
  
--- 683,694 ----
      // Store necessary current values before switching to prefixed database.
      $this->db_prefix_original = $db_prefix;
      $clean_url_original = variable_get('clean_url', 0);
!     // settings for this module
!     $this->debug = variable_get('simpletest_debug', FALSE);
!     $this->httpauth = variable_get('simpletest_httpauth', FALSE);
!     $this->httpauth_username = variable_get('simpletest_httpauth_username', '');
!     $this->httpauth_pass = variable_get('simpletest_httpauth_pass', '');
!     
      // Generate temporary prefixed database to ensure that tests have a clean starting point.
      $db_prefix = 'simpletest' . mt_rand(1000, 1000000);
  
***************
*** 788,803 ****
          CURLOPT_FOLLOWLOCATION => TRUE,
          CURLOPT_RETURNTRANSFER => TRUE,
          CURLOPT_SSL_VERIFYPEER => FALSE,
! 		CURLOPT_SSL_VERIFYHOST => FALSE,
        );
        if (preg_match('/simpletest\d+/', $db_prefix)) {
          $curl_options[CURLOPT_USERAGENT] = $db_prefix;
        }
!       if (!isset($curl_options[CURLOPT_USERPWD]) && ($auth = variable_get('simpletest_httpauth_username', ''))) {
!         if ($pass = variable_get('simpletest_httpauth_pass', '')) {
!           $auth .= ':' . $pass;
          }
-         $curl_options[CURLOPT_USERPWD] = $auth;
        }
        return $this->curlExec($curl_options);
      }
--- 793,815 ----
          CURLOPT_FOLLOWLOCATION => TRUE,
          CURLOPT_RETURNTRANSFER => TRUE,
          CURLOPT_SSL_VERIFYPEER => FALSE,
!         CURLOPT_SSL_VERIFYHOST => FALSE,
        );
        if (preg_match('/simpletest\d+/', $db_prefix)) {
          $curl_options[CURLOPT_USERAGENT] = $db_prefix;
        }
!       if ($this->debug) {
!         $curl_options[CURLOPT_VERBOSE] = TRUE;
!       }
!       if ($this->httpauth) {
!         $curl_options[CURLOPT_HTTPAUTH] = CURLAUTH_BASIC;
!         if (empty($curl_options[CURLOPT_USERPWD]) && (!empty($this->httpauth_username))) {
!           $auth = $this->httpauth_username;
!           if (!empty($this->httpauth_pass)) {
!             $auth .= ':' . $this->httpauth_pass;
!           }
!           $curl_options[CURLOPT_USERPWD] = $auth;
          }
        }
        return $this->curlExec($curl_options);
      }
***************
*** 819,824 ****
--- 831,839 ----
      $this->plain_text = FALSE;
      $this->elements = FALSE;
      $this->assertTrue($this->_content !== FALSE, t('!method to !url, response is !length bytes.', array('!method' => !empty($curl_options[CURLOPT_NOBODY]) ? 'HEAD' : (empty($curl_options[CURLOPT_POSTFIELDS]) ? 'GET' : 'POST'), '!url' => $url, '!length' => strlen($this->_content))), t('Browser'));
+     if ($this->debug) {
+       watchdog('debug', 'content returned from URL '.$url.': ' . $this->_content);
+     }
      return $this->_content;
    }
  
***************
*** 875,881 ****
      // previous options.
      $out = $this->curlExec(array(CURLOPT_HTTPGET => TRUE, CURLOPT_URL => url($path, $options)));
      $this->refreshVariables(); // Ensure that any changes to variables in the other thread are picked up.
! 
      // Replace original page output with new output from redirected page(s).
      if (($new = $this->checkForMetaRefresh())) {
        $out = $new;
--- 890,896 ----
      // previous options.
      $out = $this->curlExec(array(CURLOPT_HTTPGET => TRUE, CURLOPT_URL => url($path, $options)));
      $this->refreshVariables(); // Ensure that any changes to variables in the other thread are picked up.
!     
      // Replace original page output with new output from redirected page(s).
      if (($new = $this->checkForMetaRefresh())) {
        $out = $new;
***************
*** 953,958 ****
--- 968,976 ----
              $post = implode('&', $post);
            }
            $out = $this->curlExec(array(CURLOPT_URL => $action, CURLOPT_POST => TRUE, CURLOPT_POSTFIELDS => $post, CURLOPT_HEADER => FALSE, CURLOPT_NOBODY => FALSE));
+           if ($this->debug) {
+             watchdog('debug', 'content returned from POST to URL ' . $path . ': ' . $out);
+           }
            // Ensure that any changes to variables in the other thread are picked up.
            $this->refreshVariables();
  
***************
*** 969,974 ****
--- 987,996 ----
        }
        $this->assertTrue($submit_matches, t('Found the @submit button', array('@submit' => $submit)));
        $this->fail(t('Found the requested form fields at @path', array('@path' => $path)));
+     } else {
+       if ($this->debug) {
+         watchdog('debug', 'Failed to parse the content of the form to be posted for URL '.$path.': ' . print_r($this->elements, true));
+       }
      }
    }
