I'm almost positive an issue exists for this already, but I couldn't find it.
To reproduce:
1. Create some content as User A.
2. Log in as User B.
3. As User B, click on User A's name in the "Authored by" information of the node.
4. Notice that you are redirected to User B's user profile page, not User A's.
I imagine this is a one-line fix somewhere, but this fix should also come with tests to make sure that we don't accidentally introduce this again in the future.
Tagging as novice, since this should be a pretty easy test to write. There is some SimpleTest documentation at http://drupal.org/simpletest and sub-pages, although I find just opening up an existing .test file or two and reading it gives a pretty good introduction, too. If you have questions at all, come ask in #drupal! :)
Comment | File | Size | Author |
---|---|---|---|
#9 | theme-username-test.patch | 1.73 KB | andypost |
#4 | user-profile-link-test3.patch | 1.8 KB | drifter |
#2 | user-profile-link-test2.patch | 1.79 KB | drifter |
#1 | user-profile-link-test.patch | 1.83 KB | drifter |
Comments
Comment #1
drifter CreditAttribution: drifter commentedCouldn't reproduce the bug on my fresh install, but here's my attempt at a test case. Two questions: should this belong in user.test or node.test? I opted for user.test because it tests for profile pages, but it could be either.
Second: I'm just testing for finding the "user/$user_a->uid" string in the raw HTML - I could have opted for matching the whole <a href="/user/$user_a->uid" title="View user profile."> tag, but it could make the test more fragile. Which is the better option? Or is there a better way than searching the full raw HTML?
Comment #2
drifter CreditAttribution: drifter commentedCleaned up some comments and whitespace.
Comment #3
mr.baileysThe patch contains some tab characters (starting around line 991). Can you re-roll the patch without the tabs (Coding standards)?
Comment #4
drifter CreditAttribution: drifter commentedOK, rerolling with spaces instead of tabs...
Comment #5
mr.baileysLooks good to me. Reviewed the logic and didn't find any issue with it. Applied the patch and ran the tests without problems.
Some minor remarks:
testUserProfileLink()
Other than the (cosmetic) issues above, I think this is good to go.
Comment #6
mr.baileysRegarding your question in #2: although your method looks ok to me (there shouldn't be false positives on "user/uid"), it might be better to add the a-tag and href-attribute to the mix. Here's an example from the Assertions handbook page:
Comment #7
Dave ReidI would highly suggest just using the following test:
$this->assertRaw(theme('username', $user_a), t("User A's profile link found."));
Comment #8
cburschkaThat sounds like a very good idea. The test should not hard-code the theme output it expects, I think.
(Naturally, this won't verify that theme('username', $user); actually works as it should - if theme('username', $user_b) themes a username link to the logged in user, then we don't catch that.)
Comment #9
andypostSo here the patch
First check
theme('username', ...)
works then check resultComment #10
catchI'm really confused why we need a test for this - there's no bug to be fixed, theme('username') depends on the information given to it. Marking 'needs more info' because I think we need a situation where this could actually happen - is it supposed to protect against completely wrong implementations of theme_username() which use global $user or something?
Comment #11
sun.core CreditAttribution: sun.core commentedI agree with catch.