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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

greggles’s picture

Marked #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.

Gábor Hojtsy’s picture

Greggles, what's your opinion on the existing tests?

Dries’s picture

*bump* :)

greggles’s picture

Title: Simpletest for pathauto! » Simpletest for Pathauto
Status: Needs review » Needs work

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

Freso’s picture

FileSize
3.06 KB

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

greggles’s picture

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

Freso’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
3.06 KB

I'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?

Gábor Hojtsy’s picture

I'd say there are no naming conventions set in stone (yet). I don't know of one. But I might be mistaken.

Freso’s picture

Gábor: Is there a reason we're using strtolower() instead of drupal_strtolower()? (Found during the course of #262014: Use drupal_str functions instead of str functions.)

Gábor Hojtsy’s picture

There 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.

Freso’s picture

Indeed. 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... :/

Gábor Hojtsy’s picture

Freso: tests go to the tests subfolder of modules. Then the Drupal 6 version of simpletest can just discover and use them.

Freso’s picture

Status: Reviewed & tested by the community » Fixed
FileSize
3.06 KB

Committed 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

Gábor Hojtsy’s picture

Yay, thanks!

Freso’s picture

No, no, no, Gábor. Thank you! :)

Anonymous’s picture

Status: Fixed » Closed (fixed)

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