From 5c9d4b9c97ad4097676bd1da4c4467dc7f2e8125 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Fri, 6 Jun 2008 10:36:45 +0000 Subject: - Patch #253506 by Daniel, flobruit and catch: made the upload tests work. --- modules/simpletest/drupal_web_test_case.php | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) (limited to 'modules/simpletest/drupal_web_test_case.php') diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php index 543416a77..88d5a6b3c 100644 --- a/modules/simpletest/drupal_web_test_case.php +++ b/modules/simpletest/drupal_web_test_case.php @@ -552,29 +552,11 @@ class DrupalWebTestCase extends UnitTestCase { // We post only if we managed to handle every field in edit and the // submit button matches. if (!$edit && $submit_matches) { - // This part is not pretty. There is very little I can do. - if ($upload) { - foreach ($post as &$value) { - if (strlen($value) > 0 && $value[0] == '@') { - $this->fail(t("Can't upload and post a value starting with @")); - return FALSE; - } - } - foreach ($upload as $key => $file) { - $post[$key] = '@' . realpath($file); - } - } - else { - $post_array = $post; - $post = array(); - foreach ($post_array as $key => $value) { - // Whether this needs to be urlencode or rawurlencode, is not - // quite clear, but this seems to be the better choice. - $post[] = urlencode($key) . '=' . urlencode($value); - } - $post = implode('&', $post); + // cURL will handle file upload for us if asked kindly. + foreach ($upload as $key => $file) { + $post[$key] = '@' . realpath($file); } - $out = $this->curlExec(array(CURLOPT_URL => $action, CURLOPT_POSTFIELDS => $post, CURLOPT_POST => TRUE)); + $out = $this->curlExec(array(CURLOPT_URL => $action, CURLOPT_POST => TRUE, CURLOPT_POSTFIELDS => $post)); // Ensure that any changes to variables in the other thread are picked up. $this->refreshVariables(); return $out; -- cgit v1.2.3