summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2009-08-16 03:16:19 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2009-08-16 03:16:19 +0000
commit7e707543f5e45978440e5e8c84f66d29e6e8d30d (patch)
tree18652b58df031964a078f03991df8f50838caeaf /modules
parentff477cd6eafd99d5a3a36e06e0e20c5883b19682 (diff)
downloadbrdo-7e707543f5e45978440e5e8c84f66d29e6e8d30d.tar.gz
brdo-7e707543f5e45978440e5e8c84f66d29e6e8d30d.tar.bz2
#296324 by R.Muilwijk, kscheirer, and pamelad: Fixed TestingParty08: url() for internal urls need a thorough test.
Diffstat (limited to 'modules')
-rw-r--r--modules/simpletest/tests/common.test33
1 files changed, 33 insertions, 0 deletions
diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test
index adba561cd..7f3b07473 100644
--- a/modules/simpletest/tests/common.test
+++ b/modules/simpletest/tests/common.test
@@ -34,6 +34,39 @@ class CommonLUnitTest extends DrupalUnitTestCase {
$this->assertEqual(drupal_query_string_encode(array('a' => '1', 'b' => '2', 'c' => '3'), array('b')), 'a=1&c=3', t('Value was properly excluded.'));
$this->assertEqual(drupal_query_string_encode(array('a' => array('b' => '2', 'c' => '3')), array('b', 'a[c]')), 'a[b]=2', t('Nested array was properly encoded.'));
}
+
+ /**
+ * Test url() with/without query, with/without fragment, absolute on/off and assert all that works when clean URLs are on and off.
+ */
+ function testUrl() {
+ global $base_url;
+
+ foreach (array(FALSE, TRUE) as $absolute) {
+ // Get the expected start of the path string.
+ $base = $absolute ? $base_url . '/' : base_path();
+ $absolute_string = $absolute ? 'absolute' : NULL;
+
+ // Run tests with clean urls disabled.
+ $GLOBALS['conf']['clean_url'] = 0;
+ $clean_urls = 'disabled';
+
+ $this->assertTrue(url('node', array('absolute' => $absolute)) == $base . '?q=node', t('Creation of @absolute internal url with clean urls @clean_urls.', array('@absolute' => $absolute_string, '@clean_urls' => $clean_urls)));
+ $this->assertTrue(url('node', array('fragment' => 'foo', 'absolute' => $absolute)) == $base . '?q=node#foo', t('Creation of @absolute internal url with fragment option with clean urls @clean_urls.', array('@absolute' => $absolute_string, '@clean_urls' => $clean_urls)));
+ $this->assertTrue(url('node', array('query' => 'foo', 'absolute' => $absolute)) == $base . '?q=node&foo', t('Creation of @absolute internal url with query option with clean urls @clean_urls.', array('@absolute' => $absolute_string, '@clean_urls' => $clean_urls)));
+ $this->assertTrue(url('node', array('query' => 'foo', 'fragment' => 'bar', 'absolute' => $absolute)) == $base . '?q=node&foo#bar', t('Creation of @absolute internal url with query and fragment option with clean urls @clean_urls.', array('@absolute' => $absolute_string, '@clean_urls' => $clean_urls)));
+ $this->assertTrue(url('<front>', array('absolute' => $absolute)) == $base, t('Creation of @absolute internal url using front with clean urls @clean_urls.', array('@absolute' => $absolute_string, '@clean_urls' => $clean_urls)));
+
+ // Run tests again with clean urls enabled.
+ $GLOBALS['conf']['clean_url'] = 1;
+ $clean_urls = 'enabled';
+
+ $this->assertTrue(url('node', array('absolute' => $absolute)) == $base . 'node', t('Creation of @absolute internal url with clean urls @clean_urls.', array('@absolute' => $absolute_string, '@clean_urls' => $clean_urls)));
+ $this->assertTrue(url('node', array('fragment' => 'foo', 'absolute' => $absolute)) == $base . 'node#foo', t('Creation of @absolute internal url with fragment option with clean urls @clean_urls.', array('@absolute' => $absolute_string, '@clean_urls' => $clean_urls)));
+ $this->assertTrue(url('node', array('query' => 'foo', 'absolute' => $absolute)) == $base . 'node?foo', t('Creation of @absolute internal url with query option with clean urls @clean_urls.', array('@absolute' => $absolute_string, '@clean_urls' => $clean_urls)));
+ $this->assertTrue(url('node', array('query' => 'foo', 'fragment' => 'bar', 'absolute' => $absolute)) == $base . 'node?foo#bar', t('Creation of @absolute internal url with query and fragment option with clean urls @clean_urls.', array('@absolute' => $absolute_string, '@clean_urls' => $clean_urls)));
+ $this->assertTrue(url('<front>', array('absolute' => $absolute)) == $base, t('Creation of @absolute internal url using front with clean urls @clean_urls', array('@absolute' => $absolute_string, '@clean_urls' => $clean_urls)));
+ }
+ }
}
class CommonSizeTestCase extends DrupalUnitTestCase {