diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-08-15 06:30:38 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-08-15 06:30:38 +0000 |
commit | 6a97ac176e10f20022f13feb347e5ccc7bc04c0c (patch) | |
tree | 62468cc801c6a961257e2c31f78ab55ca632c170 /modules | |
parent | 6935b396cbf2240545667e2aef284fc9538701a7 (diff) | |
download | brdo-6a97ac176e10f20022f13feb347e5ccc7bc04c0c.tar.gz brdo-6a97ac176e10f20022f13feb347e5ccc7bc04c0c.tar.bz2 |
#296319 by redndahead, lilou, domas, and kscheirer: Added tests for external URL options.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/simpletest/tests/common.test | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test index f4837b8d0..adba561cd 100644 --- a/modules/simpletest/tests/common.test +++ b/modules/simpletest/tests/common.test @@ -191,6 +191,54 @@ class DrupalTagsHandlingTestCase extends DrupalWebTestCase { } /** + * Tests url(). + */ +class UrlTestCase extends DrupalWebtestCase { + + public static function getInfo() { + return array( + 'name' => 'Tests for the url() function', + 'description' => 'Performs tests on the url() function.', + 'group' => 'System', + ); + } + + /** + * Test the url() function's $options array. + * + * 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. url('http://drupal.org/#frag1');")); + + $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. url('http://drupal.org/#frag1', array('fragment' => 'frag1'));")); + + // 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 passed in the path paramater. url('http://drupal.org/?param1', array('query' => 'param2'));")); + + // 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 passed in the path paramater. url('http://drupal.org', array('query' => 'param2'));")); + } + +} + +/** * Test the Drupal CSS system. */ class CascadingStylesheetsTestCase extends DrupalWebTestCase { |