Objective
-
Rename
DrupalUnitTestBasetoKernelTestBase, because that's what it actually is (today). -
You have a functional kernel/service-container, no more, no less.
-
In particular the "Unit" part is 100% misleading, because it is NOT about unit testing — if anything, it's "Integration".
-
The naming was an explicit after-thought in the issue that introduced
DrupalUnitTestBase.
Proposed solution
-
Rename
DrupalUnitTestBasetoKernelTestBase. -
If necessary, retain an (empty)
DrupalUnitTestBase extends KernelTestBaseclass as a BC shim.
Notes
-
A new
HttpKernelTestBase(DUTB +HttpKernel) is in the pipeline already. The proposed new name actively takes that into account.HttpKernelTestBasewill provide the Request/Response architecture to tests, but without an external HTTP layer in between. It will enable very fast end-to-end request-response assertions, without the need to install a fully-fledged test site.The concept is used and natively supported by Symfony, too. (Although we're not able to use the native toolset, as we're missing the BrowserKit component, and that component duplicates functionality offered by Guzzle to some good extent to begin with...)
| Comment | File | Size | Author |
|---|---|---|---|
| #25 | interdiff-2259275-14-23.txt | 645 bytes | filijonka |
| #5 | 2259275-5.patch | 21.1 KB | filijonka |
| #9 | interdiff-2259275-5-9.txt | 3.42 KB | filijonka |
| #14 | test.kernel.14.patch | 42.76 KB | sun |
| #14 | interdiff.txt | 9.64 KB | sun |
Comments
Comment #1
sunOriginal issue.
Comment #2
andypostComment #3
sunComment #4
berdirI like the name but this is an API change, so tagging accordingly, this will affect a lot of modules that already ported tests to DrupalUnitTestBase. It's easy to fix, but we should still notify maintainers about it and I guess it will need a committer approval about the API change?
Comment #5
filijonka commenteda first attempt to even see if I'm in the right direction. There are obvious some doc that needs to be changed but ignoring most of them for now. Cleaned up some things that didn't followed the coding standard.
Comment #6
sunThe coding style/standard changes are out of scope here, please remove them from the patch.
Instead, yes, we need to fix all references to
DrupalUnitTestBase, and we additionally need to check whether the sloppy acronym DUTB might have slipped into a code comments somewhere.We also need to add a @deprecated phpDoc tag to the old class, pointing to the new class name.
Aside from that, the patch appears to do exactly what's desired. FWIW, I wouldn't even mind if we'd ship with the old DUTB class. It would be great to remove it later (prior to beta/stable release or so), but as long as it doesn't block anything else, it would be fine to just leave it around.
Comment #7
filijonka commentedwell if removing whitespaces etc bothers you that much I'll add them back.
about leaving the DUTB class as is if I understood you correctly I don't think that is a good idea.
Simply because let us say that we make changes in the KernelTestBase class this won't be happening in the DUTB class simply cause it's functions will override the KTB class. If empty the KTB class will always be ruling.
Comment #8
sunYes, sorry for not being clear — with "we can leave DUTB around" I meant exactly what this patch is already doing; i.e., turn the
DrupalUnitTestBaseclass into an empty wrapper aroundKernelTestBase.Comment #9
filijonka commentedComment #10
alexpott+1 to leaving DrupalUnitTestBase behind.
Minor nit
Missing space after
8.x-dev.Comment #11
alexpottTherefore not an API change
Comment #12
berdirOk works for me, yeah I think the @deprecated doesn't follow the standard anyway, should be something like this:
Comment #13
filijonka commentedThe doxygen for @deprecated says that the form should be @deprecated Description + saying what the description should say. nothing more about its structure so I kept the structure but made sure it was within 80chars of course.
Also corrected spelling of the KernelTestBase.
thanks for the quick feedback
Comment #14
sunThanks! Final clean-ups:
Comment #15
berdirAs mentioned above, the previous format is what we're doing I thought? Search for @deprecated...
Comment #16
sunSimilar to the
@sincephpDoc directive, the value of@deprecatedspecifies the version in which a resource has been deprecated.Fundamentally, phpDoc directives support values, and (optionally) a separate description. Not to be intermixed. The value must be in a machine-readable format.
Flagging something as
@deprecated 8.0means that it has been deprecated in the 8.0 stable release. By design, and by definition of all available versioning standards, resources cannot be removed within stable releases. Therefore,@deprecated 8.0logically implies that the resource will exist and will be available until the next major version.Conversely, flagging something as
@deprecated 8.xmeans that the resource can and probably will vanish prior to the next stable/major release.All of this is really trivial logic and follows common sense. It's beyond me why we even started to add those invalid phpDoc directives to core. Plenty of my patches have added proper
@deprecateddirectives to core already, following the simple logic outlined above.Comment #17
xanoIt looks like a bunch of usages weren't converted?
Comment #18
sunI did not convert all tests/consumers, because I wasn't sure whether it would cause needless havoc for the rest of the queue... ('cos the old class will stay anyway for now) - don't have a preference myself, mostly depends on what core committers think.
Comment #19
xanoOh, duh. For some reason I thought your patch removed DUTB. Don't ask me why. Feel free to ignore my patch if that is easier.
Comment #20
filijonka commentedI would say it's better to keep this as clean and small as possible and when that is done create (in new issue) a new patch dealing with next step. I wasn't even sure if we would do 1, and 2 that sun did in #14. At least not 2.
Oterwise we might risc ending up with a huge patch that is hard to comprehensive(?). divide and conquer.
@berdir @sun: about the @deprecated, I was probably not clear about this; I agree with you both that this is the way it should be written but for me the documentation on this doesn't say it like that. And most people doesn't seem to write it that way. I'll ask jhodgdon one day when I've time about it.
Comment #21
tim.plunkettThis still needs to be fixed.
As of this comment, there are NO comments with
@deprecated N, where N is a number.https://drupal.org/node/1354#deprecated explains the correct format, which here should be
Comment #22
filijonka commentedWell can we be sure that this will be removed before 8.0?
Comment #23
filijonka commentedbased this on patch in #14
Not sure about the above is correct simply cause ViewUnitTest is not extending or having any reference with ViewTestBase, but perhaps should have.
Also I wonder how come we can move around use statement etc but not remove code violating the coding standard? Tht isn't either in the scope for this issue.
Comment #25
filijonka commentedoh sorry my interdiff got patch extension. here it is as txt..
Comment #26
filijonka commentedComment #27
andypostJust existing change notices needs update:
1) primary https://drupal.org/node/1829160
2) mansions https://drupal.org/node/2235431 and https://drupal.org/node/2235431
Also there should be a follow-up to clean-up usage of old class
Comment #28
catchWe can't (although I'd be OK with a rename - this will break tests for contrib modules, but only the tests), but that's a better promise to break than saying it'll be removed later. Didn't review the patch yet.
Comment #29
catchThis needs a draft change record for the new class + deprecation, shouldn't be RTBC without one.
Comment #30
berdirCreated a follow-up for the conversion/removal (#2271273: Change all tests to extend from KernelTestBase instead of DrupalUnitTestBase + remove DrupalUnitTestBase) and created a change record: https://drupal.org/node/2271271.
Comment #32
alexpottHmmm this got committed as in 341b903 as part of #2228215: Remove module check in DrupalKernel
Fixed this with commit 2ae7acc and pushed to 8.x. Thanks!
Comment #34
xjmThe CR is live. Thanks folks.