diff --git a/tests/phpunit/tests/http/base.php b/tests/phpunit/tests/http/base.php index 14a58c4a0c..c95fac303e 100644 --- a/tests/phpunit/tests/http/base.php +++ b/tests/phpunit/tests/http/base.php @@ -52,14 +52,14 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { function test_redirect_on_301() { // 5 : 5 & 301 $res = wp_remote_request($this->redirection_script . '?code=301&rt=' . 5, array('redirection' => 5) ); - $this->assertFalse( is_wp_error($res) ); + $this->assertNotWPError( $res ); $this->assertEquals(200, (int)$res['response']['code'] ); } function test_redirect_on_302() { // 5 : 5 & 302 $res = wp_remote_request($this->redirection_script . '?code=302&rt=' . 5, array('redirection' => 5) ); - $this->assertFalse( is_wp_error($res) ); + $this->assertNotWPError( $res ); $this->assertEquals(200, (int)$res['response']['code'] ); } @@ -69,7 +69,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { function test_redirect_on_301_no_redirect() { // 5 > 0 & 301 $res = wp_remote_request($this->redirection_script . '?code=301&rt=' . 5, array('redirection' => 0) ); - $this->assertFalse( is_wp_error($res) ); + $this->assertNotWPError( $res ); $this->assertEquals(301, (int)$res['response']['code'] ); } @@ -79,21 +79,21 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { function test_redirect_on_302_no_redirect() { // 5 > 0 & 302 $res = wp_remote_request($this->redirection_script . '?code=302&rt=' . 5, array('redirection' => 0) ); - $this->assertFalse( is_wp_error($res) ); + $this->assertNotWPError( $res ); $this->assertEquals(302, (int)$res['response']['code'] ); } function test_redirections_equal() { // 5 - 5 $res = wp_remote_request($this->redirection_script . '?rt=' . 5, array('redirection' => 5) ); - $this->assertFalse( is_wp_error($res) ); + $this->assertNotWPError( $res ); $this->assertEquals(200, (int)$res['response']['code'] ); } function test_no_head_redirections() { // No redirections on HEAD request: $res = wp_remote_request($this->redirection_script . '?code=302&rt=' . 1, array('method' => 'HEAD') ); - $this->assertFalse( is_wp_error($res) ); + $this->assertNotWPError( $res ); $this->assertEquals( 302, (int)$res['response']['code'] ); } @@ -103,7 +103,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { function test_redirect_on_head() { // Redirections on HEAD request when Requested $res = wp_remote_request($this->redirection_script . '?rt=' . 5, array('redirection' => 5, 'method' => 'HEAD') ); - $this->assertFalse( is_wp_error($res) ); + $this->assertNotWPError( $res ); $this->assertEquals( 200, (int)$res['response']['code'] ); } @@ -122,7 +122,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { function test_redirections_less_edgecase() { // 4 < 5 (close edgecase) $res = wp_remote_request($this->redirection_script . '?rt=' . 4, array('redirection' => 5) ); - $this->assertFalse( is_wp_error($res) ); + $this->assertNotWPError( $res ); } /** @@ -131,7 +131,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { function test_redirections_zero_redirections_specified() { // 0 redirections asked for, Should return the document? $res = wp_remote_request($this->redirection_script . '?code=302&rt=' . 5, array('redirection' => 0) ); - $this->assertFalse( is_wp_error($res) ); + $this->assertNotWPError( $res ); $this->assertEquals( 302, (int)$res['response']['code'] ); } @@ -143,7 +143,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { function test_location_header_on_201() { // Prints PASS on initial load, FAIL if the client follows the specified redirection $res = wp_remote_request( $this->redirection_script . '?201-location=true' ); - $this->assertFalse( is_wp_error( $res ) ); + $this->assertNotWPError( $res ); $this->assertEquals( 'PASS', $res['body']); } @@ -169,7 +169,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { $headers = array('test1' => 'test', 'test2' => 0, 'test3' => ''); $res = wp_remote_request( $this->redirection_script . '?header-check', array('headers' => $headers) ); - $this->assertFalse( is_wp_error($res) ); + $this->assertNotWPError( $res ); $headers = array(); foreach ( explode("\n", $res['body']) as $key => $value ) { @@ -198,7 +198,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { unlink( $res['filename'] ); } - $this->assertFalse( is_wp_error( $res ) ); + $this->assertNotWPError( $res ); $this->assertEquals( '', $res['body'] ); // The body should be empty. $this->assertEquals( $size, $res['headers']['content-length'] ); // Check the headers are returned (and the size is the same..) $this->assertEquals( $size, $filesize ); // Check that the file is written to disk correctly without any extra characters @@ -219,7 +219,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { unlink( $res['filename'] ); } - $this->assertFalse( is_wp_error( $res ) ); + $this->assertNotWPError( $res ); $this->assertEquals( $size, $filesize ); // Check that the file is written to disk correctly without any extra characters } @@ -235,7 +235,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { $res = wp_remote_request( $url, array( 'timeout' => 30, 'limit_response_size' => $size ) ); - $this->assertFalse( is_wp_error( $res ) ); + $this->assertNotWPError( $res ); $this->assertEquals( $size, strlen( $res['body'] ) ); } diff --git a/tests/phpunit/tests/term.php b/tests/phpunit/tests/term.php index 024179b73d..0713e29219 100644 --- a/tests/phpunit/tests/term.php +++ b/tests/phpunit/tests/term.php @@ -411,7 +411,7 @@ class Tests_Term extends WP_UnitTestCase { $t = wp_insert_category( array( 'cat_name' => $term ) ); $this->assertTrue( is_numeric($t) ); - $this->assertFalse( is_wp_error($t) ); + $this->assertNotWPError( $t ); $this->assertTrue( $t > 0 ); $this->assertEquals( $initial_count + 1, wp_count_terms( 'category' ) ); diff --git a/tests/phpunit/tests/term/wpInsertTerm.php b/tests/phpunit/tests/term/wpInsertTerm.php index 3cac325d0e..0a63d26976 100644 --- a/tests/phpunit/tests/term/wpInsertTerm.php +++ b/tests/phpunit/tests/term/wpInsertTerm.php @@ -27,7 +27,7 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { $t = wp_insert_term( $term, $taxonomy ); $this->assertInternalType( 'array', $t ); - $this->assertFalse( is_wp_error($t) ); + $this->assertNotWPError( $t ); $this->assertTrue( $t['term_id'] > 0 ); $this->assertTrue( $t['term_taxonomy_id'] > 0 ); $this->assertEquals( $initial_count + 1, wp_count_terms( $taxonomy ) ); @@ -161,12 +161,12 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { */ public function test_wp_insert_term_duplicate_name() { $term = $this->factory->tag->create_and_get( array( 'name' => 'Bozo' ) ); - $this->assertFalse( is_wp_error( $term ) ); + $this->assertNotWPError( $term ); $this->assertTrue( empty( $term->errors ) ); // Test existing term name with unique slug $term1 = $this->factory->tag->create( array( 'name' => 'Bozo', 'slug' => 'bozo1' ) ); - $this->assertFalse( is_wp_error( $term1 ) ); + $this->assertNotWPError( $term1 ); // Test an existing term name $term2 = $this->factory->tag->create( array( 'name' => 'Bozo' ) ); @@ -200,21 +200,21 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { $this->assertCount( 4, array_unique( wp_list_pluck( $terms, 'slug' ) ) ); $term13 = $this->factory->tag->create( array( 'name' => 'A' ) ); - $this->assertFalse( is_wp_error( $term13 ) ); + $this->assertNotWPError( $term13 ); $term14 = $this->factory->tag->create( array( 'name' => 'A' ) ); $this->assertTrue( is_wp_error( $term14 ) ); $term15 = $this->factory->tag->create( array( 'name' => 'A+', 'slug' => 'a' ) ); - $this->assertFalse( is_wp_error( $term15 ) ); + $this->assertNotWPError( $term15 ); $term16 = $this->factory->tag->create( array( 'name' => 'A+' ) ); $this->assertTrue( is_wp_error( $term16 ) ); $term17 = $this->factory->tag->create( array( 'name' => 'A++' ) ); - $this->assertFalse( is_wp_error( $term17 ) ); + $this->assertNotWPError( $term17 ); $term18 = $this->factory->tag->create( array( 'name' => 'A-', 'slug' => 'a' ) ); - $this->assertFalse( is_wp_error( $term18 ) ); + $this->assertNotWPError( $term18 ); $term19 = $this->factory->tag->create( array( 'name' => 'A-' ) ); $this->assertTrue( is_wp_error( $term19 ) ); $term20 = $this->factory->tag->create( array( 'name' => 'A--' ) ); - $this->assertFalse( is_wp_error( $term20 ) ); + $this->assertNotWPError( $term20 ); } /** @@ -276,7 +276,7 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 'slug' => 'foo-unique', ) ); - $this->assertFalse( is_wp_error( $t2 ) ); + $this->assertNotWPError( $t2 ); $t2_term = get_term( $t2['term_id'], 'wptests_tax' ); $this->assertSame( 'foo-unique', $t2_term->slug ); @@ -368,7 +368,7 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 'slug' => 'bar', ) ); - $this->assertFalse( is_wp_error( $t4 ) ); + $this->assertNotWPError( $t4 ); $t4_term = get_term( $t4['term_id'], 'wptests_tax' ); // `wp_unique_term_slug()` allows term creation but iterates the slug. @@ -391,7 +391,7 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 'slug' => 'foo-unique', ) ); - $this->assertFalse( is_wp_error( $t2 ) ); + $this->assertNotWPError( $t2 ); $t2_term = get_term( $t2['term_id'], 'wptests_tax' ); $this->assertSame( 'foo-unique', $t2_term->slug ); @@ -455,7 +455,7 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 'slug' => 'foo', ) ); - $this->assertFalse( is_wp_error( $created ) ); + $this->assertNotWPError( $created ); $new_term = get_term( $created['term_id'], 'wptests_tax_2' ); @@ -486,7 +486,7 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 'slug' => 'foo', ) ); - $this->assertFalse( is_wp_error( $created ) ); + $this->assertNotWPError( $created ); $new_term = get_term( $created['term_id'], 'wptests_tax_2' ); diff --git a/tests/phpunit/tests/term/wpUpdateTerm.php b/tests/phpunit/tests/term/wpUpdateTerm.php index 47ec5692c4..71495d7175 100644 --- a/tests/phpunit/tests/term/wpUpdateTerm.php +++ b/tests/phpunit/tests/term/wpUpdateTerm.php @@ -188,7 +188,7 @@ class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 'slug' => 'foo', ) ); - $this->assertFalse( is_wp_error( $updated ) ); + $this->assertNotWPError( $updated ); $t1_term = get_term( $t1, 'wptests_tax' ); $t2_term = get_term( $t2, 'wptests_tax_2' ); @@ -218,7 +218,7 @@ class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 'name' => 'Foo', ) ); - $this->assertFalse( is_wp_error( $updated ) ); + $this->assertNotWPError( $updated ); $t2_term = get_term( $t2, 'wptests_tax_2' ); $this->assertSame( 'Foo', $t2_term->name ); @@ -256,7 +256,7 @@ class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 'name' => 'Bar', ) ); - $this->assertFalse( is_wp_error( $updated ) ); + $this->assertNotWPError( $updated ); $t3_term = get_term( $t3, 'wptests_tax' ); $this->assertSame( 'Bar', $t3_term->name );