diff --git a/tests/phpunit/tests/general/errors.php b/tests/phpunit/tests/general/errors.php index 7232b368a1..4c262c0eb9 100644 --- a/tests/phpunit/tests/general/errors.php +++ b/tests/phpunit/tests/general/errors.php @@ -9,7 +9,7 @@ class Tests_General_Errors extends WP_UnitTestCase { function test_create_error() { $error = new WP_Error( 'foo', 'message', 'data' ); - $this->assertTrue( is_wp_error( $error ) ); + $this->assertWPError( $error ); $this->assertEquals( 'foo', $error->get_error_code() ); $this->assertEquals( 'message', $error->get_error_message() ); $this->assertEquals( 'data', $error->get_error_data() ); @@ -19,7 +19,7 @@ class Tests_General_Errors extends WP_UnitTestCase { $error = new WP_Error(); $error->add( 'foo', 'message', 'data' ); - $this->assertTrue( is_wp_error( $error ) ); + $this->assertWPError( $error ); $this->assertEquals( 'foo', $error->get_error_code() ); $this->assertEquals( 'message', $error->get_error_message() ); $this->assertEquals( 'data', $error->get_error_data() ); @@ -30,7 +30,7 @@ class Tests_General_Errors extends WP_UnitTestCase { $error->add( 'foo', 'foo message', 'foo data' ); $error->add( 'bar', 'bar message', 'bar data' ); - $this->assertTrue( is_wp_error( $error ) ); + $this->assertWPError( $error ); $this->assertEquals( 'foo', $error->get_error_code() ); $this->assertEquals( 'foo message', $error->get_error_message() ); $this->assertEquals( 'foo data', $error->get_error_data() ); diff --git a/tests/phpunit/tests/http/base.php b/tests/phpunit/tests/http/base.php index d28c0a68e9..a546fb778e 100644 --- a/tests/phpunit/tests/http/base.php +++ b/tests/phpunit/tests/http/base.php @@ -131,13 +131,13 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { function test_redirections_greater() { // 10 > 5 $res = wp_remote_request($this->redirection_script . '?rt=' . 10, array('redirection' => 5) ); - $this->assertTrue( is_wp_error($res), print_r($res, true) ); + $this->assertWPError( $res ); } function test_redirections_greater_edgecase() { // 6 > 5 (close edgecase) $res = wp_remote_request($this->redirection_script . '?rt=' . 6, array('redirection' => 5) ); - $this->assertTrue( is_wp_error($res) ); + $this->assertWPError( $res ); } function test_redirections_less_edgecase() { @@ -387,7 +387,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { $this->markTestSkipped( 'This install of PHP does not support SSL' ); $res = wp_remote_get( 'https://wordpress.org/' ); - $this->assertTrue( ! is_wp_error( $res ), print_r( $res, true ) ); + $this->assertNotWPError( $res ); } /** diff --git a/tests/phpunit/tests/import/parser.php b/tests/phpunit/tests/import/parser.php index e48fbf7dcc..3e2ee20ee2 100644 --- a/tests/phpunit/tests/import/parser.php +++ b/tests/phpunit/tests/import/parser.php @@ -29,7 +29,7 @@ class Tests_Import_Parser extends WP_Import_UnitTestCase { foreach ( array( 'WXR_Parser_SimpleXML', 'WXR_Parser_XML' ) as $p ) { $parser = new $p; $result = $parser->parse($file); - $this->assertTrue( is_wp_error( $result ) ); + $this->assertWPError( $result ); $this->assertEquals( 'There was an error when reading this WXR file', $result->get_error_message() ); } } @@ -42,7 +42,7 @@ class Tests_Import_Parser extends WP_Import_UnitTestCase { foreach ( array( $f1, $f2 ) as $file ) { $parser = new $p; $result = $parser->parse( $file ); - $this->assertTrue( is_wp_error( $result ) ); + $this->assertWPError( $result ); $this->assertEquals( 'This does not appear to be a WXR file, missing/invalid WXR version number', $result->get_error_message() ); } } diff --git a/tests/phpunit/tests/post.php b/tests/phpunit/tests/post.php index 3f5eeff3d1..6bb5aef83b 100644 --- a/tests/phpunit/tests/post.php +++ b/tests/phpunit/tests/post.php @@ -381,7 +381,7 @@ class Tests_Post extends WP_UnitTestCase { // Test both return paths with or without WP_Error $insert_post = wp_insert_post( $post, true ); - $this->assertTrue( is_wp_error( $insert_post ), 'Did not get a WP_Error back from wp_insert_post' ); + $this->assertWPError( $insert_post ); $this->assertEquals( 'invalid_date', $insert_post->get_error_code() ); $insert_post = wp_insert_post( $post ); diff --git a/tests/phpunit/tests/term/getTheTerms.php b/tests/phpunit/tests/term/getTheTerms.php index 9c2cf2d6e4..6a3d4ba5c1 100644 --- a/tests/phpunit/tests/term/getTheTerms.php +++ b/tests/phpunit/tests/term/getTheTerms.php @@ -143,7 +143,7 @@ class Tests_Term_GetTheTerms extends WP_UnitTestCase { function test_get_the_terms_should_return_wp_error_when_taxonomy_is_unregistered() { $p = self::$post_ids[0]; $terms = get_the_terms( $p, 'this-taxonomy-does-not-exist' ); - $this->assertTrue( is_wp_error( $terms ) ); + $this->assertWPError( $terms ); } /** diff --git a/tests/phpunit/tests/term/taxQuery.php b/tests/phpunit/tests/term/taxQuery.php index 85ea44d1c2..179d25123d 100644 --- a/tests/phpunit/tests/term/taxQuery.php +++ b/tests/phpunit/tests/term/taxQuery.php @@ -231,7 +231,7 @@ class Tests_Term_Tax_Query extends WP_UnitTestCase { ) ); $tq->transform_query( $tq->queries[0], 'term_taxonomy_id' ); - $this->assertTrue( is_wp_error( $tq->queries[0] ) ); + $this->assertWPError( $tq->queries[0] ); } /** diff --git a/tests/phpunit/tests/term/wpInsertTerm.php b/tests/phpunit/tests/term/wpInsertTerm.php index fd219f5e70..6ec7ee9864 100644 --- a/tests/phpunit/tests/term/wpInsertTerm.php +++ b/tests/phpunit/tests/term/wpInsertTerm.php @@ -48,7 +48,7 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { public function test_wp_insert_term_taxonomy_does_not_exist() { $found = wp_insert_term( 'foo', 'bar' ); - $this->assertTrue( is_wp_error( $found ) ); + $this->assertWPError( $found ); $this->assertSame( 'invalid_taxonomy', $found->get_error_code() ); } @@ -57,21 +57,21 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { $found = wp_insert_term( 'foo', 'post_tag' ); remove_filter( 'pre_insert_term', array( $this, '_pre_insert_term_callback' ) ); - $this->assertTrue( is_wp_error( $found ) ); + $this->assertWPError( $found ); $this->assertSame( 'custom_error', $found->get_error_code() ); } public function test_wp_insert_term_term_0() { $found = wp_insert_term( 0, 'post_tag' ); - $this->assertTrue( is_wp_error( $found ) ); + $this->assertWPError( $found ); $this->assertSame( 'invalid_term_id', $found->get_error_code() ); } public function test_wp_insert_term_term_trims_to_empty_string() { $found = wp_insert_term( ' ', 'post_tag' ); - $this->assertTrue( is_wp_error( $found ) ); + $this->assertWPError( $found ); $this->assertSame( 'empty_term_name', $found->get_error_code() ); } @@ -80,7 +80,7 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 'parent' => 999999, ) ); - $this->assertTrue( is_wp_error( $found ) ); + $this->assertWPError( $found ); $this->assertSame( 'missing_parent', $found->get_error_code() ); } @@ -170,7 +170,7 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { // Test an existing term name $term2 = self::factory()->tag->create( array( 'name' => 'Bozo' ) ); - $this->assertTrue( is_wp_error( $term2 ) ); + $this->assertWPError( $term2 ); $this->assertNotEmpty( $term2->errors ); // Test named terms ending in special characters @@ -179,7 +179,7 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { $term5 = self::factory()->tag->create( array( 'name' => 'T$$$' ) ); $term6 = self::factory()->tag->create( array( 'name' => 'T$$$$' ) ); $term7 = self::factory()->tag->create( array( 'name' => 'T$$$$' ) ); - $this->assertTrue( is_wp_error( $term7 ) ); + $this->assertWPError( $term7 ); $this->assertNotEmpty( $term7->errors ); $this->assertEquals( $term6, $term7->error_data['term_exists'] ); @@ -192,7 +192,7 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { $term10 = self::factory()->tag->create( array( 'name' => '$$$' ) ); $term11 = self::factory()->tag->create( array( 'name' => '$$$$' ) ); $term12 = self::factory()->tag->create( array( 'name' => '$$$$' ) ); - $this->assertTrue( is_wp_error( $term12 ) ); + $this->assertWPError( $term12 ); $this->assertNotEmpty( $term12->errors ); $this->assertEquals( $term11, $term12->error_data['term_exists'] ); @@ -202,17 +202,17 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { $term13 = self::factory()->tag->create( array( 'name' => 'A' ) ); $this->assertNotWPError( $term13 ); $term14 = self::factory()->tag->create( array( 'name' => 'A' ) ); - $this->assertTrue( is_wp_error( $term14 ) ); + $this->assertWPError( $term14 ); $term15 = self::factory()->tag->create( array( 'name' => 'A+', 'slug' => 'a' ) ); $this->assertNotWPError( $term15 ); $term16 = self::factory()->tag->create( array( 'name' => 'A+' ) ); - $this->assertTrue( is_wp_error( $term16 ) ); + $this->assertWPError( $term16 ); $term17 = self::factory()->tag->create( array( 'name' => 'A++' ) ); $this->assertNotWPError( $term17 ); $term18 = self::factory()->tag->create( array( 'name' => 'A-', 'slug' => 'a' ) ); $this->assertNotWPError( $term18 ); $term19 = self::factory()->tag->create( array( 'name' => 'A-' ) ); - $this->assertTrue( is_wp_error( $term19 ) ); + $this->assertWPError( $term19 ); $term20 = self::factory()->tag->create( array( 'name' => 'A--' ) ); $this->assertNotWPError( $term20 ); } diff --git a/tests/phpunit/tests/term/wpSetObjectTerms.php b/tests/phpunit/tests/term/wpSetObjectTerms.php index 6f126b3041..1069a8bde6 100644 --- a/tests/phpunit/tests/term/wpSetObjectTerms.php +++ b/tests/phpunit/tests/term/wpSetObjectTerms.php @@ -165,7 +165,7 @@ class Tests_Term_WpSetObjectTerms extends WP_UnitTestCase { function test_set_object_terms_invalid() { // bogus taxonomy $result = wp_set_object_terms( self::$post_ids[0], array(rand_str()), rand_str() ); - $this->assertTrue( is_wp_error($result) ); + $this->assertWPError( $result ); } public function test_wp_set_object_terms_append_true() { diff --git a/tests/phpunit/tests/term/wpUpdateTerm.php b/tests/phpunit/tests/term/wpUpdateTerm.php index b4c88a71d9..0ab76b8d13 100644 --- a/tests/phpunit/tests/term/wpUpdateTerm.php +++ b/tests/phpunit/tests/term/wpUpdateTerm.php @@ -7,14 +7,14 @@ class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { public function test_wp_update_term_taxonomy_does_not_exist() { $found = wp_update_term( 1, 'bar' ); - $this->assertTrue( is_wp_error( $found ) ); + $this->assertWPError( $found ); $this->assertSame( 'invalid_taxonomy', $found->get_error_code() ); } public function test_wp_update_term_term_empty_string_should_return_wp_error() { $found = wp_update_term( '', 'post_tag' ); - $this->assertTrue( is_wp_error( $found ) ); + $this->assertWPError( $found ); $this->assertSame( 'invalid_term', $found->get_error_code() ); } @@ -60,7 +60,7 @@ class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 'name' => '', ) ); - $this->assertTrue( is_wp_error( $found ) ); + $this->assertWPError( $found ); $this->assertSame( 'empty_term_name', $found->get_error_code() ); _unregister_taxonomy( 'wptests_tax' ); } diff --git a/tests/phpunit/tests/xmlrpc/wp/editProfile.php b/tests/phpunit/tests/xmlrpc/wp/editProfile.php index b096157d1b..525f6a5652 100644 --- a/tests/phpunit/tests/xmlrpc/wp/editProfile.php +++ b/tests/phpunit/tests/xmlrpc/wp/editProfile.php @@ -51,7 +51,7 @@ class Tests_XMLRPC_wp_editProfile extends WP_XMLRPC_UnitTestCase { $auth_old = wp_authenticate( 'author', 'author' ); $auth_new = wp_authenticate( 'author', $new_pass ); $this->assertInstanceOf( 'WP_User', $auth_old ); - $this->assertTrue( is_wp_error( $auth_new ) ); + $this->assertWPError( $auth_new ); } function test_ignore_email_change() {