diff --git a/tests/phpunit/tests/bookmark/getBookmarks.php b/tests/phpunit/tests/bookmark/getBookmarks.php index d70162e2ed..45b5af91d0 100644 --- a/tests/phpunit/tests/bookmark/getBookmarks.php +++ b/tests/phpunit/tests/bookmark/getBookmarks.php @@ -55,7 +55,7 @@ class Tests_Bookmark_GetBookmarks extends WP_UnitTestCase { ); $this->assertEqualSets( $bookmarks, wp_list_pluck( $found2, 'link_id' ) ); - $this->assertTrue( $num_queries < $wpdb->num_queries ); + $this->assertGreaterThan( $num_queries, $wpdb->num_queries ); } /** @@ -82,7 +82,7 @@ class Tests_Bookmark_GetBookmarks extends WP_UnitTestCase { // Equal sets != same order. $this->assertEqualSets( $found1, $found2 ); - $this->assertTrue( $num_queries < $wpdb->num_queries ); + $this->assertGreaterThan( $num_queries, $wpdb->num_queries ); } public function test_exclude_param_gets_properly_parsed_as_list() { diff --git a/tests/phpunit/tests/cron.php b/tests/phpunit/tests/cron.php index 36b974cf1a..6fe4c32bb5 100644 --- a/tests/phpunit/tests/cron.php +++ b/tests/phpunit/tests/cron.php @@ -126,15 +126,15 @@ class Tests_Cron extends WP_UnitTestCase { wp_schedule_single_event( strtotime( '+4 hour' ), $hook, $args ); // Make sure they're returned by wp_next_scheduled(). - $this->assertTrue( wp_next_scheduled( $hook ) > 0 ); - $this->assertTrue( wp_next_scheduled( $hook, $args ) > 0 ); + $this->assertGreaterThan( 0, wp_next_scheduled( $hook ) ); + $this->assertGreaterThan( 0, wp_next_scheduled( $hook, $args ) ); // Clear the schedule for the no args events and make sure it's gone. $hook_unscheduled = wp_clear_scheduled_hook( $hook ); $this->assertSame( 2, $hook_unscheduled ); $this->assertFalse( wp_next_scheduled( $hook ) ); // The args events should still be there. - $this->assertTrue( wp_next_scheduled( $hook, $args ) > 0 ); + $this->assertGreaterThan( 0, wp_next_scheduled( $hook, $args ) ); // Clear the schedule for the args events and make sure they're gone too. // Note: wp_clear_scheduled_hook() expects args passed directly, rather than as an array. @@ -165,14 +165,14 @@ class Tests_Cron extends WP_UnitTestCase { wp_schedule_single_event( strtotime( '+4 hour' ), $hook, $args ); // Make sure they're returned by wp_next_scheduled(). - $this->assertTrue( wp_next_scheduled( $hook ) > 0 ); - $this->assertTrue( wp_next_scheduled( $hook, $args ) > 0 ); + $this->assertGreaterThan( 0, wp_next_scheduled( $hook ) ); + $this->assertGreaterThan( 0, wp_next_scheduled( $hook, $args ) ); // Clear the schedule for the no args events and make sure it's gone. wp_clear_scheduled_hook( $hook ); $this->assertFalse( wp_next_scheduled( $hook ) ); // The args events should still be there. - $this->assertTrue( wp_next_scheduled( $hook, $args ) > 0 ); + $this->assertGreaterThan( 0, wp_next_scheduled( $hook, $args ) ); // Clear the schedule for the args events and make sure they're gone too. // Note: wp_clear_scheduled_hook() used to expect args passed directly, rather than as an array pre WP 3.0. @@ -198,14 +198,14 @@ class Tests_Cron extends WP_UnitTestCase { wp_schedule_single_event( strtotime( '+6 hour' ), $multi_hook, $multi_args ); // Make sure they're returned by wp_next_scheduled(). - $this->assertTrue( wp_next_scheduled( $hook ) > 0 ); - $this->assertTrue( wp_next_scheduled( $hook, $args ) > 0 ); + $this->assertGreaterThan( 0, wp_next_scheduled( $hook ) ); + $this->assertGreaterThan( 0, wp_next_scheduled( $hook, $args ) ); // Clear the schedule for the no args events and make sure it's gone. wp_clear_scheduled_hook( $hook ); $this->assertFalse( wp_next_scheduled( $hook ) ); // The args events should still be there. - $this->assertTrue( wp_next_scheduled( $hook, $args ) > 0 ); + $this->assertGreaterThan( 0, wp_next_scheduled( $hook, $args ) ); // Clear the schedule for the args events and make sure they're gone too. // wp_clear_scheduled_hook() should take args as an array like the other functions. @@ -232,8 +232,8 @@ class Tests_Cron extends WP_UnitTestCase { wp_schedule_single_event( strtotime( '+4 hour' ), $hook, $args ); // Make sure they're returned by wp_next_scheduled(). - $this->assertTrue( wp_next_scheduled( $hook ) > 0 ); - $this->assertTrue( wp_next_scheduled( $hook, $args ) > 0 ); + $this->assertGreaterThan( 0, wp_next_scheduled( $hook ) ); + $this->assertGreaterThan( 0, wp_next_scheduled( $hook, $args ) ); // Clear the schedule and make sure it's gone. $unschedule_hook = wp_unschedule_hook( $hook ); diff --git a/tests/phpunit/tests/meta.php b/tests/phpunit/tests/meta.php index 72cc004a1c..cb819b7d5f 100644 --- a/tests/phpunit/tests/meta.php +++ b/tests/phpunit/tests/meta.php @@ -344,7 +344,7 @@ class Tests_Meta extends WP_UnitTestCase { function test_negative_meta_id() { $negative_mid = $this->meta_id * -1; - $this->assertTrue( $negative_mid < 0 ); + $this->assertLessThan( 0, $negative_mid ); $this->assertFalse( get_metadata_by_mid( 'user', $negative_mid ) ); $this->assertFalse( update_metadata_by_mid( 'user', $negative_mid, 'meta_new_value' ) ); $this->assertFalse( delete_metadata_by_mid( 'user', $negative_mid ) ); diff --git a/tests/phpunit/tests/multisite/network.php b/tests/phpunit/tests/multisite/network.php index f8ad85afe8..8a8e5537ee 100644 --- a/tests/phpunit/tests/multisite/network.php +++ b/tests/phpunit/tests/multisite/network.php @@ -451,7 +451,8 @@ if ( is_multisite() ) : $site_count = (int) get_blog_count(); $user_count = (int) get_user_count(); - $this->assertTrue( $site_count > 0 && $user_count > 0 ); + $this->assertGreaterThan( 0, $site_count ); + $this->assertGreaterThan( 0, $user_count ); } /** @@ -466,7 +467,8 @@ if ( is_multisite() ) : $site_count = (int) get_blog_count( self::$different_network_id ); $user_count = (int) get_user_count( self::$different_network_id ); - $this->assertTrue( $site_count > 0 && $user_count > 0 ); + $this->assertGreaterThan( 0, $site_count ); + $this->assertGreaterThan( 0, $user_count ); } /** diff --git a/tests/phpunit/tests/post.php b/tests/phpunit/tests/post.php index 7923288ec0..7e87f29eae 100644 --- a/tests/phpunit/tests/post.php +++ b/tests/phpunit/tests/post.php @@ -80,7 +80,7 @@ class Tests_Post extends WP_UnitTestCase { // Insert a post and make sure the ID is OK. $id = wp_insert_post( $post ); $this->assertIsNumeric( $id ); - $this->assertTrue( $id > 0 ); + $this->assertGreaterThan( 0, $id ); // Fetch the post and make sure it matches. $out = get_post( $id ); @@ -136,7 +136,7 @@ class Tests_Post extends WP_UnitTestCase { $this->post_ids[] = $id; // dmp( _get_cron_array() ); $this->assertIsNumeric( $id ); - $this->assertTrue( $id > 0 ); + $this->assertGreaterThan( 0, $id ); // Fetch the post and make sure it matches. $out = get_post( $id ); @@ -259,7 +259,7 @@ class Tests_Post extends WP_UnitTestCase { $this->post_ids[] = $id; // dmp( _get_cron_array() ); $this->assertIsNumeric( $id ); - $this->assertTrue( $id > 0 ); + $this->assertGreaterThan( 0, $id ); // Fetch the post and make sure it matches. $out = get_post( $id ); @@ -380,7 +380,7 @@ class Tests_Post extends WP_UnitTestCase { $this->post_ids[] = $id; // dmp( _get_cron_array() ); $this->assertIsNumeric( $id ); - $this->assertTrue( $id > 0 ); + $this->assertGreaterThan( 0, $id ); // Fetch the post and make sure it matches. $out = get_post( $id ); @@ -793,7 +793,8 @@ class Tests_Post extends WP_UnitTestCase { ), ); $insert_post_id = wp_insert_post( $post_data, true, true ); - $this->assertTrue( ( is_int( $insert_post_id ) && $insert_post_id > 0 ) ); + $this->assertIsInt( $insert_post_id ); + $this->assertGreaterThan( 0, $insert_post_id ); $post = get_post( $insert_post_id ); $this->assertEquals( $post->post_author, self::$editor_id ); diff --git a/tests/phpunit/tests/rest-api/rest-controller.php b/tests/phpunit/tests/rest-api/rest-controller.php index 5347ca15b7..eee484aa72 100644 --- a/tests/phpunit/tests/rest-api/rest-controller.php +++ b/tests/phpunit/tests/rest-api/rest-controller.php @@ -513,7 +513,7 @@ class WP_Test_REST_Controller extends WP_Test_REST_TestCase { $first_call_count = $listener->get_call_count( $method ); - $this->assertTrue( $first_call_count > 0 ); + $this->assertGreaterThan( 0, $first_call_count ); $request->set_param( '_fields', 'somestring' ); @@ -525,7 +525,7 @@ class WP_Test_REST_Controller extends WP_Test_REST_TestCase { $controller->prepare_item_for_response( $item, $request ); - $this->assertTrue( $listener->get_call_count( $method ) > $first_call_count ); + $this->assertGreaterThan( $first_call_count, $listener->get_call_count( $method ) ); } /** diff --git a/tests/phpunit/tests/term.php b/tests/phpunit/tests/term.php index 98adeb8f92..d18b4ef1ff 100644 --- a/tests/phpunit/tests/term.php +++ b/tests/phpunit/tests/term.php @@ -155,12 +155,12 @@ class Tests_Term extends WP_UnitTestCase { $t = wp_insert_category( array( 'cat_name' => $term ) ); $this->assertIsNumeric( $t ); $this->assertNotWPError( $t ); - $this->assertTrue( $t > 0 ); + $this->assertGreaterThan( 0, $t ); $this->assertEquals( $initial_count + 1, wp_count_terms( array( 'taxonomy' => 'category' ) ) ); // Make sure the term exists. - $this->assertTrue( term_exists( $term ) > 0 ); - $this->assertTrue( term_exists( $t ) > 0 ); + $this->assertGreaterThan( 0, term_exists( $term ) ); + $this->assertGreaterThan( 0, term_exists( $t ) ); // Now delete it. $this->assertTrue( wp_delete_category( $t ) ); diff --git a/tests/phpunit/tests/term/wpInsertTerm.php b/tests/phpunit/tests/term/wpInsertTerm.php index 1627238773..9d7f32c5af 100644 --- a/tests/phpunit/tests/term/wpInsertTerm.php +++ b/tests/phpunit/tests/term/wpInsertTerm.php @@ -29,13 +29,13 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { $t = wp_insert_term( $term, $taxonomy ); $this->assertIsArray( $t ); $this->assertNotWPError( $t ); - $this->assertTrue( $t['term_id'] > 0 ); - $this->assertTrue( $t['term_taxonomy_id'] > 0 ); + $this->assertGreaterThan( 0, $t['term_id'] ); + $this->assertGreaterThan( 0, $t['term_taxonomy_id'] ); $this->assertEquals( $initial_count + 1, wp_count_terms( array( 'taxonomy' => $taxonomy ) ) ); // Make sure the term exists. - $this->assertTrue( term_exists( $term ) > 0 ); - $this->assertTrue( term_exists( $t['term_id'] ) > 0 ); + $this->assertGreaterThan( 0, term_exists( $term ) ); + $this->assertGreaterThan( 0, term_exists( $t['term_id'] ) ); // Now delete it. add_filter( 'delete_term', array( $this, 'deleted_term_cb' ), 10, 5 ); diff --git a/tests/phpunit/tests/theme.php b/tests/phpunit/tests/theme.php index ba005f9727..24d44405cd 100644 --- a/tests/phpunit/tests/theme.php +++ b/tests/phpunit/tests/theme.php @@ -140,7 +140,7 @@ class Tests_Theme extends WP_UnitTestCase { // Important attributes should all not be empty as well. $this->assertNotEmpty( $theme['Description'] ); $this->assertNotEmpty( $theme['Author'] ); - $this->assertTrue( version_compare( $theme['Version'], 0 ) > 0 ); + $this->assertGreaterThan( 0, version_compare( $theme['Version'], 0 ) ); $this->assertNotEmpty( $theme['Template'] ); $this->assertNotEmpty( $theme['Stylesheet'] ); diff --git a/tests/phpunit/tests/user/wpDeleteUser.php b/tests/phpunit/tests/user/wpDeleteUser.php index 6c8aa8b6ce..1ecfbf25ea 100644 --- a/tests/phpunit/tests/user/wpDeleteUser.php +++ b/tests/phpunit/tests/user/wpDeleteUser.php @@ -68,7 +68,7 @@ class Tests_User_WpDeleteUser extends WP_UnitTestCase { // Insert a post and make sure the ID is OK. $post_id = wp_insert_post( $post ); $this->assertIsNumeric( $post_id ); - $this->assertTrue( $post_id > 0 ); + $this->assertGreaterThan( 0, $post_id ); $post = get_post( $post_id ); $this->assertSame( $post_id, $post->ID ); @@ -84,7 +84,7 @@ class Tests_User_WpDeleteUser extends WP_UnitTestCase { // Insert a post and make sure the ID is OK. $nav_id = wp_insert_post( $post ); $this->assertIsNumeric( $nav_id ); - $this->assertTrue( $nav_id > 0 ); + $this->assertGreaterThan( 0, $nav_id ); $post = get_post( $nav_id ); $this->assertSame( $nav_id, $post->ID );