From 620280474fe6ffa2e1c571a21d437dbb812ec1e6 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Wed, 12 Apr 2017 14:58:33 +0000 Subject: [PATCH] Build/Test tools: Introduce and implement `assertNotIXRError()` and `assertIXRError()` assertion methods. This aids in debugging XMLRPC tests which fail, by exposing the `IXR_Error` error message in the assertion failure message. Fixes #40423 git-svn-id: https://develop.svn.wordpress.org/trunk@40417 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/includes/testcase.php | 11 ++++ tests/phpunit/tests/xmlrpc/basic.php | 2 +- .../tests/xmlrpc/mt/getRecentPostTitles.php | 8 +-- tests/phpunit/tests/xmlrpc/mw/editPost.php | 32 ++++++------ tests/phpunit/tests/xmlrpc/mw/getPost.php | 12 ++--- .../tests/xmlrpc/mw/getRecentPosts.php | 12 ++--- tests/phpunit/tests/xmlrpc/mw/newPost.php | 30 +++++------ tests/phpunit/tests/xmlrpc/wp/deletePost.php | 8 +-- tests/phpunit/tests/xmlrpc/wp/deleteTerm.php | 14 ++--- tests/phpunit/tests/xmlrpc/wp/editComment.php | 4 +- tests/phpunit/tests/xmlrpc/wp/editPost.php | 44 ++++++++-------- tests/phpunit/tests/xmlrpc/wp/editProfile.php | 8 +-- tests/phpunit/tests/xmlrpc/wp/editTerm.php | 28 +++++----- tests/phpunit/tests/xmlrpc/wp/getComment.php | 10 ++-- tests/phpunit/tests/xmlrpc/wp/getComments.php | 18 +++---- .../phpunit/tests/xmlrpc/wp/getMediaItem.php | 4 +- tests/phpunit/tests/xmlrpc/wp/getOptions.php | 2 +- tests/phpunit/tests/xmlrpc/wp/getPage.php | 8 +-- tests/phpunit/tests/xmlrpc/wp/getPageList.php | 6 +-- tests/phpunit/tests/xmlrpc/wp/getPages.php | 10 ++-- tests/phpunit/tests/xmlrpc/wp/getPost.php | 12 ++--- tests/phpunit/tests/xmlrpc/wp/getPostType.php | 10 ++-- .../phpunit/tests/xmlrpc/wp/getPostTypes.php | 8 +-- tests/phpunit/tests/xmlrpc/wp/getPosts.php | 24 ++++----- tests/phpunit/tests/xmlrpc/wp/getProfile.php | 8 +-- .../phpunit/tests/xmlrpc/wp/getRevisions.php | 6 +-- .../phpunit/tests/xmlrpc/wp/getTaxonomies.php | 4 +- tests/phpunit/tests/xmlrpc/wp/getTaxonomy.php | 12 ++--- tests/phpunit/tests/xmlrpc/wp/getTerm.php | 14 ++--- tests/phpunit/tests/xmlrpc/wp/getTerms.php | 24 ++++----- tests/phpunit/tests/xmlrpc/wp/getUser.php | 16 +++--- tests/phpunit/tests/xmlrpc/wp/getUsers.php | 14 ++--- tests/phpunit/tests/xmlrpc/wp/newComment.php | 10 ++-- tests/phpunit/tests/xmlrpc/wp/newPost.php | 52 +++++++++---------- tests/phpunit/tests/xmlrpc/wp/newTerm.php | 22 ++++---- .../tests/xmlrpc/wp/restoreRevision.php | 6 +-- tests/phpunit/tests/xmlrpc/wp/uploadFile.php | 2 +- 37 files changed, 263 insertions(+), 252 deletions(-) diff --git a/tests/phpunit/includes/testcase.php b/tests/phpunit/includes/testcase.php index 8e845db704..44a0cb8298 100644 --- a/tests/phpunit/includes/testcase.php +++ b/tests/phpunit/includes/testcase.php @@ -438,6 +438,17 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase { $this->assertNotInstanceOf( 'WP_Error', $actual, $message ); } + function assertIXRError( $actual, $message = '' ) { + $this->assertInstanceOf( 'IXR_Error', $actual, $message ); + } + + function assertNotIXRError( $actual, $message = '' ) { + if ( $actual instanceof IXR_Error && '' === $message ) { + $message = $actual->message; + } + $this->assertNotInstanceOf( 'IXR_Error', $actual, $message ); + } + function assertEqualFields( $object, $fields ) { foreach( $fields as $field_name => $field_value ) { if ( $object->$field_name != $field_value ) { diff --git a/tests/phpunit/tests/xmlrpc/basic.php b/tests/phpunit/tests/xmlrpc/basic.php index bbbcbd7d5d..7818fdb0bf 100644 --- a/tests/phpunit/tests/xmlrpc/basic.php +++ b/tests/phpunit/tests/xmlrpc/basic.php @@ -11,7 +11,7 @@ class Tests_XMLRPC_Basic extends WP_XMLRPC_UnitTestCase { function test_enabled() { $result = $this->myxmlrpcserver->wp_getOptions( array( 1, 'username', 'password' ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); // If disabled, 405 would result. $this->assertEquals( 403, $result->code ); } diff --git a/tests/phpunit/tests/xmlrpc/mt/getRecentPostTitles.php b/tests/phpunit/tests/xmlrpc/mt/getRecentPostTitles.php index 8d9c027f22..7c36f978ef 100644 --- a/tests/phpunit/tests/xmlrpc/mt/getRecentPostTitles.php +++ b/tests/phpunit/tests/xmlrpc/mt/getRecentPostTitles.php @@ -7,7 +7,7 @@ class Tests_XMLRPC_mt_getRecentPostTitles extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->mt_getRecentPostTitles( array( 1, 'username', 'password' ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); } @@ -15,7 +15,7 @@ class Tests_XMLRPC_mt_getRecentPostTitles extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'author' ); $result = $this->myxmlrpcserver->mt_getRecentPostTitles( array( 1, 'author', 'author' ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 500, $result->code ); } @@ -25,7 +25,7 @@ class Tests_XMLRPC_mt_getRecentPostTitles extends WP_XMLRPC_UnitTestCase { self::factory()->post->create( array( 'post_author' => $editor ) ); $result = $this->myxmlrpcserver->mt_getRecentPostTitles( array( 1, 'author', 'author' ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertEquals( 0, count( $result ) ); } @@ -35,7 +35,7 @@ class Tests_XMLRPC_mt_getRecentPostTitles extends WP_XMLRPC_UnitTestCase { self::factory()->post->create(); $results = $this->myxmlrpcserver->mt_getRecentPostTitles( array( 1, 'author', 'author' ) ); - $this->assertNotInstanceOf( 'IXR_Error', $results ); + $this->assertNotIXRError( $results ); foreach( $results as $result ) { $post = get_post( $result['postid'] ); diff --git a/tests/phpunit/tests/xmlrpc/mw/editPost.php b/tests/phpunit/tests/xmlrpc/mw/editPost.php index e265b8898f..39a937d7d5 100644 --- a/tests/phpunit/tests/xmlrpc/mw/editPost.php +++ b/tests/phpunit/tests/xmlrpc/mw/editPost.php @@ -8,7 +8,7 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $post = array(); $result = $this->myxmlrpcserver->mw_editPost( array( 1, 'username', 'password', $post ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); } @@ -20,7 +20,7 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { $new_title = 'Post test (updated)'; $post2 = array( 'title' => $new_title ); $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post2 ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertTrue($result); $out = get_post( $post_id ); @@ -37,7 +37,7 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { $new_title = 'Post test (updated)'; $post2 = array( 'title' => $new_title ); $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'editor', 'editor', $post2 ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertTrue($result); $out = get_post( $post_id ); @@ -55,7 +55,7 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { $new_title = 'Post test (updated)'; $post2 = array( 'title' => $new_title ); $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post2 ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 401, $result->code ); $out = get_post( $post_id ); @@ -72,7 +72,7 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { $post2 = array( 'wp_author_id' => $author_id ); $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'editor', 'editor', $post2 ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertTrue($result); $out = get_post( $post_id ); @@ -88,7 +88,7 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { $post2 = array( 'wp_author_id' => $author_id ); $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post2 ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 401, $result->code ); $out = get_post( $post_id ); @@ -107,7 +107,7 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { $post2 = array( 'wp_author_id' => $editor_id ); $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'editor', 'editor', $post2 ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertTrue($result); $out = get_post( $post_id ); @@ -131,13 +131,13 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { // add post thumbnail to post that does not have one $post2 = array( 'wp_post_thumbnail' => $attachment_id ); $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'author', 'author', $post2 ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) ); // edit the post without supplying a post_thumbnail and check that it didn't change $post3 = array( 'post_content' => 'Updated post' ); $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'author', 'author', $post3 ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) ); // create another attachment @@ -146,13 +146,13 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { // change the post's post_thumbnail $post4 = array( 'wp_post_thumbnail' => $attachment2_id ); $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'author', 'author', $post4 ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertEquals( $attachment2_id, get_post_meta( $post_id, '_thumbnail_id', true ) ); // unset the post's post_thumbnail $post5 = array( 'wp_post_thumbnail' => '' ); $result = $this->myxmlrpcserver->mw_editPost( array($post_id, 'author', 'author', $post5 ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertEquals( '', get_post_meta( $post_id, '_thumbnail_id', true ) ); remove_theme_support( 'post-thumbnails' ); @@ -166,7 +166,7 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { $post2 = array( 'title' => 'New Title', 'post_author' => $contributor_id ); $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post2 ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertTrue($result); $out = get_post( $post_id ); @@ -174,7 +174,7 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { $post3 = array( 'description' => 'New Content', 'post_author' => $contributor_id ); $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post3 ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertTrue($result); $out = get_post( $post_id ); @@ -183,7 +183,7 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { $post4 = array( 'mt_excerpt' => 'New Excerpt', 'post_author' => $contributor_id ); $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post4 ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertTrue($result); $out = get_post( $post_id ); @@ -202,7 +202,7 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { $post_id = wp_insert_post( $post ); $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'editor', 'editor', array( 'sticky' => '1' ) ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertTrue( $result ); } @@ -215,7 +215,7 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { $post2 = array( 'post_type' => 'page' ); $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post2 ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( $result->code, 401 ); } diff --git a/tests/phpunit/tests/xmlrpc/mw/getPost.php b/tests/phpunit/tests/xmlrpc/mw/getPost.php index 0d433d0804..924d6ff897 100644 --- a/tests/phpunit/tests/xmlrpc/mw/getPost.php +++ b/tests/phpunit/tests/xmlrpc/mw/getPost.php @@ -19,7 +19,7 @@ class Tests_XMLRPC_mw_getPost extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->mw_getPost( array( self::$post_id, 'username', 'password' ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); } @@ -27,7 +27,7 @@ class Tests_XMLRPC_mw_getPost extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'subscriber' ); $result = $this->myxmlrpcserver->mw_getPost( array( self::$post_id, 'subscriber', 'subscriber' ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 401, $result->code ); } @@ -36,7 +36,7 @@ class Tests_XMLRPC_mw_getPost extends WP_XMLRPC_UnitTestCase { */ function test_invalid_postid() { $result = $this->myxmlrpcserver->mw_getPost( array( 9999, 'author', 'author' ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 404, $result->code ); } @@ -45,7 +45,7 @@ class Tests_XMLRPC_mw_getPost extends WP_XMLRPC_UnitTestCase { $fields = array( 'post' ); $result = $this->myxmlrpcserver->mw_getPost( array( self::$post_id, 'author', 'author' ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); // Check data types $this->assertInternalType( 'string', $result['userid'] ); @@ -96,7 +96,7 @@ class Tests_XMLRPC_mw_getPost extends WP_XMLRPC_UnitTestCase { $fields = array( 'post' ); $result = $this->myxmlrpcserver->mw_getPost( array( self::$post_id, 'author', 'author' ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertInternalType( 'string', $result['wp_post_thumbnail'] ); $this->assertStringMatchesFormat( '%d', $result['wp_post_thumbnail'] ); @@ -108,7 +108,7 @@ class Tests_XMLRPC_mw_getPost extends WP_XMLRPC_UnitTestCase { function test_date() { $fields = array( 'post' ); $result = $this->myxmlrpcserver->mw_getPost( array( self::$post_id, 'author', 'author' ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertInstanceOf( 'IXR_Date', $result['dateCreated'] ); $this->assertInstanceOf( 'IXR_Date', $result['date_created_gmt'] ); diff --git a/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php b/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php index a3b7cd4074..8ab76274b4 100644 --- a/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php +++ b/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php @@ -20,7 +20,7 @@ class Tests_XMLRPC_mw_getRecentPosts extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->mw_getRecentPosts( array( 1, 'username', 'password' ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); } @@ -31,7 +31,7 @@ class Tests_XMLRPC_mw_getRecentPosts extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'subscriber' ); $result = $this->myxmlrpcserver->mw_getRecentPosts( array( 1, 'subscriber', 'subscriber' ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 401, $result->code ); } @@ -39,7 +39,7 @@ class Tests_XMLRPC_mw_getRecentPosts extends WP_XMLRPC_UnitTestCase { wp_delete_post( self::$post_id, true ); $result = $this->myxmlrpcserver->mw_getRecentPosts( array( 1, 'author', 'author' ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertEquals( 0, count( $result ) ); } @@ -48,7 +48,7 @@ class Tests_XMLRPC_mw_getRecentPosts extends WP_XMLRPC_UnitTestCase { $fields = array( 'post' ); $results = $this->myxmlrpcserver->mw_getRecentPosts( array( 1, 'author', 'author' ) ); - $this->assertNotInstanceOf( 'IXR_Error', $results ); + $this->assertNotIXRError( $results ); foreach( $results as $result ) { $post = get_post( $result['postid'] ); @@ -99,7 +99,7 @@ class Tests_XMLRPC_mw_getRecentPosts extends WP_XMLRPC_UnitTestCase { set_post_thumbnail( self::$post_id, $attachment_id ); $results = $this->myxmlrpcserver->mw_getRecentPosts( array( self::$post_id, 'author', 'author' ) ); - $this->assertNotInstanceOf( 'IXR_Error', $results ); + $this->assertNotIXRError( $results ); foreach( $results as $result ) { $this->assertInternalType( 'string', $result['wp_post_thumbnail'] ); @@ -119,7 +119,7 @@ class Tests_XMLRPC_mw_getRecentPosts extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $results = $this->myxmlrpcserver->mw_getRecentPosts( array( 1, 'editor', 'editor' ) ); - $this->assertNotInstanceOf( 'IXR_Error', $results ); + $this->assertNotIXRError( $results ); foreach( $results as $result ) { $post = get_post( $result['postid'] ); diff --git a/tests/phpunit/tests/xmlrpc/mw/newPost.php b/tests/phpunit/tests/xmlrpc/mw/newPost.php index 01316e62d5..06aaafc77f 100644 --- a/tests/phpunit/tests/xmlrpc/mw/newPost.php +++ b/tests/phpunit/tests/xmlrpc/mw/newPost.php @@ -8,7 +8,7 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $post = array(); $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'username', 'password', $post ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); } @@ -17,7 +17,7 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { $post = array(); $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'subscriber', 'subscriber', $post ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 401, $result->code ); } @@ -26,7 +26,7 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { $post = array(); $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 500, $result->code ); $this->assertEquals( 'Content, title, and excerpt are empty.', $result->message ); } @@ -36,7 +36,7 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { $post = array( 'title' => 'Test' ); $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertStringMatchesFormat( '%d', $result ); } @@ -45,7 +45,7 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { $post = array( 'title' => 'Test', 'ID' => 103948 ); $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertNotEquals( '103948', $result ); } @@ -54,7 +54,7 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { $post = array( 'title' => 'Test', 'post_status' => 'publish' ); $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); } function test_incapable_publish() { @@ -62,7 +62,7 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { $post = array( 'title' => 'Test', 'post_status' => 'publish' ); $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'contributor', 'contributor', $post ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 401, $result->code ); } @@ -72,7 +72,7 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { $post = array( 'title' => 'Test', 'wp_author_id' => $other_author_id ); $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'editor', 'editor', $post ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); } function test_incapable_other_author() { @@ -81,7 +81,7 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { $post = array( 'title' => 'Test', 'wp_author_id' => $other_author_id ); $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'contributor', 'contributor', $post ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 401, $result->code ); } @@ -93,7 +93,7 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { $post = array( 'title' => 'Test', 'wp_author_id' => 99999999 ); $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'editor', 'editor', $post ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 404, $result->code ); } @@ -102,7 +102,7 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { $post = array( 'title' => 'Test' ); $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertStringMatchesFormat( '%d', $result ); $out = get_post( $result ); @@ -121,7 +121,7 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { $post = array( 'title' => 'Post Thumbnail Test', 'wp_post_thumbnail' => $attachment_id ); $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertEquals( $attachment_id, get_post_meta( $result, '_thumbnail_id', true ) ); remove_theme_support( 'post-thumbnails' ); @@ -132,7 +132,7 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { $post = array( 'title' => 'Test', 'post_type' => 'page' ); $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 401, $result->code ); } @@ -141,7 +141,7 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { $post = array( 'title' => 'Test', 'post_type' => 'page' ); $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'editor', 'editor', $post ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertStringMatchesFormat( '%d', $result ); $out = get_post( $result ); @@ -162,7 +162,7 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { 'post_status' => 'draft' ); $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'editor', 'editor', $post ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertStringMatchesFormat( '%d', $result ); $out = get_post( $result ); diff --git a/tests/phpunit/tests/xmlrpc/wp/deletePost.php b/tests/phpunit/tests/xmlrpc/wp/deletePost.php index e7284a7cde..d2a5bc6460 100644 --- a/tests/phpunit/tests/xmlrpc/wp/deletePost.php +++ b/tests/phpunit/tests/xmlrpc/wp/deletePost.php @@ -7,7 +7,7 @@ class Tests_XMLRPC_wp_deletePost extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_deletePost( array( 1, 'username', 'password', 0 ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); } @@ -15,7 +15,7 @@ class Tests_XMLRPC_wp_deletePost extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_deletePost( array( 1, 'editor', 'editor', 340982340 ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 404, $result->code ); } @@ -24,7 +24,7 @@ class Tests_XMLRPC_wp_deletePost extends WP_XMLRPC_UnitTestCase { $post_id = self::factory()->post->create(); $result = $this->myxmlrpcserver->wp_deletePost( array( 1, 'subscriber', 'subscriber', $post_id ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 401, $result->code ); } @@ -33,7 +33,7 @@ class Tests_XMLRPC_wp_deletePost extends WP_XMLRPC_UnitTestCase { $post_id = self::factory()->post->create(); $result = $this->myxmlrpcserver->wp_deletePost( array( 1, 'editor', 'editor', $post_id ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertTrue( $result ); $post = get_post( $post_id ); diff --git a/tests/phpunit/tests/xmlrpc/wp/deleteTerm.php b/tests/phpunit/tests/xmlrpc/wp/deleteTerm.php index ee95c6ae76..94e25c9c3d 100644 --- a/tests/phpunit/tests/xmlrpc/wp/deleteTerm.php +++ b/tests/phpunit/tests/xmlrpc/wp/deleteTerm.php @@ -14,7 +14,7 @@ class Tests_XMLRPC_wp_deleteTerm extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'username', 'password', 'category', 0 ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); } @@ -22,7 +22,7 @@ class Tests_XMLRPC_wp_deleteTerm extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'subscriber' ); $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'subscriber', 'subscriber', '', 0 ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message ); } @@ -31,7 +31,7 @@ class Tests_XMLRPC_wp_deleteTerm extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'subscriber' ); $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'subscriber', 'subscriber', 'not_existing', 0 ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message ); } @@ -40,7 +40,7 @@ class Tests_XMLRPC_wp_deleteTerm extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'subscriber' ); $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'subscriber', 'subscriber', 'category', self::$term_id ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 401, $result->code ); $this->assertEquals( __( 'Sorry, you are not allowed to delete this term.' ), $result->message ); } @@ -49,7 +49,7 @@ class Tests_XMLRPC_wp_deleteTerm extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'editor', 'editor', 'category', '' ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 500, $result->code ); $this->assertEquals( __('Empty Term'), $result->message ); } @@ -58,7 +58,7 @@ class Tests_XMLRPC_wp_deleteTerm extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'editor', 'editor', 'category', 9999 ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 404, $result->code ); $this->assertEquals( __( 'Invalid term ID.' ), $result->message ); } @@ -67,7 +67,7 @@ class Tests_XMLRPC_wp_deleteTerm extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'editor', 'editor', 'category', self::$term_id ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertInternalType( 'boolean', $result ); } } diff --git a/tests/phpunit/tests/xmlrpc/wp/editComment.php b/tests/phpunit/tests/xmlrpc/wp/editComment.php index b43beb6ee0..fcb3bb57f7 100644 --- a/tests/phpunit/tests/xmlrpc/wp/editComment.php +++ b/tests/phpunit/tests/xmlrpc/wp/editComment.php @@ -22,7 +22,7 @@ class Tests_XMLRPC_wp_editComment extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_editComment( array( 1, 'author', 'author', $comment_id, array( 'status' => 'hold' ) ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertTrue( $result ); } @@ -42,7 +42,7 @@ class Tests_XMLRPC_wp_editComment extends WP_XMLRPC_UnitTestCase { ) ); $result = $this->myxmlrpcserver->wp_editComment( array( 1, 'author', 'author', $comment_id, array( 'status' => 'hold' ) ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); $this->assertEquals( __( 'Sorry, you are not allowed to moderate or edit this comment.' ), $result->message ); } diff --git a/tests/phpunit/tests/xmlrpc/wp/editPost.php b/tests/phpunit/tests/xmlrpc/wp/editPost.php index 373d45870a..55f5be99a7 100644 --- a/tests/phpunit/tests/xmlrpc/wp/editPost.php +++ b/tests/phpunit/tests/xmlrpc/wp/editPost.php @@ -7,7 +7,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'username', 'password', 0, array() ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); } @@ -20,7 +20,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { $new_title = 'Post test (updated)'; $post2 = array( 'post_title' => $new_title ); $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'contributor', 'contributor', $post_id, $post2 ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertTrue($result); $out = get_post( $post_id ); @@ -37,7 +37,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { $new_title = 'Post test (updated)'; $post2 = array( 'post_title' => $new_title ); $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $post2 ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertTrue($result); $out = get_post( $post_id ); @@ -55,7 +55,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { $new_title = 'Post test (updated)'; $post2 = array( 'post_title' => $new_title ); $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'contributor', 'contributor', $post_id, $post2 ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 401, $result->code ); $out = get_post( $post_id ); @@ -72,7 +72,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { $post2 = array( 'post_author' => $author_id ); $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $post2 ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertTrue($result); $out = get_post( $post_id ); @@ -88,7 +88,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { $post2 = array( 'post_author' => $author_id ); $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'contributor', 'contributor', $post_id, $post2 ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 401, $result->code ); $out = get_post( $post_id ); @@ -107,7 +107,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { $post2 = array( 'post_author' => $editor_id ); $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $post2 ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertTrue($result); $out = get_post( $post_id ); @@ -131,12 +131,12 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { // add post thumbnail to post that does not have one $post2 = array( 'post_thumbnail' => $attachment_id ); $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'author', 'author', $post_id, $post2 ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) ); // fetch the post to verify that it appears $result = $this->myxmlrpcserver->wp_getPost( array( 1, 'author', 'author', $post_id ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertArrayHasKey( 'post_thumbnail', $result ); $this->assertInternalType( 'array', $result['post_thumbnail'] ); $this->assertEquals( $attachment_id, $result['post_thumbnail']['attachment_id'] ); @@ -144,7 +144,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { // edit the post without supplying a post_thumbnail and check that it didn't change $post3 = array( 'post_content' => 'Updated post' ); $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'author', 'author', $post_id, $post3 ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) ); // create another attachment @@ -153,19 +153,19 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { // change the post's post_thumbnail $post4 = array( 'post_thumbnail' => $attachment2_id ); $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'author', 'author', $post_id, $post4 ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertEquals( $attachment2_id, get_post_meta( $post_id, '_thumbnail_id', true ) ); // unset the post's post_thumbnail $post5 = array( 'post_thumbnail' => '' ); $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'author', 'author', $post_id, $post5 ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertEquals( '', get_post_meta( $post_id, '_thumbnail_id', true ) ); // use invalid ID $post6 = array( 'post_thumbnail' => 398420983409 ); $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'author', 'author', $post_id, $post6 ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 404, $result->code ); remove_theme_support( 'post-thumbnails' ); @@ -191,7 +191,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { ); $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'contributor', 'contributor', $post_id, $post2 ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertTrue($result); $out = get_post( $post_id ); @@ -213,7 +213,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { $post2 = array( 'sticky' => false ); $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $post2 ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertFalse( is_sticky( $post_id ) ); } @@ -225,7 +225,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { $post2 = array( 'post_password' => 'foobar', 'sticky' => false ); $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $post2 ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertFalse( is_sticky( $post_id ) ); } @@ -245,7 +245,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { // Modify the day old post. In this case, we think it was last modified yesterday. $struct = array( 'post_content' => 'First edit', 'if_not_modified_since' => new IXR_Date( $yesterday ) ); $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $struct ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); // Make sure the edit went through. $this->assertEquals( 'First edit', get_post( $post_id )->post_content ); @@ -253,7 +253,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { // Modify it again. We think it was last modified yesterday, but we actually just modified it above. $struct = array( 'post_content' => 'Second edit', 'if_not_modified_since' => new IXR_Date( $yesterday ) ); $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $struct ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 409, $result->code ); // Make sure the edit did not go through. @@ -273,7 +273,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { $struct = array( 'post_content' => 'First edit' ); $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $struct ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); // Make sure that the post status is still inherit $this->assertEquals( 'inherit', get_post( $post_id )->post_status ); @@ -290,7 +290,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { $struct = array( 'post_status' => 'doesnt_exists' ); $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $struct ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); // Make sure that the post status is still inherit $this->assertEquals( 'draft', get_post( $post_id )->post_status ); @@ -309,7 +309,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { $this->assertContains( $term_id, $term_ids ); $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, array( 'ID' => $post_id, 'post_title' => 'Updated' ) ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertEquals( 'Updated', get_post( $post_id )->post_title ); $term_ids = wp_list_pluck( get_the_category( $post_id ), 'term_id' ); @@ -336,7 +336,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { ) ); $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $new_post_content ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertEquals( 'Updated', get_post( $post_id )->post_title ); $term_ids = wp_list_pluck( get_the_category( $post_id ), 'term_id' ); diff --git a/tests/phpunit/tests/xmlrpc/wp/editProfile.php b/tests/phpunit/tests/xmlrpc/wp/editProfile.php index 525f6a5652..6e3ced529a 100644 --- a/tests/phpunit/tests/xmlrpc/wp/editProfile.php +++ b/tests/phpunit/tests/xmlrpc/wp/editProfile.php @@ -8,7 +8,7 @@ class Tests_XMLRPC_wp_editProfile extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_editProfile( array( 1, 'username', 'password', array() ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); } @@ -25,7 +25,7 @@ class Tests_XMLRPC_wp_editProfile extends WP_XMLRPC_UnitTestCase { 'bio' => rand_str(200) ); $result = $this->myxmlrpcserver->wp_editProfile( array( 1, 'subscriber', 'subscriber', $new_data ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertTrue( $result ); // verify that the new values were stored @@ -45,7 +45,7 @@ class Tests_XMLRPC_wp_editProfile extends WP_XMLRPC_UnitTestCase { $new_data = array( 'password' => $new_pass ); $result = $this->myxmlrpcserver->wp_editProfile( array( 1, 'author', 'author', $new_data ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertTrue( $result ); $auth_old = wp_authenticate( 'author', 'author' ); @@ -60,7 +60,7 @@ class Tests_XMLRPC_wp_editProfile extends WP_XMLRPC_UnitTestCase { $new_data = array( 'email' => $new_email ); $result = $this->myxmlrpcserver->wp_editProfile( array( 1, 'editor', 'editor', $new_data ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertTrue( $result ); $user_data = get_userdata( $editor_id ); diff --git a/tests/phpunit/tests/xmlrpc/wp/editTerm.php b/tests/phpunit/tests/xmlrpc/wp/editTerm.php index b3f22d2a24..1e62de9d1f 100644 --- a/tests/phpunit/tests/xmlrpc/wp/editTerm.php +++ b/tests/phpunit/tests/xmlrpc/wp/editTerm.php @@ -22,7 +22,7 @@ class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'username', 'password', 'category', 1 ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); } @@ -30,7 +30,7 @@ class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'subscriber' ); $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'subscriber', 'subscriber', '', array( 'taxonomy' => '' ) ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message ); } @@ -39,7 +39,7 @@ class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'subscriber' ); $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'subscriber', 'subscriber', self::$parent_term, array( 'taxonomy' => 'not_existing' ) ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message ); } @@ -48,7 +48,7 @@ class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'subscriber' ); $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'subscriber', 'subscriber', self::$parent_term, array( 'taxonomy' => 'category' ) ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 401, $result->code ); $this->assertEquals( __( 'Sorry, you are not allowed to edit this term.' ), $result->message ); } @@ -57,7 +57,7 @@ class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', 9999, array( 'taxonomy' => 'category' ) ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 404, $result->code ); $this->assertEquals( __( 'Invalid term ID.' ), $result->message ); } @@ -66,7 +66,7 @@ class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', '', array( 'taxonomy' => 'category' ) ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 500, $result->code ); $this->assertEquals( __('Empty Term'), $result->message ); } @@ -75,7 +75,7 @@ class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$parent_term, array( 'taxonomy' => 'category', 'name' => '' ) ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); $this->assertEquals( __( 'The term name cannot be empty.' ), $result->message ); } @@ -84,7 +84,7 @@ class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$post_tag, array( 'taxonomy' => 'post_tag', 'parent' => self::$parent_term ) ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); $this->assertEquals( __( "This taxonomy is not hierarchical so you can't set a parent." ), $result->message ); } @@ -93,7 +93,7 @@ class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'parent' => '', 'name' => 'test' ) ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertTrue( $result ); } @@ -102,7 +102,7 @@ class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'parent' => NULL, 'name' => 'test' ) ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertInternalType( 'boolean', $result ); $term = get_term( self::$child_term, 'category' ); @@ -113,7 +113,7 @@ class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'parent' => 'dasda', 'name' => 'test' ) ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 500, $result->code ); } @@ -121,7 +121,7 @@ class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'parent' => 9999, 'name' => 'test' ) ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); $this->assertEquals( __( 'Parent term does not exist.' ), $result->message ); } @@ -131,7 +131,7 @@ class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { $parent_term = get_term_by( 'id', self::$parent_term, 'category' ); $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'slug' => $parent_term->slug ) ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 500, $result->code ); $this->assertEquals( htmlspecialchars( sprintf( __('The slug “%s” is already in use by another term'), $parent_term->slug ) ), $result->message ); } @@ -142,7 +142,7 @@ class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { $fields = array( 'taxonomy' => 'category', 'name' => 'Child 2', 'parent' => self::$parent_term, 'description' => 'Child term', 'slug' => 'child_2' ); $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, $fields ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertInternalType( 'boolean', $result ); } } diff --git a/tests/phpunit/tests/xmlrpc/wp/getComment.php b/tests/phpunit/tests/xmlrpc/wp/getComment.php index d66ccd8a0e..57ad8995f1 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getComment.php +++ b/tests/phpunit/tests/xmlrpc/wp/getComment.php @@ -35,7 +35,7 @@ class Tests_XMLRPC_wp_getComment extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_getComment( array( 1, 'username', 'password', self::$parent_comment_id ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); } @@ -43,7 +43,7 @@ class Tests_XMLRPC_wp_getComment extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'contributor' ); $result = $this->myxmlrpcserver->wp_getComment( array( 1, 'contributor', 'contributor', self::$parent_comment_id ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); } @@ -51,7 +51,7 @@ class Tests_XMLRPC_wp_getComment extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_getComment( array( 1, 'editor', 'editor', self::$parent_comment_id ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); // Check data types $this->assertInternalType( 'string', $result['user_id'] ); @@ -87,7 +87,7 @@ class Tests_XMLRPC_wp_getComment extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_getComment( array( 1, 'editor', 'editor', self::$child_comment_id ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertEquals( self::$child_comment_id, $result['comment_id'] ); $this->assertEquals( self::$parent_comment_id, $result['parent'] ); @@ -97,7 +97,7 @@ class Tests_XMLRPC_wp_getComment extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_getComment( array( 1, 'editor', 'editor', 123456789 ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 404, $result->code ); } } \ No newline at end of file diff --git a/tests/phpunit/tests/xmlrpc/wp/getComments.php b/tests/phpunit/tests/xmlrpc/wp/getComments.php index a4bdf22333..49b72535b7 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getComments.php +++ b/tests/phpunit/tests/xmlrpc/wp/getComments.php @@ -8,7 +8,7 @@ class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_getComments( array( 1, 'username', 'password', array() ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); } @@ -16,7 +16,7 @@ class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'contributor' ); $result = $this->myxmlrpcserver->wp_getComments( array( 1, 'contributor', 'contributor', array() ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 401, $result->code ); } @@ -27,7 +27,7 @@ class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $results = $this->myxmlrpcserver->wp_getComments( array( 1, 'editor', 'editor', array() ) ); - $this->assertNotInstanceOf( 'IXR_Error', $results ); + $this->assertNotIXRError( $results ); foreach( $results as $result ) { $comment = get_comment( $result['comment_id'], ARRAY_A ); @@ -44,7 +44,7 @@ class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { $results = $this->myxmlrpcserver->wp_getComments( array( 1, 'editor', 'editor', array( 'post_id' => $this->post_id ) ) ); - $this->assertNotInstanceOf( 'IXR_Error', $results ); + $this->assertNotIXRError( $results ); foreach( $results as $result ) { $this->assertEquals( $this->post_id, $result['post_id'] ); @@ -60,7 +60,7 @@ class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { $results = $this->myxmlrpcserver->wp_getComments( array( 1, 'editor', 'editor', array( 'post_id' => $this->post_id, ) ) ); - $this->assertNotInstanceOf( 'IXR_Error', $results ); + $this->assertNotIXRError( $results ); // if no 'number' filter is specified, default should be 10 $this->assertCount( 10, $results ); @@ -69,7 +69,7 @@ class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { 'post_id' => $this->post_id, 'number' => 5 ) ) ); - $this->assertNotInstanceOf( 'IXR_Error', $results2 ); + $this->assertNotIXRError( $results2 ); $this->assertCount( 5, $results2 ); } @@ -104,7 +104,7 @@ class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { ) ); $result = $this->myxmlrpcserver->wp_getComments( array( 1, 'contributor', 'contributor' ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 401, $result->code ); } @@ -140,7 +140,7 @@ class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { $result1 = $this->myxmlrpcserver->wp_getComments( array( 1, 'author', 'author', array( 'post_id' => $author_post_id ) ) ); - $this->assertInstanceOf( 'IXR_Error', $result1 ); + $this->assertIXRError( $result1 ); $result2 = $this->myxmlrpcserver->wp_getComments( array( 1, 'author', 'author', array( 'status' => 'approve', @@ -153,7 +153,7 @@ class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { $result3 = $this->myxmlrpcserver->wp_getComments( array( 1, 'author', 'author', array( 'post_id' => $editor_post_id ) ) ); - $this->assertInstanceOf( 'IXR_Error', $result3 ); + $this->assertIXRError( $result3 ); $result4 = $this->myxmlrpcserver->wp_getComments( array( 1, 'author', 'author', array( 'status' => 'approve', diff --git a/tests/phpunit/tests/xmlrpc/wp/getMediaItem.php b/tests/phpunit/tests/xmlrpc/wp/getMediaItem.php index 7b99dd5a04..a091f1c2b6 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getMediaItem.php +++ b/tests/phpunit/tests/xmlrpc/wp/getMediaItem.php @@ -38,7 +38,7 @@ class Tests_XMLRPC_wp_getMediaItem extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_getMediaItem( array( 1, 'username', 'password', 0 ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); } @@ -47,7 +47,7 @@ class Tests_XMLRPC_wp_getMediaItem extends WP_XMLRPC_UnitTestCase { $fields = array( 'post' ); $result = $this->myxmlrpcserver->wp_getMediaItem( array( 1, 'author', 'author', $this->attachment_id, $fields ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); // Check data types $this->assertInternalType( 'string', $result['attachment_id'] ); diff --git a/tests/phpunit/tests/xmlrpc/wp/getOptions.php b/tests/phpunit/tests/xmlrpc/wp/getOptions.php index 8b095f65c5..0dffcff231 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getOptions.php +++ b/tests/phpunit/tests/xmlrpc/wp/getOptions.php @@ -7,7 +7,7 @@ class Tests_XMLRPC_wp_getOptions extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_getOptions( array( 1, 'username', 'password' ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); } diff --git a/tests/phpunit/tests/xmlrpc/wp/getPage.php b/tests/phpunit/tests/xmlrpc/wp/getPage.php index 0f377b13b8..eb57239c95 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getPage.php +++ b/tests/phpunit/tests/xmlrpc/wp/getPage.php @@ -20,7 +20,7 @@ class Tests_XMLRPC_wp_getPage extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_getPage( array( 1, self::$post_id, 'username', 'password' ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); } @@ -31,7 +31,7 @@ class Tests_XMLRPC_wp_getPage extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_getPage( array( 1, 9999, 'editor', 'editor' ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 404, $result->code ); } @@ -39,7 +39,7 @@ class Tests_XMLRPC_wp_getPage extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_getPage( array( 1, self::$post_id, 'editor', 'editor' ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); // Check data types $this->assertInternalType( 'string', $result['userid'] ); @@ -80,7 +80,7 @@ class Tests_XMLRPC_wp_getPage extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_getPage( array( 1, self::$post_id, 'editor', 'editor' ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertInstanceOf( 'IXR_Date', $result['dateCreated'] ); $this->assertInstanceOf( 'IXR_Date', $result['date_created_gmt'] ); diff --git a/tests/phpunit/tests/xmlrpc/wp/getPageList.php b/tests/phpunit/tests/xmlrpc/wp/getPageList.php index ef8f793ca1..0e924c4ef4 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getPageList.php +++ b/tests/phpunit/tests/xmlrpc/wp/getPageList.php @@ -20,7 +20,7 @@ class Tests_XMLRPC_wp_getPageList extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_getPageList( array( 1, 'username', 'password' ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); } @@ -28,7 +28,7 @@ class Tests_XMLRPC_wp_getPageList extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'contributor' ); $result = $this->myxmlrpcserver->wp_getPageList( array( 1, 'contributor', 'contributor' ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 401, $result->code ); } @@ -36,7 +36,7 @@ class Tests_XMLRPC_wp_getPageList extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $results = $this->myxmlrpcserver->wp_getPageList( array( 1, 'editor', 'editor' ) ); - $this->assertNotInstanceOf( 'IXR_Error', $results ); + $this->assertNotIXRError( $results ); foreach( $results as $result ) { $page = get_post( $result->page_id ); diff --git a/tests/phpunit/tests/xmlrpc/wp/getPages.php b/tests/phpunit/tests/xmlrpc/wp/getPages.php index 424238794a..f528d832ff 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getPages.php +++ b/tests/phpunit/tests/xmlrpc/wp/getPages.php @@ -26,7 +26,7 @@ class Tests_XMLRPC_wp_getPages extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_getPages( array( 1, 'username', 'password' ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); } @@ -34,13 +34,13 @@ class Tests_XMLRPC_wp_getPages extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'contributor' ); $result = $this->myxmlrpcserver->wp_getPages( array( 1, 'contributor', 'contributor' ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 401, $result->code ); } function test_capable_user() { $results = $this->myxmlrpcserver->wp_getPages( array( 1, 'administrator', 'administrator' ) ); - $this->assertNotInstanceOf( 'IXR_Error', $results ); + $this->assertNotIXRError( $results ); foreach( $results as $result ) { $page = get_post( $result['page_id'] ); @@ -65,12 +65,12 @@ class Tests_XMLRPC_wp_getPages extends WP_XMLRPC_UnitTestCase { add_filter( 'map_meta_cap', array( $this, 'remove_editor_edit_page_cap') , 10, 4 ); $results = $this->myxmlrpcserver->wp_getPages( array( 1, 'editor', 'editor' ) ); - $this->assertNotInstanceOf( 'IXR_Error', $results ); + $this->assertNotIXRError( $results ); $found_incapable = false; foreach( $results as $result ) { // WP#20629 - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); if ( $result['page_id'] == self::$post_id ) { $found_incapable = true; diff --git a/tests/phpunit/tests/xmlrpc/wp/getPost.php b/tests/phpunit/tests/xmlrpc/wp/getPost.php index 6e6ecaeae9..b33f8a3021 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getPost.php +++ b/tests/phpunit/tests/xmlrpc/wp/getPost.php @@ -27,7 +27,7 @@ class Tests_XMLRPC_wp_getPost extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_getPost( array( 1, 'username', 'password', 1 ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); } @@ -36,7 +36,7 @@ class Tests_XMLRPC_wp_getPost extends WP_XMLRPC_UnitTestCase { $fields = array( 'post', 'custom_fields' ); $result = $this->myxmlrpcserver->wp_getPost( array( 1, 'author', 'author', $this->post_id, $fields ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); // Check data types $this->assertInternalType( 'string', $result['post_id'] ); @@ -79,7 +79,7 @@ class Tests_XMLRPC_wp_getPost extends WP_XMLRPC_UnitTestCase { function test_no_fields() { $fields = array(); $result = $this->myxmlrpcserver->wp_getPost( array( 1, 'author', 'author', $this->post_id, $fields ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); // when no fields are requested, only the IDs should be returned $this->assertEquals( 1, count( $result ) ); @@ -88,7 +88,7 @@ class Tests_XMLRPC_wp_getPost extends WP_XMLRPC_UnitTestCase { function test_default_fields() { $result = $this->myxmlrpcserver->wp_getPost( array( 1, 'author', 'author', $this->post_id ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertArrayHasKey( 'post_id', $result ); $this->assertArrayHasKey( 'link', $result ); // random field from 'posts' group @@ -99,7 +99,7 @@ class Tests_XMLRPC_wp_getPost extends WP_XMLRPC_UnitTestCase { function test_date() { $fields = array( 'post' ); $result = $this->myxmlrpcserver->wp_getPost( array( 1, 'author', 'author', $this->post_id, $fields ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertInstanceOf( 'IXR_Date', $result['post_date'] ); $this->assertInstanceOf( 'IXR_Date', $result['post_date_gmt'] ); @@ -130,7 +130,7 @@ class Tests_XMLRPC_wp_getPost extends WP_XMLRPC_UnitTestCase { ) ); $result = $this->myxmlrpcserver->wp_getPost( array( 1, 'editor', 'editor', $child_page_id ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertInternalType( 'string', $result['post_id'] ); $this->assertInternalType( 'string', $result['post_parent'] ); diff --git a/tests/phpunit/tests/xmlrpc/wp/getPostType.php b/tests/phpunit/tests/xmlrpc/wp/getPostType.php index a00dbda3f7..cef0fd6981 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getPostType.php +++ b/tests/phpunit/tests/xmlrpc/wp/getPostType.php @@ -31,7 +31,7 @@ class Tests_XMLRPC_wp_getPostType extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_getPostType( array( 1, 'username', 'password', 'post' ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); } @@ -39,7 +39,7 @@ class Tests_XMLRPC_wp_getPostType extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_getPostType( array( 1, 'editor', 'editor', 'foobar' ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); } @@ -47,14 +47,14 @@ class Tests_XMLRPC_wp_getPostType extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_getPostType( array( 1, 'editor', 'editor', 'post' ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); } function test_incapable_user() { $this->make_user_by_role( 'subscriber' ); $result = $this->myxmlrpcserver->wp_getPostType( array( 1, 'subscriber', 'subscriber', 'post' ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 401, $result->code ); } @@ -62,7 +62,7 @@ class Tests_XMLRPC_wp_getPostType extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_getPostType( array( 1, 'editor', 'editor', $this->cpt_name, array( 'labels', 'cap', 'menu', 'taxonomies' ) ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); // check data types $this->assertInternalType( 'string', $result['name'] ); diff --git a/tests/phpunit/tests/xmlrpc/wp/getPostTypes.php b/tests/phpunit/tests/xmlrpc/wp/getPostTypes.php index ae78a5db51..7188411931 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getPostTypes.php +++ b/tests/phpunit/tests/xmlrpc/wp/getPostTypes.php @@ -6,7 +6,7 @@ class Tests_XMLRPC_wp_getPostTypes extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_getPostTypes( array( 1, 'username', 'password', 'post' ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); } @@ -14,7 +14,7 @@ class Tests_XMLRPC_wp_getPostTypes extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'subscriber' ); $result = $this->myxmlrpcserver->wp_getPostTypes( array( 1, 'subscriber', 'subscriber' ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertInternalType( 'array', $result ); $this->assertEquals( 0, count( $result ) ); } @@ -23,7 +23,7 @@ class Tests_XMLRPC_wp_getPostTypes extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_getPostTypes( array( 1, 'editor', 'editor' ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertInternalType( 'array', $result ); $this->assertGreaterThan( 0, count( $result ) ); } @@ -32,7 +32,7 @@ class Tests_XMLRPC_wp_getPostTypes extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_getPostTypes( array( 1, 'editor', 'editor', array( 'hierarchical' => true ) ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertInternalType( 'array', $result ); // verify that pages is in the result, and post is not diff --git a/tests/phpunit/tests/xmlrpc/wp/getPosts.php b/tests/phpunit/tests/xmlrpc/wp/getPosts.php index 3119fea61f..28d3c4b28d 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getPosts.php +++ b/tests/phpunit/tests/xmlrpc/wp/getPosts.php @@ -7,7 +7,7 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_getPosts( array( 1, 'username', 'password' ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); } @@ -18,12 +18,12 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'subscriber' ); $result = $this->myxmlrpcserver->wp_getPosts( array( 1, 'subscriber', 'subscriber' ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 401, $result->code ); $filter = array( 'post_type' => 'page' ); $result = $this->myxmlrpcserver->wp_getPosts( array( 1, 'subscriber', 'subscriber', $filter ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 401, $result->code ); } @@ -31,7 +31,7 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor' ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); } function test_invalid_post_type() { @@ -39,7 +39,7 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { $filter = array( 'post_type' => 'invalid_post_type_name' ); $result = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); } function test_filters() { @@ -62,7 +62,7 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { // get them all $filter = array( 'post_type' => $cpt_name, 'number' => $num_posts + 10 ); $results = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter ) ); - $this->assertNotInstanceOf( 'IXR_Error', $results ); + $this->assertNotIXRError( $results ); $this->assertEquals( $num_posts, count( $results ) ); // page through results @@ -86,7 +86,7 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { // get results ordered by comment count $filter2 = array( 'post_type' => $cpt_name, 'number' => $num_posts, 'orderby' => 'comment_count', 'order' => 'DESC' ); $results2 = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter2 ) ); - $this->assertNotInstanceOf( 'IXR_Error', $results2 ); + $this->assertNotIXRError( $results2 ); $last_comment_count = 100; foreach ( $results2 as $post ) { $comment_count = intval( get_comments_number( $post['post_id'] ) ); @@ -100,7 +100,7 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { wp_update_post( $post ); $filter3 = array( 'post_type' => $cpt_name, 'post_status' => 'draft' ); $results3 = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter3 ) ); - $this->assertNotInstanceOf( 'IXR_Error', $results3 ); + $this->assertNotIXRError( $results3 ); $this->assertEquals( 1, count( $results3 ) ); $this->assertEquals( $post->ID, $results3[0]['post_id'] ); @@ -113,7 +113,7 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { // check default fields $results = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor' ) ); - $this->assertNotInstanceOf( 'IXR_Error', $results ); + $this->assertNotIXRError( $results ); $expected_fields = array( 'post_id', 'post_title', 'terms', 'custom_fields', 'link' ); // subset of expected fields foreach( $expected_fields as $field ) { $this->assertArrayHasKey( $field, $results[0] ); @@ -123,7 +123,7 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { $filter = array(); $fields = array( 'post_name', 'post_author', 'enclosure' ); $results2 = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter, $fields ) ); - $this->assertNotInstanceOf( 'IXR_Error', $results2 ); + $this->assertNotIXRError( $results2 ); $expected_fields = array_merge( $fields, array( 'post_id' ) ); foreach ( array_keys( $results2[0] ) as $field ) { $this->assertContains( $field, $expected_fields ); @@ -142,13 +142,13 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { // Search for none of them $filter = array( 's' => 'Third' ); $results = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter ) ); - $this->assertNotInstanceOf( 'IXR_Error', $results ); + $this->assertNotIXRError( $results ); $this->assertEquals( 0, count( $results ) ); // Search for one of them $filter = array( 's' => 'First:' ); $results = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter ) ); - $this->assertNotInstanceOf( 'IXR_Error', $results ); + $this->assertNotIXRError( $results ); $this->assertEquals( 1, count( $results ) ); } diff --git a/tests/phpunit/tests/xmlrpc/wp/getProfile.php b/tests/phpunit/tests/xmlrpc/wp/getProfile.php index cc2da3e46a..86fd8213dd 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getProfile.php +++ b/tests/phpunit/tests/xmlrpc/wp/getProfile.php @@ -8,7 +8,7 @@ class Tests_XMLRPC_wp_getProfile extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_getProfile( array( 1, 'username', 'password' ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); } @@ -16,7 +16,7 @@ class Tests_XMLRPC_wp_getProfile extends WP_XMLRPC_UnitTestCase { $subscriber_id = $this->make_user_by_role( 'subscriber' ); $result = $this->myxmlrpcserver->wp_getProfile( array( 1, 'subscriber', 'subscriber' ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertEquals( $subscriber_id, $result['user_id'] ); $this->assertContains( 'subscriber', $result['roles'] ); } @@ -25,7 +25,7 @@ class Tests_XMLRPC_wp_getProfile extends WP_XMLRPC_UnitTestCase { $administrator_id = $this->make_user_by_role( 'administrator' ); $result = $this->myxmlrpcserver->wp_getProfile( array( 1, 'administrator', 'administrator' ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertEquals( $administrator_id, $result['user_id'] ); $this->assertContains( 'administrator', $result['roles'] ); } @@ -36,7 +36,7 @@ class Tests_XMLRPC_wp_getProfile extends WP_XMLRPC_UnitTestCase { $fields = array( 'email', 'bio', 'user_contacts' ); $result = $this->myxmlrpcserver->wp_getProfile( array( 1, 'editor', 'editor', $fields ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertEquals( $editor_id, $result['user_id'] ); $expected_fields = array( 'user_id', 'email', 'bio' ); diff --git a/tests/phpunit/tests/xmlrpc/wp/getRevisions.php b/tests/phpunit/tests/xmlrpc/wp/getRevisions.php index a407c65ae2..d1aad1e390 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getRevisions.php +++ b/tests/phpunit/tests/xmlrpc/wp/getRevisions.php @@ -7,7 +7,7 @@ class Tests_XMLRPC_wp_getRevisions extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_getRevisions( array( 1, 'username', 'password', 0 ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); } @@ -17,7 +17,7 @@ class Tests_XMLRPC_wp_getRevisions extends WP_XMLRPC_UnitTestCase { $post_id = self::factory()->post->create(); $result = $this->myxmlrpcserver->wp_getRevisions( array( 1, 'subscriber', 'subscriber', $post_id ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 401, $result->code ); } @@ -26,7 +26,7 @@ class Tests_XMLRPC_wp_getRevisions extends WP_XMLRPC_UnitTestCase { $post_id = self::factory()->post->create(); $result = $this->myxmlrpcserver->wp_getRevisions( array( 1, 'editor', 'editor', $post_id ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); } function test_revision_count() { diff --git a/tests/phpunit/tests/xmlrpc/wp/getTaxonomies.php b/tests/phpunit/tests/xmlrpc/wp/getTaxonomies.php index cd2c86e3cc..97bd9cf467 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getTaxonomies.php +++ b/tests/phpunit/tests/xmlrpc/wp/getTaxonomies.php @@ -7,7 +7,7 @@ class Tests_XMLRPC_wp_getTaxonomies extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_getTaxonomies( array( 1, 'username', 'password' ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); } @@ -15,6 +15,6 @@ class Tests_XMLRPC_wp_getTaxonomies extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_getTaxonomies( array( 1, 'editor', 'editor' ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); } } \ No newline at end of file diff --git a/tests/phpunit/tests/xmlrpc/wp/getTaxonomy.php b/tests/phpunit/tests/xmlrpc/wp/getTaxonomy.php index f8446bcbf9..5ffff80a81 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getTaxonomy.php +++ b/tests/phpunit/tests/xmlrpc/wp/getTaxonomy.php @@ -7,7 +7,7 @@ class Tests_XMLRPC_wp_getTaxonomy extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_getTaxonomy( array( 1, 'username', 'password', 'category' ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); } @@ -15,7 +15,7 @@ class Tests_XMLRPC_wp_getTaxonomy extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_getTaxonomy( array( 1, 'editor', 'editor', '' ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message ); } @@ -24,7 +24,7 @@ class Tests_XMLRPC_wp_getTaxonomy extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_getTaxonomy( array( 1, 'editor', 'editor', 'not_existing' ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message ); } @@ -33,7 +33,7 @@ class Tests_XMLRPC_wp_getTaxonomy extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'subscriber' ); $result = $this->myxmlrpcserver->wp_getTaxonomy( array( 1, 'subscriber', 'subscriber', 'category' ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 401, $result->code ); $this->assertEquals( __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ), $result->message ); } @@ -42,14 +42,14 @@ class Tests_XMLRPC_wp_getTaxonomy extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_getTaxonomy( array( 1, 'editor', 'editor', 'category' ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); } function test_prepare_taxonomy() { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_getTaxonomy( array( 1, 'editor', 'editor', 'category' ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $taxonomy = get_taxonomy( 'category' ); $this->assertEquals( 'category', $result['name'], 'name' ); $this->assertEquals( true, $result['_builtin'], '_builtin' ); diff --git a/tests/phpunit/tests/xmlrpc/wp/getTerm.php b/tests/phpunit/tests/xmlrpc/wp/getTerm.php index 2edbaeb2ff..fca71a7a95 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getTerm.php +++ b/tests/phpunit/tests/xmlrpc/wp/getTerm.php @@ -15,7 +15,7 @@ class Tests_XMLRPC_wp_getTerm extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'username', 'password', 'category', 1 ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); } @@ -23,7 +23,7 @@ class Tests_XMLRPC_wp_getTerm extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'editor', 'editor', '', 0 ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message ); } @@ -32,7 +32,7 @@ class Tests_XMLRPC_wp_getTerm extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'editor', 'editor', 'not_existing', 0 ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message ); } @@ -41,7 +41,7 @@ class Tests_XMLRPC_wp_getTerm extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'subscriber' ); $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'subscriber', 'subscriber', 'category', self::$term_id ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 401, $result->code ); $this->assertEquals( __( 'Sorry, you are not allowed to assign this term.' ), $result->message ); } @@ -51,7 +51,7 @@ class Tests_XMLRPC_wp_getTerm extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'editor', 'editor', 'category', '' ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 500, $result->code ); $this->assertEquals( __('Empty Term'), $result->message ); } @@ -60,7 +60,7 @@ class Tests_XMLRPC_wp_getTerm extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'editor', 'editor', 'category', 9999 ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 404, $result->code ); $this->assertEquals( __( 'Invalid term ID.' ), $result->message ); } @@ -72,7 +72,7 @@ class Tests_XMLRPC_wp_getTerm extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'editor', 'editor', 'category', self::$term_id ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertEquals( $result, $term ); // Check DataTypes diff --git a/tests/phpunit/tests/xmlrpc/wp/getTerms.php b/tests/phpunit/tests/xmlrpc/wp/getTerms.php index 1673975f1f..b67cbde140 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getTerms.php +++ b/tests/phpunit/tests/xmlrpc/wp/getTerms.php @@ -7,7 +7,7 @@ class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_getTerms( array( 1, 'username', 'password', 'category' ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); } @@ -15,7 +15,7 @@ class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', '' ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message ); } @@ -24,7 +24,7 @@ class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'not_existing' ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message ); } @@ -33,7 +33,7 @@ class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'subscriber' ); $result = $this->myxmlrpcserver->wp_getTerms( array( 1, 'subscriber', 'subscriber', 'category' ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 401, $result->code ); $this->assertEquals( __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ), $result->message ); } @@ -45,7 +45,7 @@ class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase { $cat = wp_insert_term( 'term_' . __FUNCTION__ , 'category' ); $results = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'category' ) ); - $this->assertNotInstanceOf( 'IXR_Error', $results ); + $this->assertNotIXRError( $results ); foreach( $results as $term ) { $this->assertInternalType( 'int', $term['count'] ); @@ -71,7 +71,7 @@ class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase { // test fetching all terms $results = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', $tax_name ) ); - $this->assertNotInstanceOf( 'IXR_Error', $results ); + $this->assertNotIXRError( $results ); $this->assertEquals( $num_terms, count( $results ) ); foreach ( $results as $term ) { @@ -81,20 +81,20 @@ class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase { // test paged results $filter = array( 'number' => 5 ); $results2 = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', $tax_name, $filter ) ); - $this->assertNotInstanceOf( 'IXR_Error', $results ); + $this->assertNotIXRError( $results ); $this->assertEquals( 5, count( $results2 ) ); $this->assertEquals( $results[1]['term_id'], $results2[1]['term_id'] ); // check one of the terms $filter['offset'] = 10; $results3 = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', $tax_name, $filter ) ); - $this->assertNotInstanceOf( 'IXR_Error', $results3 ); + $this->assertNotIXRError( $results3 ); $this->assertEquals( $num_terms - 10, count( $results3 ) ); $this->assertEquals( $results[11]['term_id'], $results3[1]['term_id'] ); // test hide_empty (since none have been attached to posts yet, all should be hidden $filter = array( 'hide_empty' => true ); $results4 = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', $tax_name, $filter ) ); - $this->assertNotInstanceOf( 'IXR_Error', $results4 ); + $this->assertNotIXRError( $results4 ); $this->assertEquals( 0, count( $results4 ) ); unset($GLOBALS['wp_taxonomies'][$tax_name]); @@ -111,7 +111,7 @@ class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase { $filter = array( 'orderby' => 'count', 'order' => 'DESC' ); $results = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'category', $filter ) ); - $this->assertNotInstanceOf( 'IXR_Error', $results ); + $this->assertNotIXRError( $results ); $this->assertNotEquals( 0, count( $results ) ); foreach( $results as $term ) { @@ -133,7 +133,7 @@ class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase { // search by full name $filter = array( 'search' => $name ); $results = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'category', $filter ) ); - $this->assertNotInstanceOf( 'IXR_Error', $results ); + $this->assertNotIXRError( $results ); $this->assertEquals( 1, count( $results ) ); $this->assertEquals( $name, $results[0]['name'] ); $this->assertEquals( $name_id, $results[0]['term_id'] ); @@ -141,7 +141,7 @@ class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase { // search by partial name $filter = array( 'search' => substr( $name, 0, 10 ) ); $results2 = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'category', $filter ) ); - $this->assertNotInstanceOf( 'IXR_Error', $results2 ); + $this->assertNotIXRError( $results2 ); $this->assertEquals( 1, count( $results2 ) ); $this->assertEquals( $name, $results2[0]['name'] ); $this->assertEquals( $name_id, $results2[0]['term_id'] ); diff --git a/tests/phpunit/tests/xmlrpc/wp/getUser.php b/tests/phpunit/tests/xmlrpc/wp/getUser.php index acef3c6a06..beda930f42 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getUser.php +++ b/tests/phpunit/tests/xmlrpc/wp/getUser.php @@ -25,13 +25,13 @@ class Tests_XMLRPC_wp_getUser extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_getUser( array( 1, 'username', 'password', 1 ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); } function test_invalid_user() { $result = $this->myxmlrpcserver->wp_getUser( array( 1, 'administrator', 'administrator', 34902348908234 ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 404, $result->code ); } @@ -40,7 +40,7 @@ class Tests_XMLRPC_wp_getUser extends WP_XMLRPC_UnitTestCase { $editor_id = $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_getUser( array( 1, 'subscriber', 'subscriber', $editor_id ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 401, $result->code ); } @@ -48,7 +48,7 @@ class Tests_XMLRPC_wp_getUser extends WP_XMLRPC_UnitTestCase { $subscriber_id = $this->make_user_by_role( 'subscriber' ); $result = $this->myxmlrpcserver->wp_getUser( array( 1, 'subscriber', 'subscriber', $subscriber_id ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertEquals( $subscriber_id, $result['user_id'] ); } @@ -72,7 +72,7 @@ class Tests_XMLRPC_wp_getUser extends WP_XMLRPC_UnitTestCase { $user_id = wp_insert_user( $user_data ); $result = $this->myxmlrpcserver->wp_getUser( array( 1, 'administrator', 'administrator', $user_id ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); // check data types $this->assertInternalType( 'string', $result['user_id'] ); @@ -111,7 +111,7 @@ class Tests_XMLRPC_wp_getUser extends WP_XMLRPC_UnitTestCase { $editor_id = $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_getUser( array( 1, 'administrator', 'administrator', $editor_id, array() ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertEquals( $editor_id, $result['user_id'] ); $expected_fields = array( 'user_id' ); @@ -122,7 +122,7 @@ class Tests_XMLRPC_wp_getUser extends WP_XMLRPC_UnitTestCase { $editor_id = $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_getUser( array( 1, 'administrator', 'administrator', $editor_id, array( 'basic' ) ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertEquals( $editor_id, $result['user_id'] ); $expected_fields = array( 'user_id', 'username', 'email', 'registered', 'display_name', 'nicename' ); @@ -138,7 +138,7 @@ class Tests_XMLRPC_wp_getUser extends WP_XMLRPC_UnitTestCase { $fields = array( 'email', 'bio', 'user_contacts' ); $result = $this->myxmlrpcserver->wp_getUser( array( 1, 'administrator', 'administrator', $editor_id, $fields ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertEquals( $editor_id, $result['user_id'] ); $expected_fields = array( 'user_id', 'email', 'bio' ); diff --git a/tests/phpunit/tests/xmlrpc/wp/getUsers.php b/tests/phpunit/tests/xmlrpc/wp/getUsers.php index 1860fd11d3..62169e0c64 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getUsers.php +++ b/tests/phpunit/tests/xmlrpc/wp/getUsers.php @@ -8,7 +8,7 @@ class Tests_XMLRPC_wp_getUsers extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $results = $this->myxmlrpcserver->wp_getUsers( array( 1, 'username', 'password' ) ); - $this->assertInstanceOf( 'IXR_Error', $results ); + $this->assertIXRError( $results ); $this->assertEquals( 403, $results->code ); } @@ -16,7 +16,7 @@ class Tests_XMLRPC_wp_getUsers extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'subscriber' ); $results = $this->myxmlrpcserver->wp_getUsers( array( 1, 'subscriber', 'subscriber' ) ); - $this->assertInstanceOf( 'IXR_Error', $results ); + $this->assertIXRError( $results ); $this->assertEquals( 401, $results->code ); } @@ -24,7 +24,7 @@ class Tests_XMLRPC_wp_getUsers extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'administrator' ); $result = $this->myxmlrpcserver->wp_getUsers( array( 1, 'administrator', 'administrator' ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); // check data types $this->assertInternalType( 'string', $result[0]['user_id'] ); @@ -49,7 +49,7 @@ class Tests_XMLRPC_wp_getUsers extends WP_XMLRPC_UnitTestCase { $filter = array( 'role' => 'invalidrole' ); $results = $this->myxmlrpcserver->wp_getUsers( array( 1, 'administrator', 'administrator', $filter ) ); - $this->assertInstanceOf( 'IXR_Error', $results ); + $this->assertIXRError( $results ); $this->assertEquals( 403, $results->code ); } @@ -63,14 +63,14 @@ class Tests_XMLRPC_wp_getUsers extends WP_XMLRPC_UnitTestCase { // test a single role ('editor') $filter = array( 'role' => 'editor' ); $results = $this->myxmlrpcserver->wp_getUsers( array( 1, 'administrator', 'administrator', $filter ) ); - $this->assertNotInstanceOf( 'IXR_Error', $results ); + $this->assertNotIXRError( $results ); $this->assertCount( 1, $results ); $this->assertEquals( $editor_id, $results[0]['user_id'] ); // test 'authors', which should return all non-subscribers $filter2 = array( 'who' => 'authors' ); $results2 = $this->myxmlrpcserver->wp_getUsers( array( 1, 'administrator', 'administrator', $filter2 ) ); - $this->assertNotInstanceOf( 'IXR_Error', $results2 ); + $this->assertNotIXRError( $results2 ); $this->assertCount( 3, array_intersect( array( $author_id, $editor_id, $administrator_id ), wp_list_pluck( $results2, 'user_id' ) ) ); } @@ -104,7 +104,7 @@ class Tests_XMLRPC_wp_getUsers extends WP_XMLRPC_UnitTestCase { $filter = array( 'orderby' => 'email', 'order' => 'ASC' ); $results = $this->myxmlrpcserver->wp_getUsers( array( 1, 'administrator', 'administrator', $filter ) ); - $this->assertNotInstanceOf( 'IXR_Error', $results ); + $this->assertNotIXRError( $results ); $last_email = ''; foreach ( $results as $user ) { diff --git a/tests/phpunit/tests/xmlrpc/wp/newComment.php b/tests/phpunit/tests/xmlrpc/wp/newComment.php index 80e70ef32e..148c6acc23 100644 --- a/tests/phpunit/tests/xmlrpc/wp/newComment.php +++ b/tests/phpunit/tests/xmlrpc/wp/newComment.php @@ -13,7 +13,7 @@ class Tests_XMLRPC_wp_newComment extends WP_XMLRPC_UnitTestCase { 'content' => rand_str( 100 ) ) ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); } function test_empty_comment() { @@ -24,7 +24,7 @@ class Tests_XMLRPC_wp_newComment extends WP_XMLRPC_UnitTestCase { 'content' => '' ) ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); } @@ -40,7 +40,7 @@ class Tests_XMLRPC_wp_newComment extends WP_XMLRPC_UnitTestCase { 'content' => rand_str( 100 ), ) ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); } @@ -54,12 +54,12 @@ class Tests_XMLRPC_wp_newComment extends WP_XMLRPC_UnitTestCase { // First time it's a valid comment $result = $this->myxmlrpcserver->wp_newComment( $comment_args ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); // Run second time for duplication error $result = $this->myxmlrpcserver->wp_newComment( $comment_args ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); } diff --git a/tests/phpunit/tests/xmlrpc/wp/newPost.php b/tests/phpunit/tests/xmlrpc/wp/newPost.php index 3092aef637..1b718bc563 100644 --- a/tests/phpunit/tests/xmlrpc/wp/newPost.php +++ b/tests/phpunit/tests/xmlrpc/wp/newPost.php @@ -7,7 +7,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'username', 'password', array() ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); } @@ -15,7 +15,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'subscriber' ); $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'subscriber', 'subscriber', array() ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 401, $result->code ); } @@ -23,7 +23,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'author' ); $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', array() ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 500, $result->code ); $this->assertEquals( 'Content, title, and excerpt are empty.', $result->message ); } @@ -33,7 +33,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { $post = array( 'post_title' => 'Test' ); $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertStringMatchesFormat( '%d', $result ); } @@ -42,7 +42,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { $post = array( 'post_title' => 'Test', 'ID' => 103948 ); $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertNotEquals( '103948', $result ); } @@ -51,7 +51,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { $post = array( 'post_title' => 'Test', 'post_status' => 'publish' ); $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); } function test_incapable_publish() { @@ -59,7 +59,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { $post = array( 'post_title' => 'Test', 'post_status' => 'publish' ); $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'contributor', 'contributor', $post ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 401, $result->code ); } @@ -68,7 +68,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { $post = array( 'post_title' => 'Test', 'post_status' => 'private' ); $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); } function test_incapable_private() { @@ -76,7 +76,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { $post = array( 'post_title' => 'Test', 'post_status' => 'private' ); $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'contributor', 'contributor', $post ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 401, $result->code ); } @@ -86,7 +86,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { $post = array( 'post_title' => 'Test', 'post_author' => $other_author_id ); $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); } function test_incapable_other_author() { @@ -95,7 +95,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { $post = array( 'post_title' => 'Test', 'post_author' => $other_author_id ); $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'contributor', 'contributor', $post ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 401, $result->code ); } @@ -104,7 +104,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { $post = array( 'post_title' => 'Test', 'post_author' => 99999999 ); $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 404, $result->code ); } @@ -113,7 +113,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { $post = array( 'post_title' => 'Test' ); $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertStringMatchesFormat( '%d', $result ); $out = get_post( $result ); @@ -132,7 +132,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { $post = array( 'post_title' => 'Post Thumbnail Test', 'post_thumbnail' => $attachment_id ); $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertEquals( $attachment_id, get_post_meta( $result, '_thumbnail_id', true ) ); remove_theme_support( 'post-thumbnails' ); @@ -143,7 +143,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { $post = array( 'post_title' => 'Test', 'post_status' => 'foobar_status' ); $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertEquals( 'draft', get_post_status( $result ) ); } @@ -152,7 +152,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { $post = array( 'post_title' => 'Test', 'sticky' => true ); $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'contributor', 'contributor', $post ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 401, $result->code ); } @@ -161,7 +161,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { $post = array( 'post_title' => 'Test', 'sticky' => true ); $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertTrue( is_sticky( $result ) ); } @@ -170,7 +170,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { $post = array( 'post_title' => 'Test', 'post_status' => 'private', 'sticky' => true ); $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 401, $result->code ); } @@ -179,7 +179,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { $post = array( 'post_title' => 'Test', 'post_format' => 'quote' ); $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertEquals( 'quote', get_post_format( $result ) ); } @@ -188,7 +188,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { $post = array( 'post_title' => 'Test', 'post_format' => 'tumblr' ); $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertEquals( '', get_post_format( $result ) ); } @@ -202,7 +202,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { ) ); $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 401, $result->code ); $post2 = array( @@ -212,7 +212,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { ) ); $result2 = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post2 ) ); - $this->assertInstanceOf( 'IXR_Error', $result2 ); + $this->assertIXRError( $result2 ); $this->assertEquals( 401, $result2->code ); } @@ -226,7 +226,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { ) ); $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); } @@ -247,7 +247,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { ) ); $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $post_tags = wp_get_object_terms( $result, 'post_tag', array( 'fields' => 'ids' ) ); $this->assertNotContains( $tag1['term_id'], $post_tags ); @@ -274,7 +274,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { ) ); $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); // verify that cat2 was created $cat2 = get_term_by( 'name', $cat2_name, 'category' ); $this->assertNotEmpty( $cat2 ); @@ -291,7 +291,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { ) ); $result2 = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post2 ) ); - $this->assertInstanceOf( 'IXR_Error', $result2 ); + $this->assertIXRError( $result2 ); $this->assertEquals( 401, $result2->code ); } diff --git a/tests/phpunit/tests/xmlrpc/wp/newTerm.php b/tests/phpunit/tests/xmlrpc/wp/newTerm.php index 860e5c8dcb..f5f012f3eb 100644 --- a/tests/phpunit/tests/xmlrpc/wp/newTerm.php +++ b/tests/phpunit/tests/xmlrpc/wp/newTerm.php @@ -15,7 +15,7 @@ class Tests_XMLRPC_wp_newTerm extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'username', 'password', array() ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); } @@ -23,7 +23,7 @@ class Tests_XMLRPC_wp_newTerm extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => '' ) ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message ); } @@ -32,7 +32,7 @@ class Tests_XMLRPC_wp_newTerm extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'not_existing' ) ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message ); } @@ -41,7 +41,7 @@ class Tests_XMLRPC_wp_newTerm extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'subscriber' ); $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'subscriber', 'subscriber', array( 'taxonomy' => 'category' ) ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 401, $result->code ); $this->assertEquals( __( 'Sorry, you are not allowed to create terms in this taxonomy.' ), $result->message ); } @@ -50,7 +50,7 @@ class Tests_XMLRPC_wp_newTerm extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'category', 'name' => '' ) ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); $this->assertEquals( __( 'The term name cannot be empty.' ), $result->message ); } @@ -59,7 +59,7 @@ class Tests_XMLRPC_wp_newTerm extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'post_tag', 'parent' => self::$parent_term_id, 'name' => 'test' ) ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); $this->assertEquals( __( 'This taxonomy is not hierarchical.' ), $result->message ); } @@ -68,7 +68,7 @@ class Tests_XMLRPC_wp_newTerm extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'category', 'parent' => 'dasda', 'name' => 'test' ) ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 500, $result->code ); } @@ -76,7 +76,7 @@ class Tests_XMLRPC_wp_newTerm extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'category', 'parent' => 9999, 'name' => 'test' ) ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); $this->assertEquals( __( 'Parent term does not exist.' ), $result->message ); } @@ -86,7 +86,7 @@ class Tests_XMLRPC_wp_newTerm extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'category', 'name' => 'test' ) ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertStringMatchesFormat( '%d', $result ); } @@ -94,7 +94,7 @@ class Tests_XMLRPC_wp_newTerm extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'category', 'parent' => self::$parent_term_id, 'name' => 'test' ) ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertStringMatchesFormat( '%d', $result ); } @@ -103,7 +103,7 @@ class Tests_XMLRPC_wp_newTerm extends WP_XMLRPC_UnitTestCase { $taxonomy = array( 'taxonomy' => 'category', 'parent' => self::$parent_term_id, 'name' => 'test_all', 'description' => 'Test all', 'slug' => 'test_all' ); $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', $taxonomy ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); $this->assertStringMatchesFormat( '%d', $result ); } } diff --git a/tests/phpunit/tests/xmlrpc/wp/restoreRevision.php b/tests/phpunit/tests/xmlrpc/wp/restoreRevision.php index 75f5d74fa0..be9d1916af 100644 --- a/tests/phpunit/tests/xmlrpc/wp/restoreRevision.php +++ b/tests/phpunit/tests/xmlrpc/wp/restoreRevision.php @@ -23,7 +23,7 @@ class Tests_XMLRPC_wp_restoreRevision extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_restoreRevision( array( 1, 'username', 'password', $this->revision_id ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 403, $result->code ); } @@ -31,7 +31,7 @@ class Tests_XMLRPC_wp_restoreRevision extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'subscriber' ); $result = $this->myxmlrpcserver->wp_restoreRevision( array( 1, 'subscriber', 'subscriber', $this->revision_id ) ); - $this->assertInstanceOf( 'IXR_Error', $result ); + $this->assertIXRError( $result ); $this->assertEquals( 401, $result->code ); } @@ -39,7 +39,7 @@ class Tests_XMLRPC_wp_restoreRevision extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $result = $this->myxmlrpcserver->wp_restoreRevision( array( 1, 'editor', 'editor', $this->revision_id ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); } function test_revision_restored() { diff --git a/tests/phpunit/tests/xmlrpc/wp/uploadFile.php b/tests/phpunit/tests/xmlrpc/wp/uploadFile.php index 8baa3f6cff..e15f85d420 100644 --- a/tests/phpunit/tests/xmlrpc/wp/uploadFile.php +++ b/tests/phpunit/tests/xmlrpc/wp/uploadFile.php @@ -25,7 +25,7 @@ class Tests_XMLRPC_wp_uploadFile extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->mw_newMediaObject( array( 0, 'editor', 'editor', $data ) ); - $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertNotIXRError( $result ); // check data types $this->assertInternalType( 'string', $result['id'] );