Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hey, here is a simpletest for pathauto which just tests one configuration of the module. I am looking for input on what would be the best ways to generalize this. We certainly need tests for user, taxonomy, etc. paths, but otherwise how would it be better to write more generic functional tests which would consider different options being set? I'd love to write a more generic test for pathauto.
Comment | File | Size | Author |
---|---|---|---|
#13 | pathauto.test | 3.06 KB | Freso |
#7 | pathauto.test | 3.06 KB | Freso |
#5 | pathauto.test | 3.06 KB | Freso |
pathauto_basic.test | 2.74 KB | Gábor Hojtsy |
Comments
Comment #1
gregglesMarked #209164: simpletests for Drupal6 Pathauto as a duplicate of this since this has a patch. I'm not sure about a best practice for making this more generic.
Comment #2
Gábor HojtsyGreggles, what's your opinion on the existing tests?
Comment #3
Dries CreditAttribution: Dries commented*bump* :)
Comment #4
greggles@Dries - sure, a bump from the only person who can bump an issue with immunity ;)
Freso and I have developed a plan for the branches of Pathauto at http://groups.drupal.org/node/11551 For Pathauto 6.x-2.x, Freso has some ideas on refactoring to simplify testing so my preference is to have basic testing now and wait to get broader coverage until 6.x-2.x.
To expand on that discussion...the major piece of Pathauto which should get tests is for the tokens which is now mostly outside of Pathauto. So, I think we should have a fairly basic set of tests for Pathauto itself. These would be:
1. Aliasing new and edited nodes/vocabs/terms/users/user trackers/user blog posts
2. The tokens provided by Pathauto
3. Perhaps the bulk update
4. Perhaps the bulk delete
If use specific titles for the nodes/users and tweak the "General settings" between each object type in #1 then we should be able to get good coverage of the most important paths in the code without a lot of duplicate work.
I wrote several tests for Pathauto using Selenium and based on that work and this discussion I'm not sure of a more generalized way to test the module. I think expanding on Gábor's current system is the best strategy.
So, thoughts?
For a review: the path needs to be fixed now. And it's _P_athauto.
Comment #5
Freso CreditAttribution: Freso commentedI took the test from #0 and played around with it. One test failed due to the move of the admin page, which I fixed, but two other fail, and I haven't (yet) figured out whether this is due to bad testing or Pathauto misbehaving...
Oh, and I also added a bunch of Doxygen, so that #258314: Doxygen clean-up won't be in vain. :)
Comment #6
gregglesI got 23 out of 23 working fine on an installation that was the basis for the 6.x port of Pathauto (i.e. it has been around for a long time and is not necessarily the current default settings). Perhaps this makes some assumptions about variable settings which you have different, Freso?
Comment #7
Freso CreditAttribution: Freso commentedI'm getting 20 passes with a clean (Danish) install (only default core modules enabled, apart from token, pathauto, and simpletest - and color.module disabled) with the attached .test-file (the only difference from the previous one, is a
t()
to make the test function in non-English locales). The old test site was growing old, so this was probably a good occasion to start it over. :)So, if the current test is good, shouldn't it be checked in? The test(s) can always be improved upon, added to, removed from, etc. as we see fit. But at least there's something (or some things) being tested...
Oh, and I'm not sure about what it should be named. Should it just be "tests/pathauto.test"? Should unit tests go into "tests/[filename[.ext]].test"? Gábor, Dries?
Comment #8
Gábor HojtsyI'd say there are no naming conventions set in stone (yet). I don't know of one. But I might be mistaken.
Comment #9
Freso CreditAttribution: Freso commentedGábor: Is there a reason we're using
strtolower()
instead ofdrupal_strtolower()
? (Found during the course of #262014: Use drupal_str functions instead of str functions.)Comment #10
Gábor HojtsyThere is no specific reason, except maybe performance. Since this title is only ever going to contain ascii chars, both the utf-8 safe and the basic PHP solution gets to the same result.
Comment #11
Freso CreditAttribution: Freso commentedIndeed. Well, there should certainly be a test for aliases with UTF-8 in them, too! (For cases where they aren't transliterated or simply stripped out.) But that can always be added. Right now I'd just like to figure out how to name/place the * file... :/
Comment #12
Gábor HojtsyFreso: tests go to the tests subfolder of modules. Then the Drupal 6 version of simpletest can just discover and use them.
Comment #13
Freso CreditAttribution: Freso commentedCommitted the attached test to HEAD/6.x-1.x. The purpose of this issue is filled, but I'd like a new task for "Adding tests to Pathauto" or some such. We should also make it a policy of 6.x-2.x to have tests for every patch (like core 7.x). (Oh, and this .test could use a good sprinkle of Doxygen fairy dust...)
Also: Thanks to webchick for discussing naming standards with me and greggles in IRC! <3
Comment #14
Gábor HojtsyYay, thanks!
Comment #15
Freso CreditAttribution: Freso commentedNo, no, no, Gábor. Thank you! :)
Comment #16
Anonymous (not verified) CreditAttribution: Anonymous commentedAutomatically closed -- issue fixed for two weeks with no activity.