mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 04:40:26 +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:
@@ -702,7 +702,7 @@ class Tests_AdminBar extends WP_UnitTestCase {
|
||||
|
||||
$nodes = $wp_admin_bar->get_nodes();
|
||||
foreach ( $this->get_my_sites_network_menu_items() as $id => $cap ) {
|
||||
$this->assertFalse( isset( $nodes[ $id ] ), sprintf( 'Menu item %s must not display for a regular user.', $id ) );
|
||||
$this->assertArrayNotHasKey( $id, $nodes, sprintf( 'Menu item %s must not display for a regular user.', $id ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -719,7 +719,7 @@ class Tests_AdminBar extends WP_UnitTestCase {
|
||||
|
||||
$nodes = $wp_admin_bar->get_nodes();
|
||||
foreach ( $this->get_my_sites_network_menu_items() as $id => $cap ) {
|
||||
$this->assertTrue( isset( $nodes[ $id ] ), sprintf( 'Menu item %s must display for a super admin.', $id ) );
|
||||
$this->assertArrayHasKey( $id, $nodes, sprintf( 'Menu item %s must display for a super admin.', $id ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -745,9 +745,9 @@ class Tests_AdminBar extends WP_UnitTestCase {
|
||||
$nodes = $wp_admin_bar->get_nodes();
|
||||
foreach ( $this->get_my_sites_network_menu_items() as $id => $cap ) {
|
||||
if ( in_array( $cap, $network_user_caps, true ) ) {
|
||||
$this->assertTrue( isset( $nodes[ $id ] ), sprintf( 'Menu item %1$s must display for a user with the %2$s cap.', $id, $cap ) );
|
||||
$this->assertArrayHasKey( $id, $nodes, sprintf( 'Menu item %1$s must display for a user with the %2$s cap.', $id, $cap ) );
|
||||
} else {
|
||||
$this->assertFalse( isset( $nodes[ $id ] ), sprintf( 'Menu item %1$s must not display for a user without the %2$s cap.', $id, $cap ) );
|
||||
$this->assertArrayNotHasKey( $id, $nodes, sprintf( 'Menu item %1$s must not display for a user without the %2$s cap.', $id, $cap ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user