mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Tests: Modernize the WP_UnitTestCase_Base::assertEqualFields() method:
* Use `assertSame()` instead of `fail()` to display a proper message in case of failure. * Add an optional `$message` parameter for consistency with other assertions. Follow-up to [51478], [51479]. See #53363. git-svn-id: https://develop.svn.wordpress.org/trunk@51480 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
dc568b181b
commit
d8c3bc78a1
@ -655,14 +655,16 @@ abstract class WP_UnitTestCase_Base extends PHPUnit\Framework\TestCase {
|
||||
/**
|
||||
* Asserts that the given fields are present in the given object.
|
||||
*
|
||||
* @param object $object The object to check.
|
||||
* @param array $fields The fields to check.
|
||||
* @since UT (3.7.0)
|
||||
* @since 5.9.0 Added the `$message` parameter.
|
||||
*
|
||||
* @param object $object The object to check.
|
||||
* @param array $fields The fields to check.
|
||||
* @param string $message Optional. Message to display when the assertion fails.
|
||||
*/
|
||||
public function assertEqualFields( $object, $fields ) {
|
||||
public function assertEqualFields( $object, $fields, $message = '' ) {
|
||||
foreach ( $fields as $field_name => $field_value ) {
|
||||
if ( $object->$field_name !== $field_value ) {
|
||||
$this->fail();
|
||||
}
|
||||
$this->assertSame( $object->$field_name, $field_value, $message . ' Field values do not match.' );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user