Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Do not allow PHPUnit tests to test an interface. Generaly you cannot test an interace, so do not allow it.
Proposed solution
Let the DrupalStandardsListener class generate a failure when a PHPUnit test is testing an interface.
Beta phase evaluation
Unfrozen changes | Unfrozen because it improves automated testing. |
---|---|
Disruption | Not disruptive because no PHPUnit test is testing an interface. |
Comment | File | Size | Author |
---|---|---|---|
#16 | 2428753.patch | 2.46 KB | borisson_ |
Comments
Comment #1
daffie CreditAttribution: daffie commentedComment #2
franksj CreditAttribution: franksj commentedI changed Drupal\Tests\Component\Utility\HtmlTest to @coversDefaultClass \Drupal\Component\Utility\ArgumentsResolverInterface and it did start giving errors.
However, the interface does actually exist, it's just that we aren't allowing it. Should we change the failure to reflect why the test is really failing?
Comment #4
dawehnerI agree that message is not that helpful yet.
Comment #9
borisson_Reroll + fixes #4.
Comment #11
borisson_There was one instance in core where this was happening, fixed that.
Comment #12
dawehner@borisson_ Nice find!
Would it make sense to merge these 2 ifs?
Comment #13
borisson_@dawehner:
We could do this instead, but I don't think that's a big improvement.
Comment #14
borisson_@dawehner is #13 what you meant to improve in #12?
Comment #15
dawehner+1 for #13
Comment #16
borisson_Ok, done.
Comment #17
borisson_Is there anything we can do other than a review to get this issue in? Does this need a change notice?
Comment #18
dawehnerDo you know whether we can ship with an invalid use and have that to be a test?
Comment #19
borisson_I think #9 is sufficient to prove that this works?
Comment #20
dawehnerWell, an automated way which doesn't break in the future would be nice I guess. But yeah I see your point. Well, let's see whether a core committer complains.
Comment #21
alexpottLet's open a followup for testing DrupalStandardsListenerTrait as there is no test so far.
Crediting @dawehner and @franksj for reviews and testing.
Comment #22
alexpottCommitted 7c6f4ae and pushed to 8.6.x. Thanks!