Index: modules/simpletest/tests/common.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/common.test,v
retrieving revision 1.4
diff -u -p -r1.4 common.test
--- modules/simpletest/tests/common.test	29 Aug 2008 14:45:19 -0000	1.4
+++ modules/simpletest/tests/common.test	31 Aug 2008 09:15:11 -0000
@@ -144,3 +144,49 @@ class DrupalHTTPRequestTestCase extends 
     $this->assertTitle(variable_get('site_name', 'Drupal'), t('Site title matches.'));
   }
 }
+
+class UrlTestCase extends DrupalWebtestCase {
+  /**
+   * Implementation of getInfo().
+   */
+  function getInfo() {
+    return array(
+      'name' => t('Drupal url() test'),
+      'description' => t("Performs tests on the url() function"),
+      'group' => t('System')
+    );
+  }
+
+  /*
+   * Test case
+   * Assert that calling url() with an external URL
+   *   1. containing a fragment works with and without a fragment in $options.
+   *   2. containing or not containing a query works with a query in $options.
+   */
+  function testUrlOptions() {
+    //testing the fragment handling
+    $fragment = $this->randomName(10);
+    $test_url = 'http://www.drupal.org/#'.$fragment;
+
+    $result_url = url($test_url);
+    $this->assertEqual($test_url, $result_url, t('External URL containing a fragment works without a fragment in $options'));
+
+    $result_url = url($test_url, array('fragment' => $fragment));
+    $this->assertEqual($test_url, $result_url, t('External URL containing a fragment works with a fragment in $options'));
+
+    //testing the query handling
+    $query = $this->randomName(10);
+    $query2 = $this->randomName(10);
+    $test_url = 'http://www.drupal.org/?'.$query;
+
+    //the external URL contains a query
+    $result_url = url($test_url, array('query' => $query2));
+    $this->assertEqual($test_url.'&'.$query2, $result_url, t('External URL with a query'));
+
+    //the external URL does not contain a query
+    $test_url = 'http://www.drupal.org';
+    $result_url = url($test_url, array('query' => $query2));
+    $this->assertEqual($test_url.'?'.$query2, $result_url, t('External URL without a query.'));
+  }
+
+}
