Closed (fixed)
Project:
Panopoly
Version:
7.x-1.x-dev
Component:
Tests / Continuous Integration
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
21 Jul 2014 at 05:23 UTC
Updated:
17 Oct 2014 at 12:04 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
trevjs commentedComment #2
trevjs commentedThis seems to do the job.
Comment #3
trevjs commentedComment #4
dsnopekThanks @trevjs!
Some review:
Random indentation change.
This is the meat of the patch! It's taking a (hopefully) existing username, rather than creating a new one.
However, I don't think this is quite right. We don't really know that that user exists, and we're not removing it anywhere.
I think creating a new user with a randomly generated username is fine. We just need to make sure to delete it after the tests are finished.
That step is adding the new users to
$this->users, however, now that this in a sub-context, rather than part of the main context (like it used to be before #2293747: Move our FeatureContext and *.features into panopoly_test so that child distributions can reuse them), we're no longer removing those users later.I think what we need is just a method tagged
@AfterScenariothat loops through those users and deletes them. For example (untested):Comment #5
trevjs commentedThanks for the review. I'll put in a patch for the indent at least, however, as far as I can tell this does remove the user. Let me outline my thinking, and you can correct me if I'm wrong.
At the start of the feature we have this to set up a user named TestUser:
And in the two previous scenarios we are passing in the name of this user. Example
The Background/Given users does appear to clean up for itself, and so my approach was to change the one time login test to also pass in the name of "TestUser" and rewrote the step to accomodate this. Prior to this it was creating a new user in the step with a random username and that is how we were ending up with users that weren't being cleaned up. I changed it to use "TestUser" because this approach seemed consistent with the previous two tests.
Does that make sense? Or was there a reason we wanted to use a randomly generated user rather than the "TestUser" created at the start of the feature? Perhaps we need some sort of check to see if the user exists?
Let me know what you think and I'll put in another patch.
Comment #6
dsnopekAh, ok, so it's depending on the "Given users" step. However, I'd still prefer just to fix the way we were doing it before, ie. removing the new users we're creating at the end of the Scenario.
Comment #7
trevjs commentedSomething along these lines? This checks at the end of every scenario.
Comment #8
trevjs commentedSee below...
Comment #9
trevjs commentedThis seems to work. I was having some trouble using xdebug, but the random user is removed.
Comment #10
dsnopekYeah, that's pretty much what I was thinking, thanks! Can you make two changes:
removeUsers()method, clear out$this->users- otherwise it'll continue to accumulate values with each scenario run.Comment #11
trevjs commentedComment #12
dsnopekThanks! One last bit of review:
Rather than
unset()this, let's set it to an empty array like:This way that member variable is always a valid array (which is part of the reason I wanted to declare it as well).
Comment #13
trevjs commentedI was thinking the same thing.
Comment #14
trevjs commentedComment #16
dsnopekLooks great, thanks! Committed.