-
Notifications
You must be signed in to change notification settings - Fork 309
Enforce PHPUnit assertion messages #10902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Enforce PHPUnit assertion messages #10902
Conversation
Build files for 96fc58d are ready:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @benbowler LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @benbowler. Almost all looks good, but there is one thing that we need to address here. Please, take a look.
$this->assertion_methods = array_filter( | ||
get_class_methods( Assert::class ), | ||
function ( $method ) { | ||
return 0 === strpos( $method, 'assert' ); | ||
} | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checking just the Assert
class is not enough because we also have a custom assert method defined in the TestCase
class that also has the $message
argument:
site-kit-wp/tests/phpunit/includes/TestCase.php
Lines 224 to 228 in 44f18cd
protected function assertArrayIntersection( array $subset, array $array_to_check, $message = '' ) { | |
$intersection = array_intersect_key( $array_to_check, $subset ); | |
$this->assertEqualSetsWithIndex( $subset, $intersection, $message ); | |
} |
We need to make sure such custom assert methods are not ignored.
Summary
Addresses issue:
Relevant technical choices
PR Author Checklist
Do not alter or remove anything below. The following sections will be managed by moderators only.
Code Reviewer Checklist
Merge Reviewer Checklist