Download & Extend

TestingParty08: external URL options need a test

Project:Drupal core
Version:7.x-dev
Component:base system
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

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

#1

Priority:critical» minor

Working on it..

#2

Priority:minor» normal
Status:active» needs review

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.

AttachmentSizeStatusTest resultOperations
url_test.patch2.16 KBIdleFailed: 7077 passes, 108 fails, 6667 exceptionsView details

#3

Status:needs review» needs work

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.

AttachmentSizeStatusTest resultOperations
url_test_1.patch2.1 KBIdleFailed: Failed to install HEAD.View details

#4

Status:needs work» needs review

Whoops forgot to change back

#5

Status:needs review» reviewed & tested by the community

I've reviewed this, it's good.

#6

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. :)

<?php
+class UrlTestCase extends DrupalWebtestCase {
?>

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

<?php
+      '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.

<?php
+      '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. :)

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

<?php
+    $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...

<?php
+    $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!!

#7

Status:needs work» needs review

Hopefully this one is better.

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

returns http://drupal.org?param1

So the ending slash is not needed.

AttachmentSizeStatusTest resultOperations
url_test_2.patch2.35 KBIdleFailed: Failed to install HEAD.View details

#8

Added the test function to the other descriptions.

AttachmentSizeStatusTest resultOperations
url_test_3.patch2.45 KBIdleFailed: Failed to apply patch.View details

#9

Status:needs review» needs work

The last submitted patch failed testing.

#10

Status:needs work» needs review

#11

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.

#12

Component:tests» base system
Status:needs work» needs review

Reroll according to #11.

AttachmentSizeStatusTest resultOperations
issue-296319.patch2.64 KBIgnored: Check issue status.NoneNone

#13

Component:base system» simpletest.module

#14

@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?

#15

AttachmentSizeStatusTest resultOperations
issue-296319.patch2.64 KBIdleFailed: 11120 passes, 0 fails, 2 exceptionsView details

#16

Status:needs review» needs work

The last submitted patch failed testing.

#17

Status:needs work» needs review

Now tests may passes.

AttachmentSizeStatusTest resultOperations
issue-296319.patch2.64 KBIdleFailed: 11627 passes, 0 fails, 1 exceptionView details

#18

Status:needs review» needs work

The last submitted patch failed testing.

#19

Component:simpletest.module» base system

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

#20

Status:needs work» needs review

tests look good, all pass. rerolled against HEAD.

AttachmentSizeStatusTest resultOperations
issue-296319_2.patch2.46 KBIdlePassed: 12092 passes, 0 fails, 0 exceptionsView details

#21

Attached patch remove t() in getinfo() (#500866: Simpletest: remove t() from assert message).

AttachmentSizeStatusTest resultOperations
issue-296319-21.patch2.71 KBIdlePassed: 12122 passes, 0 fails, 0 exceptionsView details

#22

Status:needs review» needs work

The last submitted patch failed testing.

#23

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.

#24

Status:reviewed & tested by the community» fixed

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

Committed to HEAD, thanks!

#25

Status:fixed» closed (fixed)

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

nobody click here