Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
simpletest.module
Priority:
Normal
Category:
Task
Assigned:
Issue tags:
Reporter:
Created:
15 Aug 2008 at 19:32 UTC
Updated:
2 Jan 2014 at 23:45 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
mlncn commentedAgreed.
An aside: Should there be a random text function (that puts in spaces and such)?
Comment #2
damien tournoud commentedWhile we are at it, it could make sense to have a randomHtml function, that produce simple valid HTML (like some
<i>and<strong>).Comment #3
boombatower commentedI'll work on a patch.
Comment #4
robloachI'm getting all passing tests.
Comment #5
webchickI'm not so sure of this patch, and not just because I don't want to confuse test authors by shifting APIs out from under them this late into the game when we have over 111 test cases for D7. Rob Loach's patch makes it clear that this touches just about every test in core, so it's seriously going to mess people up if it changes.
But since we don't care about backwards compatibility in a code thaw, instead take a look at this:
That's the defined charset for randomName(). This makes sense; those characters are the only ones allowed in usernames, for example. They're also guaranteed to be safe and not contain any weird characters that could mess something up.
On the other hand, if I saw a function called randomString(), I would expect it to generate things like ® and $ and ' and not be limited to a particular character set.
So I think the name of this function is actually fine, as it describes what it does. If we want to add a randomString() function additionally, that purposely attempts to generate wacky characters to see if things screw up, then that's another matter.
Comment #6
robloachThe addition of a randomString function with a larger charset is a good idea.
Comment #7
boombatower commentedTalked with webchick and added a few thoughts myself.
This patch leaves the randomName() method, but updates its code as it previously made sure strings started with something other than a number. Seems unnecessary.
Adds randomString() which includes misc. characters including space as requested.
Removes prefix as parameter and just prefixes strings with the database prefix. I would encourage people to use longer random strings instead of prefixes to ensure the strings are unique. The random functions should be just that...random.
Ran aggregator, profile, and tracker tests which I removed prefix code from....they still passes. If someone has time to run whole suite that would be great.
Comment #8
boombatower commentedRe-rolled.
Comment #9
Anonymous (not verified) commentedThe last submitted patch failed testing.
Comment #10
boombatower commentedUpdated patch...interestingly there are now 377 references to randomName().
Comment #12
boombatower commentedHad to do with the length of the random strings since they are now appended with $db_prefix. I added code to remove the redundant "simpletest" portion of the prefix to shorten them...and cleared out some suffixes used in field tests.
Comment #14
boombatower commentedActual bug in the field test. #446878: Field.test contains incorrect appending syntax
NOTE: accidentally re-uploaded patch :)
Comment #15
boombatower commentedOther patch committed.
Comment #17
boombatower commentedInteresting little quirk in the upload test, fixed.
Comment #18
dries commentedCommitted to CVS HEAD. Thanks.
Comment #19
c960657 commentedrandomString() is limited to US-ASCII characters. Any reason why it doesn't use a wider selection of Unicode characters?
Comment #20
sunSpot the typo here.
Comment #21
boombatower commentedNice catch.
#19 I suppose not. Perhaps a follow up patch?
Comment #22
sunFunction summaries should be on one line. If required, add a blank PHPDoc line after the summary, followed by a longer function description.
Another typo in here. (also in the second PHPDoc)
Comment #23
boombatower commentedI have never even thought about the single line summary. I'll try and remember that for future patches.
I fixed the summary and such, but I'm not sure what the type is in the second block.
Comment #24
sunWe're almost there.
There needs to be a blank PHPDoc line between the PHPDoc summary and PHPDoc description.
The typo is in
$db_prefx. However, now you introduced another one inThe letters may be upper of lower case.Also, the fix from #21 is no longer contained.
Comment #25
boombatower commentedWasn't sure on new-line...fixed.
other typos fixed.
Hopefully this is good. :)
Comment #26
dries commentedGreat job, sun. Thanks! Keep 'em coming if you have more.
Comment #27
webchickHm. Sorry, but I still think this needs work.
It's not at all clear from the documentation why you should use randomString() vs. why you should use randomName(). Can we please add a line to each (probably as well as a cross-referenced @see entry) to explain this?
Comment #28
webchickAdditionally, let's make sure all of the examples at http://drupal.org/simpletest that need to be updated are, and a mention of this API change on the 6.x -> 7.x updates page.
Comment #29
boombatower commentedI added a bit of documentation.
Comment #30
boombatower commentedUpdate: http://drupal.org/node/265762
Comment #31
webchickAwesome. Thanks!