Problem/Motivation
CommentHelperCase does not support the two ways two pass $modules that DrupalWebTestCase does. You can see how that leads to awkwardness in CommentNodeAccessTest::setUp() where DrupalWebTestCase::setUp()
is called statically (?!) instead of parent::setUp()
Proposed resolution
Implement CommentHelperCase::setUp
like the following:
function setUp() {
$modules = func_get_args();
if (isset($modules[0]) && is_array($modules[0])) {
$modules = $modules[0];
}
$modules[] = 'comment';
parent::setUp($modules);
// Here comes the rest of the function as it was before.
...
}
Also change CommentNodeAccessTest::setUp() to use parent::setUp('search', 'node_access_test');
instead of DrupalWebTestCase::setUp('comment', 'search', 'node_access_test');
Remaining tasks
Commit the patch. :-)
User interface changes
None.
API changes
None, really. Technically this is an API change for people who sub-class CommentHelperCase, but it's rather fixing something that people expect to work anyway. I'm marking "needs change notification" anyway, because I guess it can't hurt to document this publically, even though few people will care. :-)
Comment | File | Size | Author |
---|---|---|---|
#29 | make_commenthelpercase-1569856-1.patch | 1.13 KB | faline |
#23 | support_modules_var_1569856_23.patch | 1.41 KB | IvoryTierra |
#12 | support_modules_var_1569856_12.patch | 1.56 KB | wizonesolutions |
#10 | support_modules_var_1569856_8.patch | 1.57 KB | wizonesolutions |
#8 | support_modules_var_1569856_8.patch | 1.57 KB | wizonesolutions |
Comments
Comment #1
tstoecklerOh, and also CommentNodeAccessTest needs to be changed to use parent::setUp(). Edited issue summary accordingly.
Comment #2
sunFor D8, this duplicates: #1380958: Replace $modules list for WebTestBase::setUp() with ::$modules class properties
Comment #3
wizonesolutionsTwin Cities sprint.
Comment #4
wizonesolutionsComment #5
wizonesolutionsMy first core patch evar attached.
Comment #6
sunThis comment and following blank line can be removed.
This needs to be $modules[] or comment module won't be added if $modules is not empty.
How much of the following setup code is further duplicated in CommentNodeAccessTest?
Note: It's possible that there are differences, so it might not be duplicated at all and needs to be retained then.
Comment #7
wizonesolutionsComment #8
wizonesolutionsHere's a modified patch that should address your comments. The user in CommentNodeAccessTest was unique, so I left that alone. Removed the other two lines.
Also changed the += to an = since it now uses
$modules[]
.Comment #9
wizonesolutionsUnassigning, status change.
Comment #10
wizonesolutionsGuess I've gotta attach the patch again for testbot.
Comment #11
tstoecklerThis needs to be
Currently this would result in:
Comment #12
wizonesolutionsAh, good point. Fixed and attached.
Comment #13
tstoecklerSince this references
$this->web_user
, which is a different user than in the parent implementation, this line should not be removed.Alternatively, we could just grant the user the 'node test view' permission. E.g.
user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('node test view'))
. I haven't seen that in tests before, though, so maybe that's not wanted.Comment #14
sunThere's nothing wrong with overriding $this->web_user from the parent class in this test.
This looks RTBC, but no idea why testbot doesn't come back green. Sending for re-test.
Comment #15
tstoecklerWell, since in this case only view permissions are required I guess it's OK do that, but it's still kind of weird, because:
I can live with that, though.
Comment #16
sunGood point + finding. But yeah, as long as the particular test doesn't rely on $this->node->uid, there's no harm here and this is good to go.
Comment #16.0
sunUpdated issue summary.
Comment #16.1
tstoecklerUpdated issue summary.
Comment #17
tstoecklerUpdated issue summary, so that the code example actually resembles the latest patch.
RTBC++
Comment #18
aspilicious CreditAttribution: aspilicious commented#12: support_modules_var_1569856_12.patch queued for re-testing.
Comment #20
wizonesolutionsThe structure of the comment tests seems to have changed. Any guidance on what the changes were (seems like more abstraction) and how I could re-roll my patch appropriately if it's still necessary?
Comment #21
tstoecklerYes the change are still needed.
What was
CommentHelperCase
before is nowCommentTestBase
and it no longer lives incore/modules/comment/comment.test
but incode/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php
. The actual code changes should be (I think) the same as before.Comment #22
star-szrTagging.
Comment #23
IvoryTierra CreditAttribution: IvoryTierra commentedHi folks.... I am new to drupal and I have gotten lots of help from the awesome kbasarab with this patch.
It was not possible to re-roll so I have created a new patch. Please review and all comments are appreciated. Thanks!!!
--Tierra
PS The guys at mediacurrent are so great and knowledgeable! Thanks for the help! @drupalcampatlanta
Comment #24
tstoecklerSince #1380958: Replace $modules list for WebTestBase::setUp() with ::$modules class properties is now in D8, this is obsolete for D8. We should still do this for D7, though.
@IvoryTierra: I'm very sorry that your work on porting this to D8 was in vein. I didn't realize we still had this one open. Thank you very much for your contribution, though. If you still would like to bring this issue forward, you could back-port your new patch to D7 (or alternatively, use the patch in #12 as a starting point, I'm not sure which is easier).
Marking for D7
Comment #25
Gaelan CreditAttribution: Gaelan commentedComment #26
tstoeckler#23: support_modules_var_1569856_23.patch queued for re-testing.
Comment #28
tstoecklerComment #28.0
tstoecklerUpdated issue summary.
Comment #29
faline CreditAttribution: faline at CI&T commentedCreate the patch as described in the updated summary
Comment #30
cebasqueira CreditAttribution: cebasqueira commentedIt's works for me!
Comment #31
Fabianx CreditAttribution: Fabianx as a volunteer commentedWhy not :).
This is tests only and hence should be an eligible change for D7.
Marking for commit.
Comment #32
Fabianx CreditAttribution: Fabianx as a volunteer commentedCommitted and pushed to 7.x. Thanks!
Comment #34
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedFYI, Drupal 7.53 wound up just being a small bugfix release (to fix a single regression from Drupal 7.51) so this issue was not included there. It will be in the next non-security release instead.