mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Tests: Use better assertions in WP_UnitTestCase_Base::assertEqualFields():
* Check if the object attribute exists before checking its value. * Mention the field name in error messages in case of failure. Follow-up to [51478], [51479], [51480]. Props jrf. See #53363. git-svn-id: https://develop.svn.wordpress.org/trunk@51481 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
d8c3bc78a1
commit
2c0a1f7377
@ -664,7 +664,8 @@ abstract class WP_UnitTestCase_Base extends PHPUnit\Framework\TestCase {
|
||||
*/
|
||||
public function assertEqualFields( $object, $fields, $message = '' ) {
|
||||
foreach ( $fields as $field_name => $field_value ) {
|
||||
$this->assertSame( $object->$field_name, $field_value, $message . ' Field values do not match.' );
|
||||
$this->assertObjectHasAttribute( $field_name, $object, $message . " Property $field_name does not exist on the object." );
|
||||
$this->assertSame( $field_value, $object->$field_name, $message . " Value of property $field_name is not $field_value." );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user