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.

Comments

Anonymous’s picture

Priority: Critical » Minor

Working on it..

Anonymous’s picture

Priority: Minor » Normal
Status: Active » Needs review
StatusFileSize
new2.16 KB

Here's a patch to modules/simpletest/tests/common.test, providing the test. I'm not completely sure if this is the way it's supposed to be. If I've missed anything, please let me know.

redndahead’s picture

Status: Needs review » Needs work
StatusFileSize
new2.1 KB

Patch apply's and works but there were coding standard violations. Spaces around concatenation, spaces in front of comments and caps at beginning of comments.

redndahead’s picture

Status: Needs work » Needs review

Whoops forgot to change back

dmitrig01’s picture

Status: Needs review » Reviewed & tested by the community

I've reviewed this, it's good.

webchick’s picture

Status: Reviewed & tested by the community » Needs work

Since this is a testing party patch, I'm going to be very nit-picky in this review. It's only because I care. :)

+class UrlTestCase extends DrupalWebtestCase {

Let's add a PHPdoc block with a quick sentence that summarizes what this test case does.

+      'description' => t("Performs tests on the url() function"),

a) Should be single quotes, not double, since there's no interpolation going on.
b) Should end in a period.

+      'group' => t('System')

Should be a comma at the end of this line. I know it looks like a mistake, but it's the standards. :)

+  /*
+   * 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.
+   */

a) /* needs to be /**
b) Test case isn't very descriptive. I would replace that with a one-sentence summary, like "Test the url() function's $options array." Make sure there's a newline between this sentence and the lines below it with more detail.

+    $this->assertEqual($test_url . '&' . $query2, $result_url, t('External URL with a query'));
...
+    $this->assertEqual($test_url . '?' . $query2, $result_url, t('External URL without a query.'));

The last messages were nice and descriptive as to what was being tested. These two, a little less so...

+    $test_url = 'http://www.drupal.org';

That's weird that the code below passes. Looks like this needs a trailing /.

That's it. :) Thanks a lot!!

redndahead’s picture

Status: Needs work » Needs review
StatusFileSize
new2.35 KB

Hopefully this one is better.

url('http://drupal.org', array('query' => 'param1');

returns http://drupal.org?param1

So the ending slash is not needed.

redndahead’s picture

StatusFileSize
new2.45 KB

Added the test function to the other descriptions.

Status: Needs review » Needs work

The last submitted patch failed testing.

redndahead’s picture

Status: Needs work » Needs review
catch’s picture

Status: Needs review » Needs work

getInfo() should no longer have PHPdoc, see http://drupal.org/node/325974

Also it looks like the calls to t() could use double quotes to save escaping the single quotes.

lilou’s picture

Component: tests » base system
Status: Needs work » Needs review
StatusFileSize
new2.64 KB

Reroll according to #11.

lilou’s picture

Component: base system » simpletest.module
mr.baileys’s picture

@lilou: link to patch in #12 doesn't seem to be working (directs me to the d.o. home page), and the testbot isn't picking this one up for testing. Could you re-upload?

lilou’s picture

StatusFileSize
new2.64 KB

Status: Needs review » Needs work

The last submitted patch failed testing.

lilou’s picture

Status: Needs work » Needs review
StatusFileSize
new2.64 KB

Now tests may passes.

Status: Needs review » Needs work

The last submitted patch failed testing.

dave reid’s picture

Component: simpletest.module » base system

Moving to the appropriate component since url() is base of the base system.

kscheirer’s picture

Status: Needs work » Needs review
StatusFileSize
new2.46 KB

tests look good, all pass. rerolled against HEAD.

lilou’s picture

StatusFileSize
new2.71 KB

Attached patch remove t() in getinfo() (#500866: [META] remove t() from assert message).

Status: Needs review » Needs work

The last submitted patch failed testing.

kscheirer’s picture

Status: Needs work » Reviewed & tested by the community

Patch applied without fuzz and tests pass. Not sure why testbot is complaining of a warning in the Javascript test.

As a side note though, we now have 3 tests in the System group that all deal with the url() function:

  • Tests for the url() function - Performs tests on the url() function. (this patch)
  • URL generation tests - Confirm that url(), drupal_query_string_encode(), and l() work correctly with various input.
  • Valid Url - Performs tests on Drupal's valid url function.
webchick’s picture

Status: Reviewed & tested by the community » Fixed

Whoops. Sorry this took so long to get back on my radar. :\

Committed to HEAD, thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.