While working on #352951: Make JS & CSS Preprocessing Pluggable, I got very much fed up with the extreme slowness of CascadingStylesheetsTest.php
.
Difference
- Before: 281 seconds
- After: 8 seconds
- (That's 35.125 times faster, or only 2.85% of the original test running time.)
It used WebTestBase
for historical reasons, while it could easily use DrupalUnitTestBase
now.
Ideally, this would be a PHPUnit test, but that's not technically possible right now. This will at least make it a whole lot faster, while retaining the same test coverage.
Changes
I changed as little as possible:
DrupalWebTestBase
->DrupalUnitTestBase
- Removed
testRenderInlineFullPage()
since it was rather pointless: it tests adding inline CSS, but that's already tested in two other tests, and in fact to do so it used the PHP filter of all things… - Instead of relying on a certain page callback in
common_test
module, which would indeed needWebTestBase
, I just moved the relevant parts ofcommon_test.module
into the test itself (2 lines of code).