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:
Sergey Biryukov
2021-07-10 11:15:44 +00:00
parent cf7cc2843b
commit d77f065f24
43 changed files with 126 additions and 121 deletions
+5 -3
View File
@@ -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] );
}
}
}