From cc5e3f78110a48d3d6d3bab02fc93d2b6abe0008 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 15 Jul 2021 09:06:20 +0000 Subject: [PATCH] Tests: Use more appropriate assertions in various tests. This replaces instances of `assertTrue( is_a( ... ) )` with `assertInstanceOf()` to use native PHPUnit functionality. Follow-up to [51335], [51337], [51367], [51397], [51403], [51404]. See #53363. git-svn-id: https://develop.svn.wordpress.org/trunk@51436 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/filesystem/base.php | 2 +- tests/phpunit/tests/post/query.php | 2 +- tests/phpunit/tests/sitemaps/functions.php | 2 +- tests/phpunit/tests/taxonomy.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/tests/filesystem/base.php b/tests/phpunit/tests/filesystem/base.php index f186cbb961..54fcb3e1e9 100644 --- a/tests/phpunit/tests/filesystem/base.php +++ b/tests/phpunit/tests/filesystem/base.php @@ -29,7 +29,7 @@ abstract class WP_Filesystem_UnitTestCase extends WP_UnitTestCase { function test_is_MockFS_sane() { global $wp_filesystem; - $this->assertTrue( is_a( $wp_filesystem, 'WP_Filesystem_MockFS' ) ); + $this->assertInstanceOf( 'WP_Filesystem_MockFS', $wp_filesystem ); $wp_filesystem->init( '/' ); diff --git a/tests/phpunit/tests/post/query.php b/tests/phpunit/tests/post/query.php index 686f77a293..6ccf69f534 100644 --- a/tests/phpunit/tests/post/query.php +++ b/tests/phpunit/tests/post/query.php @@ -102,7 +102,7 @@ class Tests_Post_Query extends WP_UnitTestCase { foreach ( $query->posts as $post ) { // Posts are WP_Post objects. - $this->assertTrue( is_a( $post, 'WP_Post' ) ); + $this->assertInstanceOf( 'WP_Post', $post ); // Filters are raw. $this->assertSame( 'raw', $post->filter ); diff --git a/tests/phpunit/tests/sitemaps/functions.php b/tests/phpunit/tests/sitemaps/functions.php index aa4c63cc41..a4913fae5f 100644 --- a/tests/phpunit/tests/sitemaps/functions.php +++ b/tests/phpunit/tests/sitemaps/functions.php @@ -55,7 +55,7 @@ class Test_Sitemaps_Functions extends WP_UnitTestCase { $this->assertSame( array_keys( $expected ), array_keys( $sitemaps ), 'Unable to confirm default sitemap types are registered.' ); foreach ( $expected as $name => $provider ) { - $this->assertTrue( is_a( $sitemaps[ $name ], $provider ), "Default $name sitemap is not a $provider object." ); + $this->assertInstanceOf( $provider, $sitemaps[ $name ], "Default $name sitemap is not a $provider object." ); } } diff --git a/tests/phpunit/tests/taxonomy.php b/tests/phpunit/tests/taxonomy.php index 8e256f8928..241cc26a98 100644 --- a/tests/phpunit/tests/taxonomy.php +++ b/tests/phpunit/tests/taxonomy.php @@ -438,7 +438,7 @@ class Tests_Taxonomy extends WP_UnitTestCase { 'taxonomy' => 'force_error', 'cat_name' => 'Error', ); - $this->assertTrue( is_a( wp_insert_category( $cat, true ), 'WP_Error' ) ); + $this->assertInstanceOf( 'WP_Error', wp_insert_category( $cat, true ) ); } function test_insert_category_force_error_no_handle() {