From fe9ab38075a647ca0421ca98f2cb98a0faf54823 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 18 May 2021 21:04:31 +0000 Subject: [PATCH] Tests: Use `assertInstanceOf()` instead of `assertTrue()` in some tests. See #52625. git-svn-id: https://develop.svn.wordpress.org/trunk@50926 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/l10n/loadTextdomainJustInTime.php | 2 +- tests/phpunit/tests/term/cache.php | 2 +- tests/phpunit/tests/term/getTerm.php | 2 +- tests/phpunit/tests/term/getTermBy.php | 8 ++++---- tests/phpunit/tests/user/updateUserCaches.php | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/phpunit/tests/l10n/loadTextdomainJustInTime.php b/tests/phpunit/tests/l10n/loadTextdomainJustInTime.php index 814f6562c8..dd380c3d0c 100644 --- a/tests/phpunit/tests/l10n/loadTextdomainJustInTime.php +++ b/tests/phpunit/tests/l10n/loadTextdomainJustInTime.php @@ -110,7 +110,7 @@ class Tests_L10n_LoadTextdomainJustInTime extends WP_UnitTestCase { remove_filter( 'override_load_textdomain', '__return_true' ); remove_filter( 'locale', array( $this, 'filter_set_locale_to_german' ) ); - $this->assertTrue( $translations instanceof NOOP_Translations ); + $this->assertInstanceOf( 'NOOP_Translations', $translations ); } /** diff --git a/tests/phpunit/tests/term/cache.php b/tests/phpunit/tests/term/cache.php index 9847f37460..07bbc5426a 100644 --- a/tests/phpunit/tests/term/cache.php +++ b/tests/phpunit/tests/term/cache.php @@ -433,7 +433,7 @@ class Tests_Term_Cache extends WP_UnitTestCase { $term = get_term_by( 'name', 'Burrito', 'post_tag' ); $num_queries++; - $this->assertTrue( $term instanceof WP_Term ); + $this->assertInstanceOf( 'WP_Term', $term ); $this->assertSame( $term_id, $term->term_id ); $this->assertSame( $num_queries, $wpdb->num_queries ); diff --git a/tests/phpunit/tests/term/getTerm.php b/tests/phpunit/tests/term/getTerm.php index 22ae4d527e..e2760f64a2 100644 --- a/tests/phpunit/tests/term/getTerm.php +++ b/tests/phpunit/tests/term/getTerm.php @@ -135,7 +135,7 @@ class Tests_Term_GetTerm extends WP_UnitTestCase { $found = get_term( $term_data ); - $this->assertTrue( $found instanceof WP_Term ); + $this->assertInstanceOf( 'WP_Term', $found ); $this->assertInternalType( 'int', $found->term_id ); $this->assertInternalType( 'int', $found->term_taxonomy_id ); $this->assertInternalType( 'int', $found->parent ); diff --git a/tests/phpunit/tests/term/getTermBy.php b/tests/phpunit/tests/term/getTermBy.php index 037bef0419..ab49ea92ef 100644 --- a/tests/phpunit/tests/term/getTermBy.php +++ b/tests/phpunit/tests/term/getTermBy.php @@ -125,7 +125,7 @@ class Tests_Term_GetTermBy extends WP_UnitTestCase { $found = get_term_by( 'slug', 'foo', 'wptests_tax' ); $num_queries++; - $this->assertTrue( $found instanceof WP_Term ); + $this->assertInstanceOf( 'WP_Term', $found ); $this->assertSame( $t, $found->term_id ); $this->assertSame( $num_queries, $wpdb->num_queries ); @@ -151,7 +151,7 @@ class Tests_Term_GetTermBy extends WP_UnitTestCase { $found = get_term_by( 'name', $term_name_slashed, 'wptests_tax' ); - $this->assertTrue( $found instanceof WP_Term ); + $this->assertInstanceOf( 'WP_Term', $found ); $this->assertSame( $t, $found->term_id ); $this->assertSame( $term_name, $found->name ); } @@ -171,7 +171,7 @@ class Tests_Term_GetTermBy extends WP_UnitTestCase { // Whitespace should get replaced by a '-'. $found1 = get_term_by( 'slug', 'foo foo', 'wptests_tax' ); - $this->assertTrue( $found1 instanceof WP_Term ); + $this->assertInstanceOf( 'WP_Term', $found1 ); $this->assertSame( $t1, $found1->term_id ); $t2 = self::factory()->term->create( @@ -184,7 +184,7 @@ class Tests_Term_GetTermBy extends WP_UnitTestCase { // Slug should get urlencoded. $found2 = get_term_by( 'slug', '仪表盘', 'wptests_tax' ); - $this->assertTrue( $found2 instanceof WP_Term ); + $this->assertInstanceOf( 'WP_Term', $found2 ); $this->assertSame( $t2, $found2->term_id ); } diff --git a/tests/phpunit/tests/user/updateUserCaches.php b/tests/phpunit/tests/user/updateUserCaches.php index 6797ec229b..1bb298278f 100644 --- a/tests/phpunit/tests/user/updateUserCaches.php +++ b/tests/phpunit/tests/user/updateUserCaches.php @@ -64,7 +64,7 @@ class Tests_User_UpdateUserCaches extends WP_UnitTestCase { update_user_caches( $user_object ); $cached = wp_cache_get( $u, 'users' ); - $this->assertFalse( $cached instanceof WP_User ); + $this->assertNotInstanceOf( 'WP_User', $cached ); $this->assertEquals( $raw_userdata, $cached ); } }