mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-13 05:10:18 +00:00
Tests: Use more appropriate assertions in various tests.
This replaces instances of `assertTrue( isset( ... ) )` with `assertArrayHasKey()` to use native PHPUnit functionality. Follow-up to [51335], [51337], [51367]. See #53363. git-svn-id: https://develop.svn.wordpress.org/trunk@51397 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -166,7 +166,8 @@ class Tests_User extends WP_UnitTestCase {
|
||||
// For reasons unclear, the resulting array is indexed numerically; meta keys are not included anywhere.
|
||||
// So we'll just check to make sure our values are included somewhere.
|
||||
foreach ( $vals as $k => $v ) {
|
||||
$this->assertTrue( isset( $out[ $k ] ) && $out[ $k ][0] === $v );
|
||||
$this->assertArrayHasKey( $k, $out );
|
||||
$this->assertSame( $v, $out[ $k ][0] );
|
||||
}
|
||||
// Delete one key and check again.
|
||||
$keys = array_keys( $vals );
|
||||
@@ -176,9 +177,10 @@ class Tests_User extends WP_UnitTestCase {
|
||||
// Make sure that key is excluded from the results.
|
||||
foreach ( $vals as $k => $v ) {
|
||||
if ( $k === $key_to_delete ) {
|
||||
$this->assertFalse( isset( $out[ $k ] ) );
|
||||
$this->assertArrayNotHasKey( $k, $out );
|
||||
} else {
|
||||
$this->assertTrue( isset( $out[ $k ] ) && $out[ $k ][0] === $v );
|
||||
$this->assertArrayHasKey( $k, $out );
|
||||
$this->assertSame( $v, $out[ $k ][0] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user