GHOP task #129: Write tests for path module
chx - January 7, 2008 - 08:31
| Project: | SimpleTest |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | task |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
| Issue tags: | GHOP |
Description
- create an alias for a node.
- change the alias
- move the alias to another node by giving it the same alias
- add, edit, delete aliases from the administration screen

#1
#2
The GHOP task associated with this issue can be found at:
http://code.google.com/p/google-highly-open-participation-drupal/issues/...
#3
This is the test from http://code.google.com/p/google-highly-open-participation-drupal/issues/... I have just copied over. That issue includes patches against path module, too.
#4
First of all thanks for the speedy work!
You need a drupalModuleEnable to make sure path module is on.
User input is not fed to
t()so remove please thet($node1->title)the t() calls. t is used only for constant strings not user input.You can safely presume that each randomname calls differ so no need for the getNewAlias function.
When checking for alias moves, I would assert the The path is already in use. message.
Core tests file go into the tests subdirectory of the simpletest module, no need for path_simpletest. Just upload the fixed test file.
#5
Two more things beside chxs' notes:
- I prefer using assertText function when you look for plain text on a page (title,body, anything that is visible), assertWantedRaw is used if you want to assert something in source code i.e. "Page simpletest_XRs4 has been updated."
- after you change the alias, you could also check that old alias produces "page not found" error
#6
Summary of changes:
drupalModuleEnable().t().getNewAlias().The path is already in use.andThe alias %alias is already in use in this language.instead of checking see if alias call would return that page._simpletest()hook.rawtests totext.A few notes:
page_creation.testas an example and it appears to use bothassertWantedRaw()andt()for the reason thatt()adds<em></em>around inserted variables. To implement the check for the message stating that the alias is already in use I have to do the same thing and thus have to leave aassertWantedRaw()in my test case.$this->assertWantedRaw(t('Your %post has been created.', array ('%post' => 'Page')), 'Page created');I believe this test case includes all the requested changes.
#7
Great work. You have made all the changes we asked for and I consider your task finished. I have two minor suggestions but this is really nitpicking
<?php$this->assertTitle(new PatternExpectation('/Page not found/'), 'We get page not found error');
?>
I added this small changes to the test so you don't need to bother with them and also committed this test to cvs.
#8
Oh yeah I guess this is fixed now.
Regarding the hook confusion. You only need simpletest hook if you write tests for your own module (non core). Core tests are kept in simpletest module and are searched for in simpletest/tests dir. So any file that ends with ".test" in simpletest/tests is included automatically.
#9
Thanks for clearing that up.
#10
Automatically closed -- issue fixed for two weeks with no activity.