Decided I never want to set up the dependencies to test UR node access again, so I finally had to teach myself to write tests for Drupal.
Feel like I might be missing a few test cases here, but I think its mostly there.
| Comment | File | Size | Author |
|---|---|---|---|
| #20 | ur-node-access-tests-20.patch | 8.1 KB | mrf |
| #15 | ur-node-access-tests-15.patch | 5.8 KB | mrf |
| #8 | ur-node-access-tests-8.patch | 6.01 KB | mrf |
| #4 | ur-node-access-tests-3.patch | 5.96 KB | mrf |
| #1 | ur-node-access-tests-2.patch | 6.03 KB | mrf |
Comments
Comment #1
mrf commentedBad file name and debug info left in...
Comment #3
berdirHm, looks like your test is the wrong way round, the patch attempts to remove the file as opposed to add :)
Comment #4
mrf commentedAnd this might work a little better.
Comment #5
mrf commentedComment #7
berdirCould use a space between functions.
Comments should be formatted like this:
// Clear cache.
(space after //, first character upper case, . at the end).
What I usually do is this:
No need to pass the user object to drupalLogout(), you only log out the currently logged in user anyway ;)
Comment #8
mrf commentedCommitted http://drupalcode.org/project/user_relationships.git/commitdiff/3da5daa for the notices that were appearing.
Applied suggested fixes, and this should now pass with the above fix included.
Comment #9
mrf commentedComment #10
berdirBoth branch tests seem to be hung up. Re-triggered, should be picked up.
There are still a few missing (test methods) or incorrectly formatted (class properties should be documented with /** ... */ like methods, clear cache comments, ...) comments.
Apart from that, I would suggest to commit this asap, then it will be easier for bugs and other issues to extend the existing tests, rather than continue working on this patch. Can you provide a port for 7.x-1.x as well once you commited it? Will probably require quite a few changes to strings and url's, but should work the same way conceptually.
Comment #11
berdirHere is some additional feedback, feel free to work on that after commiting a first patch.
Might make sense to have an explicit test assertion that the delete actually worked. (e.g. add a assertText() on the confirmation message). you're currently only asserting this implicitly (as it would generate errors when drupalPost( can't find the form that should be submitted if you're on a 404 page).
Also, it is in general also useful to have tests for cases where something should not happen/work. In this case, you might want to set up a third user that is not related, or even better, in another relationship that should not have delete access.
That gives you much better coverage if the module works *correctly*.
I guess this will always work because we do not deny access.
To make this check actually useful, you would need to additionally install a content access module which allows to deny access (or implement this feature in UR node access), this would also be necessary to check that users do not have access if they're not supposed to.
The problem with that is that the testbot doesn't know that the tests needs another module. I'm currently adding a empty test module to #1115956: Revamp relationship type name display which allows to add a dependency on i18n so that I will be able to write tests that depend on it, you could do something similar.
This isn't necessary as you already initialize $this->rtypes to an empty array in your setUp() method. So you can remove this method.
Comment #12
berdirComment #13
mrf commentedPatch from #8 committed to 6.x. http://drupalcode.org/project/user_relationships.git/commitdiff/decbe41
Will polish this a bit further then once its more solid port it over to 7.
Comment #14
mrf commentedActually that user doesn't even have the 'access content' permission so they can't see anything on the site unless explicitly granted. I should probably use that unrelated user for a test that confirms this though.
Comment #15
mrf commentedHere are some fixes and some general cleanup. I was wrong about the 'access content' permission, but it looks like our external user is denied view permission anyway?
Comment #16
mrf commentedComment #18
mrf commented#15: ur-node-access-tests-15.patch queued for re-testing.
Comment #19
mrf commentedCommitted changes for #15 to 6.x. http://drupalcode.org/project/user_relationships.git/commitdiff/4023c2e
Moving over to 7.x.
Comment #20
mrf commentedHere is a first attempt at the port, mostly works but needs a few modifications to completely work.