Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
simpletest.module
Priority:
Normal
Category:
Task
Assigned:
Issue tags:
Reporter:
Created:
3 May 2014 at 04:23 UTC
Updated:
29 Jul 2014 at 23:35 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
sunFirst: The basic trait change. Should come back green.
Comment #3
sunFixed WebTestBaseTest.
Comment #4
sunAdded trait to DrupalUnitTestBase.
→ Checking whether any DUTB test implements custom copies of the methods already (which should cause PHP strict warnings).
Comment #7
sunThe test results are incomplete, so I quickly whipped up a script to check all existing DUTB tests for clashing methods.
Lines prefixed with a - sign are conflicting methods.
Comment #8
sunComment #9
sunUpdated for #1939008: Convert theme_table() to Twig
Comment #10
larowlanShould have the return type (I realise this is C/P but pretty sure we have to fix when we touch it) - fixed in attached (only changes in attached are coding standards)
$html_dom (c/p) - also fixed?
pass, fail, assert and getUrl methods aren't in the trait - but should be if the trait needs them. Even if they're just abstract in the trait or throw Exceptions. Same for assertEqual, assertTrue, assertFalse, assertIdentical, verbose and assertNotEqual? I thought the idea here was that you could drop this trait into any class. But this seems to not fit that - it relies on these methods that are in TestBase.
Comment #11
larowlanOf course I could totally have traits wrong
Comment #13
wim leersWhere was that introduced? :) I'd love to convert as many tests as possible in the components I maintain!
Comment #14
larowlancouple of these where second argument is optional but subsequent arguments aren't.
I changed them around but it broke some stuff.
hoping this fixes.
Comment #15
sunThanks @larowlan! :-)
Updated recently revised ScriptTest for new trait methods.
re: #10.2: I don't know whether we have a custom Drupal "standard" for traits either, but IMO from a purely technical standpoint, traits are just a tool to copy/paste code at compile time... The two classes that use the trait are not in the same inheritance hierarchy, so the trait nicely resolves that issue. Even if there may be a policy for traits, I really hope that we can make an exception for the testing framework code here.
This change will be a huge help for all the DUTB conversions for #2258173: [meta] Various web tests are not performing any HTTP requests, so I'd really love to get this in ASAP. :-)
@Wim Leers: I can't remember since when exactly, but it's possible for at least ~1.5 years already. In essence,
DrupalUnitTestBaseis aKernelTestBase, so whatever you can do with a kernel you can do in a DUTB test. However, due to the lack of helper and assertion methods, it has been (too) complex/cumbersome to author content/output related tests. Hence this issue :-)This improvement here is also a prerequisite for a new
HttpKernelTestBase(DUTB +HttpKernel), which I already toyed around with on my local disk, and for which I'll create an issue after this patch has landed.Comment #16
wim leersWow. Wow. The consequences of this issue are going to be *awesome*. Thanks for the explanation, and for working on this! :)
Comment #17
sunI consider this patch RTBC from my perspective.
Comment #18
larowlanSpoke with folks in irc and both timplunkett and Crell agreed that the trait should provide abstract stubs for the methods it calls but does not implement.
Comment #19
larowlanMore irc discussions: Crell and timplunkett are happy with this as is because its only for test assertions, not runtime code.
Comment #20
sunAs this is RTBC already, and because it would really be great to move forward on DUTB conversions ASAP, and because the discussion on more explicit method declarations in test helper traits could very well take a bit longer, I'd like to move that into a dedicated follow-up issue:
#2260053: Make test helper traits explicitly define expected TestBase methods
Comment #22
sun15: test.content.15.patch queued for re-testing.
Comment #23
sun#2262085: Random test failure in Drupal\image\Tests\ImageFieldDisplayTest
Comment #25
cs_shadow commentedPatch in #14 no longer applies due to a recent change in WebTestBase.php.
Rerolled the patch in #14 against latest HEAD.
Comment #27
sunMerged 8.x + Fixed merge conflicts.
Comment #29
sunMerged 8.x + updated for renamed
KernelTestBase.Comment #31
sun29: test.content.29.patch queued for re-testing.
Comment #32
sunComment #33
sunAny chance to get this in?
Comment #34
xjmReroll for #2247991: [May 27] Move all module code from …/lib/Drupal/… to …/src/… for PSR-4.
Comment #35
tim.plunkettComment #37
sunMerged 8.x.
Comment #39
sunMerged 8.x.
Comment #40
alexpottNeeds a reroll
Comment #41
sunMerged 8.x + resolved conflicts.
Comment #42
chx commentedI love traits but isn't this excessive? Why can't this be either in TestBase or a common base class one step above TestBase?
Comment #43
sunA trait is the most appropriate implementation respecting the architecture. The base classes are not and should not be in the same inheritance chain. UnitTestBase should not have these content assertion methods. The trait also allows us to rethink and work on alternative test base classes.
Comment #45
sunMerged 8.x + resolved merge conflicts.
Comment #47
larowlanreroll after #2282683: Responsive tables do not have tests
Comment #48
sunThanks @larowlan. Still the same patch, so RTBC.
However, removing some unintentional garbage from #47:
Comment #49
alexpottIt would have been nice if the issue summary or somewhere documented this change... anyhow this needs a change notice before it can be committed since you are now changing public API method names. And we need to check exiting change records (unlikely I know)
Above are changes I would have made on commit - that need doing.
Comment #50
sunIncorporated diff from #49.
Actually, the existing methods on
WebTestBaseare not removed by this patch; they are retained as BC wrappers/aliases for the new methods and have been marked as @deprecated. I would have added an API change notice to the issue summary otherwise.Unless I'm mistaken, we only publish CRs when functions are removed, no?
Comment #53
sunUpdated for latest DisplayApiTest in HEAD.
With that we should be back to RTBC. Regarding CR, see #50.
Comment #54
alexpottCommitted 8501b7f and pushed to 8.x. Thanks!
Comment #56
alexpottWe should update https://www.drupal.org/node/1829160 to note that these assertions are available.