Move Optimization Detective test cases into separate files and add helper trait to reduce code duplication#1405
Conversation
83bf261 to
174a2a2
Compare
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
| * @package auto-sizes | ||
| */ | ||
|
|
||
| require_once __DIR__ . '/../../../tests/class-optimization-detective-test-helpers.php'; |
There was a problem hiding this comment.
We could load this just once in bootstrap, instead of in every test.
Or maybe an autoloader at some point :-)
There was a problem hiding this comment.
Yeah, adding it to the bootstrap is a good idea. I recall we did have an autoloader previously but it was removed as discussed in #1262 (comment)
swissspidy
left a comment
There was a problem hiding this comment.
That's a lot of changed lines, but it makes the test cases definitely more manageable 👍
Yeah, sorry. But it's almost entirely just moving code from one place to another. |
Co-authored-by: Pascal Birchler <[email protected]>
The test files are too large with the cases for testing Optimization Detective behavior. They need to be split into separate files to make this easier to work with. This has been done for:
It was overkill for Auto Sizes since the test data is smaller as it is only testing individual
imgtags not entire documents.This PR also removes a lot of duplication across plugin test suites by moving duplicated
populate_url_metrics,get_validated_url_metric, andremove_initial_tabsmethods to a newOptimization_Detective_Test_Helpershelper trait.