Closed (fixed)
Project:
Flag
Version:
8.x-4.x-dev
Component:
Flag core
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
9 Apr 2016 at 14:13 UTC
Updated:
28 Apr 2016 at 15:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
martin107 commentedHere is the conversion
I tried creating a trait, but the code was too highly coupled and dependant on all sorts of things like the $modules class variable and schema initialization
it looked a mess so I backed it out.....
For me the speed up was from 1min2s -> 28s. Nothing to sneeze at but also not that significant.
Comment #3
berdirI guess the reason for that is that you change the doTest* methods to standalone test methods. Without that pattern, the test would be ~3x slower as a web test.
I agree with doing that, as the performance is still acceptable and it leads to better separation.
Comment #4
berdiryou could move this into setup, I think it's always the same?
Yeah, trait doesn' really seem worth it yet, we could make a base class with the setUp() method since that seems to be pretty much identical for both tests that we have now.
Comment #5
martin107 commentedThanks for the prompt review
Yes, I took myself out for a long walk after posting the patch and was kicking myself the whole way round - because of that.
Comment #7
martin107 commentedFlagKernelTestBase is now abstract.
and I tweaked the incorrect class annonation.
Comment #8
berdirLooks good to me.
Comment #9
joachim commentedTypos here.
Comment #10
martin107 commentedarround -> around
Oh crap I misspelled that in middle school too.
I have just updated my phpcs ruleset - @file is not to be removed from class/interface/trait files.
Comment #11
socketwench commentedEverything looks good, but FlagKernelTestBase appears in the WebUI. Is there a way to prevent that? Maybe remove @group?
Comment #12
berdirYes. Don't add the @group. Sorry, I missed that.
Comment #13
martin107 commentedGood catch thanks - also added a newline expected by phpcs.
Comment #14
socketwench commentedWhy are we creating the flag in FlagKernelTestBase? Shouldn't this be the responsibility of the child class?
Comment #15
martin107 commentedWhat we have currently is not a pattern, I feel attached to....
So the pros and cons
1) If the pattern is 'setup supplies objects common to all test using this base' - so with a view to converting FlagCountsTest to a kernel test that extends this base class then we are in good company as FlagCountsTest::setup() provides both a Flag and a Node on tap...
2) I can see a counter example
I think
#2704959: FlagCountManager::decrementCounts() doesn't handle empty results gracefully
is a example where the test to be added might benefit from the guarantee that no stray stuff is the system before we exercise the deleting methods.... but I think this is a minor point.
@socketwench - what is you feeling on this ... do you think it puts unnecessary fluff in the setup, or is it that forces the next developer into a pattern that does not suit every situation?
Comment #16
martin107 commentedI am a paranoid bunny, who frequently jumps the gun.
So TDLR I am splitting off a couple of site issues.
Looking at the code coverage reports of my own work frequently makes me laugh out loud and cringe in equal measure.
One unstated advantage of this issue is that we can now spot holes in test coverage visually.
so to generate a report based on our 3 shiny new kernel tests type something like
cd core
../vendor/bin/phpunit --group flag --coverage-html ~/codeCoverage/
Comment #17
socketwench commentedMostly I'm concerned that we'll run into the situation where we may need more than one flag or node in a test -- something that is the case in many of our simpletests -- and the variables will look....weird. Kernel tests may be different than our simpletests, and creating a standard flag or node out the box is just a common pattern. The thing is, we can't really know that right now. Flags and nodes are also such highly individual things that moving their creation to the child classes just makes more sense to me.
Comment #18
martin107 commentedOkeydokey
reversing #4
Comment #20
socketwench commentedThat works. We should also consider refactoring flag and node creation into base class methods (rather than setUp()) for child classes to call. We can do that in another issue.