Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
simpletest.module
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
19 May 2015 at 11:11 UTC
Updated:
15 Jul 2016 at 06:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
pfrenssenHere's a fix + test. Since the
$this->cookiesproperty seems to be wholly untested I also added a test to see if the name and value of the cookie are correct.Comment #3
znerol commentedUse
$this->drupalGetHeader()unless there is a strong reason against that.The
$cookiesproperty is not initialized on declaration. In order to maintain consistency (each test should work with the same initial value), I think either the$cookiesproperty needs to be set toNULLhere or it should to be initialized to an empty array on declaration.Comment #4
pfrenssenarray()syntax instead of[]to be consistent with the rest of the file.Comment #5
pfrenssenThis patch contains only the test, this should fail.
Comment #7
pfrenssenComment #8
znerol commentedThanks!
Comment #9
alexpottLet's set a static in testCookies() and assert it's value in testCookieDoesNotBleed() so we can be sure we're testing something - or if someone has the bright idea of parallelising all the individual test methods during a run this breaks.
Comment #10
pfrenssenAl right I added a static to track whether
testCookies()actually runs beforetestCookieDoesNotBleed(). This will fail to alert someone running the tests in parallel that this behaviour is now untested. Probably we will have long moved to BrowserTestBase before running test methods in parallel becomes a real necessity.I added two failing tests now: one to prove that the test detects the issue, and the other to prove that a failure will occur if
testCookies()does not run beforetestCookieDoesNotBleed().Comment #12
almaudoh commentedCore maintainers comments addressed and reversed test sequence fails as desired. I would have set this to RTBC, but:
'A cookie has been set in a previous test.' does not exactly tell why the assertion failed. A more explicit message like 'testCookieDoesNotBleed() runs after testCookie()' or so would be more helpful, especially in the case of parallel testing.
Comment #13
znerol commentedI'm not quite sure and I cannot find any reliable source, but I feel that
staticis preferable overselfnowadays. search query.Comment #14
znerol commentedRe #12 perhaps something like Test methods are run in the expected order?
Comment #15
pfrenssenComment #16
pfrenssenAddressed the remarks.
Comment #18
znerol commentedThanks!
Comment #19
alexpottCommitted ca5fced and pushed to 8.0.x. Thanks!
Comment #21
David_Rothstein commentedI am guessing this needs to be backported, right?
Comment #23
pietmarcus commentedI have backported this issue to Drupal 7. Here is a testonly patch, that will fail.
Comment #24
pietmarcus commentedHere is the patch itself. Please review.
Comment #25
pietmarcus commentedLet me upload the testonly patch again, so it is picked up by the test-server.
Comment #27
pietmarcus commentedAs expected, the test-only patch failed. #24 passed, so I'm changing the status to Needs review again.
Comment #29
Anonymous (not verified) commentedThis patch applied in my localhost. I qued the test again.
Comment #31
pietmarcus commentedThe test only patch failed again. #24, the patch with the fix is the patch up for review.
Comment #32
znerol commentedNice, thanks.
Comment #33
David_Rothstein commentedThis won't work on PHP 5.2, which we technically still support. Is there any reason
self::can't just be used instead?Also, minor, but the @see should actually be a sentence using "See" since it's an inline code comment. I would probably include the class name too, in other words: "See SimpleTestBrowserTestCase::testCookieDoesNotBleed()."
Comment #34
znerol commentedOh, do we even have 5.2 test runners on CI?
Comment #35
pietmarcus commentedI have changed the patch as suggested in #33. Here are a new patch and the interdiff.
Please review!
Comment #37
pietmarcus commentedThe test that failed has nothing to do with the patch, so marking Needs review again.
Comment #38
Anonymous (not verified) commentedI qued for test again.
Comment #39
David_Rothstein commentedLooking better, but:
The @see should not be there. Just the "See". And a period at the end of the sentence.
Since this one is part of the function documentation it should use @see but according to https://www.drupal.org/coding-standards/docs#see. So it should just be "@see SimpleTestBrowserTestCase::testCookies()"
This one will need to use "self::" also.
Comment #40
David_Rothstein commentedNot currently, but I've heard rumors they could exist in the future :) Bottom line, it's worth keeping the tests compatible with PHP 5.2 (like the rest of Drupal) if we can.
Comment #41
pietmarcus commentedFixed the comments made in #39. Please review.
Comment #42
znerol commentedLooks good, thanks.
Comment #43
fabianx commentedThis should still say SimpleTestBrowserTestCase::testCookies.
Could be fixed on commit, though.
Comment #44
stefan.r commented+1, looks great
Comment #45
fabianx commentedStill RTBC and marked for commit.
Comment #46
stefan.r commentedComment #48
fabianx commentedCommitted and pushed to 7.x! Thanks!
Added to CHANGELOG.txt so that module authors know that their tests could have a side effect fixed.