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.
Problem/Motivation
In #2850797: Prepare our phpunit tests to be BC compatible with phpunit 5.x/6.x we found that some component tests are extending the core class Drupal\Tests\UnitTestCase. They should be extending PHPUnit\Framework\TestCase instead.
Proposed resolution
Replace Drupal\Tests\UnitTestCase by PHPUnit\Framework\TestCase.
Remaining tasks
Review.
User interface changes
None.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#10 | 2866894-10.patch | 48.67 KB | maxocub |
#7 | 2866894-7.patch | 48.63 KB | maxocub |
#7 | 2866894-7-test-only.patch | 1.54 KB | maxocub |
#3 | 2866894-3.patch | 47.08 KB | maxocub |
Comments
Comment #2
maxocub CreditAttribution: maxocub commentedComment #3
maxocub CreditAttribution: maxocub commentedHere some additional modifications that were required:
Comment #4
Mile23+1 on this.
Also, we should add a test listener to make sure that tests in the
Drupal\Tests\Component\
namespace don't inherit from UTC, KTB or BTB or other Drupal test bases. That will avoid regressions.Look at
DrupalStandardsListener
for an example of how to do this.Comment #5
maxocub CreditAttribution: maxocub commented@Mile23: Good idea, I'll do that, thanks.
Comment #6
klausiPatch looks good, needs work for the listener.
Comment #7
maxocub CreditAttribution: maxocub commentedFirst time using a test listener, so not sure if I'm doing it right.
The test-only patch is the interdiff from the last patch.
Comment #8
maxocub CreditAttribution: maxocub commentedThere's still 3 core classes that are used in a component test:
I guess we should open a follow-up since it's out of scope of this issue?
Comment #10
maxocub CreditAttribution: maxocub commentedPatch no longer applied, Re-rolled.
Comment #11
Mile23Listener-only patch in #7 proves that the listener works.
Everything else looks good.
I was a little concerned about the instances of this substitution but the tests pass, so yay.
assertArrayEquals()
appliesksort()
to both arrays before comparing. But the tests pass here, and will fail if the arrays are assembled differently in the future. This is better than modifying the arrays so they're comparable because the expectation is more exact.Comment #13
larowlanAgree
Committed as 13e93c0 and pushed to 8.5.x.
Cherry-picked as 00c6cf4 and pushed to 8.4.x.
Comment #15
maxocub CreditAttribution: maxocub as a volunteer and commented