diff --git a/tests/phpunit/tests/actions.php b/tests/phpunit/tests/actions.php index 2f2848100f..a511890bb7 100644 --- a/tests/phpunit/tests/actions.php +++ b/tests/phpunit/tests/actions.php @@ -279,7 +279,7 @@ class Tests_Actions extends WP_UnitTestCase { $this->assertSame( $args[0][0], $obj ); // Just in case we don't trust assertSame(). $obj->foo = true; - $this->assertFalse( empty( $args[0][0]->foo ) ); + $this->assertNotEmpty( $args[0][0]->foo ); } /** diff --git a/tests/phpunit/tests/filters.php b/tests/phpunit/tests/filters.php index d3c4d0aff9..aa8a611e1b 100644 --- a/tests/phpunit/tests/filters.php +++ b/tests/phpunit/tests/filters.php @@ -231,7 +231,7 @@ class Tests_Filters extends WP_UnitTestCase { $this->assertSame( $args[0][0], $obj ); // Just in case we don't trust assertSame(). $obj->foo = true; - $this->assertFalse( empty( $args[0][0]->foo ) ); + $this->assertNotEmpty( $args[0][0]->foo ); } /** @@ -254,13 +254,13 @@ class Tests_Filters extends WP_UnitTestCase { $this->assertSame( $args[0][1], $obj ); // Just in case we don't trust assertSame(). $obj->foo = true; - $this->assertFalse( empty( $args[0][1]->foo ) ); + $this->assertNotEmpty( $args[0][1]->foo ); $args = $b->get_args(); $this->assertSame( $args[0][1], $obj ); // Just in case we don't trust assertSame(). $obj->foo = true; - $this->assertFalse( empty( $args[0][1]->foo ) ); + $this->assertNotEmpty( $args[0][1]->foo ); } diff --git a/tests/phpunit/tests/http/base.php b/tests/phpunit/tests/http/base.php index 8dd002f830..c192065dbf 100644 --- a/tests/phpunit/tests/http/base.php +++ b/tests/phpunit/tests/http/base.php @@ -225,7 +225,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { $this->skipTestOnTimeout( $res ); $this->assertSame( 'PASS', wp_remote_retrieve_body( $res ) ); - $this->assertTrue( ! empty( $res['headers']['location'] ) ); + $this->assertNotEmpty( $res['headers']['location'] ); } /** diff --git a/tests/phpunit/tests/import/base.php b/tests/phpunit/tests/import/base.php index 7d52aee69b..db83296c0a 100644 --- a/tests/phpunit/tests/import/base.php +++ b/tests/phpunit/tests/import/base.php @@ -24,7 +24,7 @@ abstract class WP_Import_UnitTestCase extends WP_UnitTestCase { $importer = new WP_Import(); $file = realpath( $filename ); - $this->assertTrue( ! empty( $file ), 'Path to import file is empty.' ); + $this->assertNotEmpty( $file, 'Path to import file is empty.' ); $this->assertTrue( is_file( $file ), 'Import file is not a file.' ); $authors = array(); diff --git a/tests/phpunit/tests/post/attachments.php b/tests/phpunit/tests/post/attachments.php index 0a03d77ed6..63b5e6684c 100644 --- a/tests/phpunit/tests/post/attachments.php +++ b/tests/phpunit/tests/post/attachments.php @@ -18,7 +18,7 @@ class Tests_Post_Attachments extends WP_UnitTestCase { $contents = rand_str(); $upload = wp_upload_bits( $filename, null, $contents ); - $this->assertTrue( empty( $upload['error'] ) ); + $this->assertEmpty( $upload['error'] ); } function test_insert_image_no_thumb() { @@ -28,7 +28,7 @@ class Tests_Post_Attachments extends WP_UnitTestCase { $contents = file_get_contents( $filename ); $upload = wp_upload_bits( wp_basename( $filename ), null, $contents ); - $this->assertTrue( empty( $upload['error'] ) ); + $this->assertEmpty( $upload['error'] ); $id = $this->_make_attachment( $upload ); @@ -65,7 +65,7 @@ class Tests_Post_Attachments extends WP_UnitTestCase { $contents = file_get_contents( $filename ); $upload = wp_upload_bits( wp_basename( $filename ), null, $contents ); - $this->assertTrue( empty( $upload['error'] ) ); + $this->assertEmpty( $upload['error'] ); $id = $this->_make_attachment( $upload ); @@ -119,7 +119,7 @@ class Tests_Post_Attachments extends WP_UnitTestCase { $contents = file_get_contents( $filename ); $upload = wp_upload_bits( wp_basename( $filename ), null, $contents ); - $this->assertTrue( empty( $upload['error'] ) ); + $this->assertEmpty( $upload['error'] ); $id = $this->_make_attachment( $upload ); $uploads = wp_upload_dir(); @@ -176,7 +176,7 @@ class Tests_Post_Attachments extends WP_UnitTestCase { $contents = file_get_contents( $filename ); $upload = wp_upload_bits( wp_basename( $filename ), null, $contents ); - $this->assertTrue( empty( $upload['error'] ) ); + $this->assertEmpty( $upload['error'] ); $id = $this->_make_attachment( $upload ); $uploads = wp_upload_dir(); @@ -219,13 +219,13 @@ class Tests_Post_Attachments extends WP_UnitTestCase { $contents = file_get_contents( $filename ); $upload = wp_upload_bits( wp_basename( $filename ), null, $contents ); - $this->assertTrue( empty( $upload['error'] ) ); + $this->assertEmpty( $upload['error'] ); $upload['url'] = ''; $id = $this->_make_attachment( $upload ); $guid = get_the_guid( $id ); - $this->assertFalse( empty( $guid ) ); + $this->assertNotEmpty( $guid ); } /** @@ -236,7 +236,7 @@ class Tests_Post_Attachments extends WP_UnitTestCase { $contents = file_get_contents( $filename ); $upload = wp_upload_bits( wp_basename( $filename ), null, $contents ); - $this->assertTrue( empty( $upload['error'] ) ); + $this->assertEmpty( $upload['error'] ); $id = $this->_make_attachment( $upload ); @@ -262,7 +262,7 @@ class Tests_Post_Attachments extends WP_UnitTestCase { $contents = file_get_contents( $filename ); $upload = wp_upload_bits( wp_basename( $filename ), null, $contents ); - $this->assertTrue( empty( $upload['error'] ) ); + $this->assertEmpty( $upload['error'] ); $attachment_id = $this->_make_attachment( $upload ); @@ -294,7 +294,7 @@ class Tests_Post_Attachments extends WP_UnitTestCase { $contents = file_get_contents( $filename ); $upload = wp_upload_bits( wp_basename( $filename ), null, $contents ); - $this->assertTrue( empty( $upload['error'] ) ); + $this->assertEmpty( $upload['error'] ); // Set attachment ID. $attachment_id = $this->_make_attachment( $upload ); @@ -319,7 +319,7 @@ class Tests_Post_Attachments extends WP_UnitTestCase { $contents = file_get_contents( $filename ); $upload = wp_upload_bits( wp_basename( $filename ), null, $contents ); - $this->assertTrue( empty( $upload['error'] ) ); + $this->assertEmpty( $upload['error'] ); // Set attachment ID. $attachment_id = $this->_make_attachment( $upload ); @@ -344,7 +344,7 @@ class Tests_Post_Attachments extends WP_UnitTestCase { $contents = file_get_contents( $filename ); $upload = wp_upload_bits( wp_basename( $filename ), null, $contents ); - $this->assertTrue( empty( $upload['error'] ) ); + $this->assertEmpty( $upload['error'] ); // Set attachment ID. $attachment_id = $this->_make_attachment( $upload ); @@ -372,7 +372,7 @@ class Tests_Post_Attachments extends WP_UnitTestCase { $contents = file_get_contents( $filename ); $upload = wp_upload_bits( wp_basename( $filename ), null, $contents ); - $this->assertTrue( empty( $upload['error'] ) ); + $this->assertEmpty( $upload['error'] ); // Set attachment ID. $attachment_id = $this->_make_attachment( $upload ); @@ -400,7 +400,7 @@ class Tests_Post_Attachments extends WP_UnitTestCase { $contents = file_get_contents( $filename ); $upload = wp_upload_bits( wp_basename( $filename ), null, $contents ); - $this->assertTrue( empty( $upload['error'] ) ); + $this->assertEmpty( $upload['error'] ); // Set attachment ID. $attachment_id = $this->_make_attachment( $upload ); @@ -427,7 +427,7 @@ class Tests_Post_Attachments extends WP_UnitTestCase { $contents = file_get_contents( $filename ); $upload = wp_upload_bits( wp_basename( $filename ), null, $contents ); - $this->assertTrue( empty( $upload['error'] ) ); + $this->assertEmpty( $upload['error'] ); // Set attachment ID. $attachment_id = $this->_make_attachment( $upload ); diff --git a/tests/phpunit/tests/query/setupPostdata.php b/tests/phpunit/tests/query/setupPostdata.php index a3183c3b25..cc8f6b81c1 100644 --- a/tests/phpunit/tests/query/setupPostdata.php +++ b/tests/phpunit/tests/query/setupPostdata.php @@ -317,7 +317,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase { $this->go_to( get_permalink( $post1 ) ); setup_postdata( $post2 ); - $this->assertTrue( empty( $GLOBALS['more'] ) ); + $this->assertEmpty( $GLOBALS['more'] ); } /** @@ -335,7 +335,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase { $this->go_to( get_permalink( $page ) ); setup_postdata( $post ); - $this->assertTrue( empty( $GLOBALS['more'] ) ); + $this->assertEmpty( $GLOBALS['more'] ); } /** @@ -372,7 +372,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase { $q->the_post(); // $more should refer to the current loop. - $this->assertTrue( empty( $GLOBALS['more'] ) ); + $this->assertEmpty( $GLOBALS['more'] ); } } wp_reset_postdata(); diff --git a/tests/phpunit/tests/rest-api/rest-block-renderer-controller.php b/tests/phpunit/tests/rest-api/rest-block-renderer-controller.php index 06cf3a30ad..fb21cfa2a6 100644 --- a/tests/phpunit/tests/rest-api/rest-block-renderer-controller.php +++ b/tests/phpunit/tests/rest-api/rest-block-renderer-controller.php @@ -478,7 +478,7 @@ class REST_Block_Renderer_Controller_Test extends WP_Test_REST_Controller_Testca $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertTrue( empty( $data['rendered'] ) ); + $this->assertEmpty( $data['rendered'] ); // Now test with post ID. $request->set_param( 'post_id', self::$post_id ); diff --git a/tests/phpunit/tests/rest-api/rest-schema-setup.php b/tests/phpunit/tests/rest-api/rest-schema-setup.php index 0bbff275d2..3754705b28 100644 --- a/tests/phpunit/tests/rest-api/rest-schema-setup.php +++ b/tests/phpunit/tests/rest-api/rest-schema-setup.php @@ -73,7 +73,7 @@ class WP_Test_REST_Schema_Initialization extends WP_Test_REST_TestCase { $routes = rest_get_server()->get_routes(); $this->assertIsArray( $routes, '`get_routes` should return an array.' ); - $this->assertTrue( ! empty( $routes ), 'Routes should not be empty.' ); + $this->assertNotEmpty( $routes, 'Routes should not be empty.' ); $routes = array_filter( array_keys( $routes ), array( $this, 'is_builtin_route' ) ); @@ -472,7 +472,7 @@ class WP_Test_REST_Schema_Initialization extends WP_Test_REST_TestCase { $response->get_status(), "HTTP $status from $route[route]: " . json_encode( $data ) ); - $this->assertTrue( ! empty( $data ), $route['name'] . ' route should return data.' ); + $this->assertNotEmpty( $data, $route['name'] . ' route should return data.' ); $fixture = $this->normalize_fixture( $data, $route['name'] ); $mocked_responses .= "\nmockedApiResponse." . $route['name'] . ' = ' diff --git a/tests/phpunit/tests/rest-api/rest-users-controller.php b/tests/phpunit/tests/rest-api/rest-users-controller.php index 5f1d6df4cc..bded32517a 100644 --- a/tests/phpunit/tests/rest-api/rest-users-controller.php +++ b/tests/phpunit/tests/rest-api/rest-users-controller.php @@ -260,7 +260,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $rest_post_types = array_values( get_post_types( array( 'show_in_rest' => true ), 'names' ) ); foreach ( $users as $user ) { - $this->assertTrue( count_user_posts( $user['id'], $rest_post_types ) > 0 ); + $this->assertNotEmpty( count_user_posts( $user['id'], $rest_post_types ) ); // Ensure we don't expose non-public data. $this->assertArrayNotHasKey( 'capabilities', $user ); diff --git a/tests/phpunit/tests/term/wpInsertTerm.php b/tests/phpunit/tests/term/wpInsertTerm.php index 3a7d637d8c..bad84c9ae4 100644 --- a/tests/phpunit/tests/term/wpInsertTerm.php +++ b/tests/phpunit/tests/term/wpInsertTerm.php @@ -187,7 +187,7 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { public function test_wp_insert_term_duplicate_name() { $term = self::factory()->tag->create_and_get( array( 'name' => 'Bozo' ) ); $this->assertNotWPError( $term ); - $this->assertTrue( empty( $term->errors ) ); + $this->assertEmpty( $term->errors ); // Test existing term name with unique slug. $term1 = self::factory()->tag->create( diff --git a/tests/phpunit/tests/theme.php b/tests/phpunit/tests/theme.php index 9e54eebf8c..ba005f9727 100644 --- a/tests/phpunit/tests/theme.php +++ b/tests/phpunit/tests/theme.php @@ -288,7 +288,7 @@ class Tests_Theme extends WP_UnitTestCase { $this->assertTrue( is_dir( $root_fs ) ); $root_uri = get_theme_root_uri(); - $this->assertTrue( ! empty( $root_uri ) ); + $this->assertNotEmpty( $root_uri ); $this->assertSame( $root_fs . '/' . get_stylesheet(), get_stylesheet_directory() ); $this->assertSame( $root_uri . '/' . get_stylesheet(), get_stylesheet_directory_uri() ); diff --git a/tests/phpunit/tests/theme/themeDir.php b/tests/phpunit/tests/theme/themeDir.php index 0880f72964..663503fc1f 100644 --- a/tests/phpunit/tests/theme/themeDir.php +++ b/tests/phpunit/tests/theme/themeDir.php @@ -45,7 +45,7 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase { $theme = get_theme( 'WordPress Default' ); $this->assertSame( $themes['WordPress Default'], $theme ); - $this->assertFalse( empty( $theme ) ); + $this->assertNotEmpty( $theme ); // echo gen_tests_array( 'theme', $theme ); @@ -74,7 +74,7 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase { function test_theme_sandbox() { $theme = get_theme( 'Sandbox' ); - $this->assertFalse( empty( $theme ) ); + $this->assertNotEmpty( $theme ); // echo gen_tests_array( 'theme', $theme ); @@ -111,7 +111,7 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase { $themes = get_themes(); $theme = $themes['Stylesheet Only']; - $this->assertFalse( empty( $theme ) ); + $this->assertNotEmpty( $theme ); // echo gen_tests_array( 'theme', $theme ); @@ -205,7 +205,7 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase { $themes = get_themes(); $theme = $themes['Page Template Theme']; - $this->assertFalse( empty( $theme ) ); + $this->assertNotEmpty( $theme ); $templates = $theme['Template Files']; $this->assertTrue( in_array( $this->theme_root . '/page-templates/template-top-level.php', $templates, true ) );