-
diff --git tests/phpunit/tests/xmlrpc/basic.php tests/phpunit/tests/xmlrpc/basic.php
index bbbcbd7d5d..7818fdb0bf 100644
|
|
|
class Tests_XMLRPC_Basic extends WP_XMLRPC_UnitTestCase { |
| 11 | 11 | function test_enabled() { |
| 12 | 12 | $result = $this->myxmlrpcserver->wp_getOptions( array( 1, 'username', 'password' ) ); |
| 13 | 13 | |
| 14 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 14 | $this->assertIXRError( $result ); |
| 15 | 15 | // If disabled, 405 would result. |
| 16 | 16 | $this->assertEquals( 403, $result->code ); |
| 17 | 17 | } |
-
diff --git tests/phpunit/tests/xmlrpc/mt/getRecentPostTitles.php tests/phpunit/tests/xmlrpc/mt/getRecentPostTitles.php
index 8d9c027f22..7c36f978ef 100644
|
|
|
class Tests_XMLRPC_mt_getRecentPostTitles extends WP_XMLRPC_UnitTestCase { |
| 7 | 7 | |
| 8 | 8 | function test_invalid_username_password() { |
| 9 | 9 | $result = $this->myxmlrpcserver->mt_getRecentPostTitles( array( 1, 'username', 'password' ) ); |
| 10 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 10 | $this->assertIXRError( $result ); |
| 11 | 11 | $this->assertEquals( 403, $result->code ); |
| 12 | 12 | } |
| 13 | 13 | |
| … |
… |
class Tests_XMLRPC_mt_getRecentPostTitles extends WP_XMLRPC_UnitTestCase { |
| 15 | 15 | $this->make_user_by_role( 'author' ); |
| 16 | 16 | |
| 17 | 17 | $result = $this->myxmlrpcserver->mt_getRecentPostTitles( array( 1, 'author', 'author' ) ); |
| 18 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 18 | $this->assertIXRError( $result ); |
| 19 | 19 | $this->assertEquals( 500, $result->code ); |
| 20 | 20 | } |
| 21 | 21 | |
| … |
… |
class Tests_XMLRPC_mt_getRecentPostTitles extends WP_XMLRPC_UnitTestCase { |
| 25 | 25 | self::factory()->post->create( array( 'post_author' => $editor ) ); |
| 26 | 26 | |
| 27 | 27 | $result = $this->myxmlrpcserver->mt_getRecentPostTitles( array( 1, 'author', 'author' ) ); |
| 28 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 28 | $this->assertNotIXRError( $result ); |
| 29 | 29 | $this->assertEquals( 0, count( $result ) ); |
| 30 | 30 | } |
| 31 | 31 | |
| … |
… |
class Tests_XMLRPC_mt_getRecentPostTitles extends WP_XMLRPC_UnitTestCase { |
| 35 | 35 | self::factory()->post->create(); |
| 36 | 36 | |
| 37 | 37 | $results = $this->myxmlrpcserver->mt_getRecentPostTitles( array( 1, 'author', 'author' ) ); |
| 38 | | $this->assertNotInstanceOf( 'IXR_Error', $results ); |
| | 38 | $this->assertNotIXRError( $results ); |
| 39 | 39 | |
| 40 | 40 | foreach( $results as $result ) { |
| 41 | 41 | $post = get_post( $result['postid'] ); |
-
diff --git tests/phpunit/tests/xmlrpc/mw/editPost.php tests/phpunit/tests/xmlrpc/mw/editPost.php
index e265b8898f..39a937d7d5 100644
|
|
|
class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { |
| 8 | 8 | function test_invalid_username_password() { |
| 9 | 9 | $post = array(); |
| 10 | 10 | $result = $this->myxmlrpcserver->mw_editPost( array( 1, 'username', 'password', $post ) ); |
| 11 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 11 | $this->assertIXRError( $result ); |
| 12 | 12 | $this->assertEquals( 403, $result->code ); |
| 13 | 13 | } |
| 14 | 14 | |
| … |
… |
class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { |
| 20 | 20 | $new_title = 'Post test (updated)'; |
| 21 | 21 | $post2 = array( 'title' => $new_title ); |
| 22 | 22 | $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post2 ) ); |
| 23 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 23 | $this->assertNotIXRError( $result ); |
| 24 | 24 | $this->assertTrue($result); |
| 25 | 25 | |
| 26 | 26 | $out = get_post( $post_id ); |
| … |
… |
class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { |
| 37 | 37 | $new_title = 'Post test (updated)'; |
| 38 | 38 | $post2 = array( 'title' => $new_title ); |
| 39 | 39 | $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'editor', 'editor', $post2 ) ); |
| 40 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 40 | $this->assertNotIXRError( $result ); |
| 41 | 41 | $this->assertTrue($result); |
| 42 | 42 | |
| 43 | 43 | $out = get_post( $post_id ); |
| … |
… |
class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { |
| 55 | 55 | $new_title = 'Post test (updated)'; |
| 56 | 56 | $post2 = array( 'title' => $new_title ); |
| 57 | 57 | $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post2 ) ); |
| 58 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 58 | $this->assertIXRError( $result ); |
| 59 | 59 | $this->assertEquals( 401, $result->code ); |
| 60 | 60 | |
| 61 | 61 | $out = get_post( $post_id ); |
| … |
… |
class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { |
| 72 | 72 | |
| 73 | 73 | $post2 = array( 'wp_author_id' => $author_id ); |
| 74 | 74 | $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'editor', 'editor', $post2 ) ); |
| 75 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 75 | $this->assertNotIXRError( $result ); |
| 76 | 76 | $this->assertTrue($result); |
| 77 | 77 | |
| 78 | 78 | $out = get_post( $post_id ); |
| … |
… |
class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { |
| 88 | 88 | |
| 89 | 89 | $post2 = array( 'wp_author_id' => $author_id ); |
| 90 | 90 | $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post2 ) ); |
| 91 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 91 | $this->assertIXRError( $result ); |
| 92 | 92 | $this->assertEquals( 401, $result->code ); |
| 93 | 93 | |
| 94 | 94 | $out = get_post( $post_id ); |
| … |
… |
class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { |
| 107 | 107 | |
| 108 | 108 | $post2 = array( 'wp_author_id' => $editor_id ); |
| 109 | 109 | $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'editor', 'editor', $post2 ) ); |
| 110 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 110 | $this->assertNotIXRError( $result ); |
| 111 | 111 | $this->assertTrue($result); |
| 112 | 112 | |
| 113 | 113 | $out = get_post( $post_id ); |
| … |
… |
class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { |
| 131 | 131 | // add post thumbnail to post that does not have one |
| 132 | 132 | $post2 = array( 'wp_post_thumbnail' => $attachment_id ); |
| 133 | 133 | $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'author', 'author', $post2 ) ); |
| 134 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 134 | $this->assertNotIXRError( $result ); |
| 135 | 135 | $this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) ); |
| 136 | 136 | |
| 137 | 137 | // edit the post without supplying a post_thumbnail and check that it didn't change |
| 138 | 138 | $post3 = array( 'post_content' => 'Updated post' ); |
| 139 | 139 | $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'author', 'author', $post3 ) ); |
| 140 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 140 | $this->assertNotIXRError( $result ); |
| 141 | 141 | $this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) ); |
| 142 | 142 | |
| 143 | 143 | // create another attachment |
| … |
… |
class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { |
| 146 | 146 | // change the post's post_thumbnail |
| 147 | 147 | $post4 = array( 'wp_post_thumbnail' => $attachment2_id ); |
| 148 | 148 | $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'author', 'author', $post4 ) ); |
| 149 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 149 | $this->assertNotIXRError( $result ); |
| 150 | 150 | $this->assertEquals( $attachment2_id, get_post_meta( $post_id, '_thumbnail_id', true ) ); |
| 151 | 151 | |
| 152 | 152 | // unset the post's post_thumbnail |
| 153 | 153 | $post5 = array( 'wp_post_thumbnail' => '' ); |
| 154 | 154 | $result = $this->myxmlrpcserver->mw_editPost( array($post_id, 'author', 'author', $post5 ) ); |
| 155 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 155 | $this->assertNotIXRError( $result ); |
| 156 | 156 | $this->assertEquals( '', get_post_meta( $post_id, '_thumbnail_id', true ) ); |
| 157 | 157 | |
| 158 | 158 | remove_theme_support( 'post-thumbnails' ); |
| … |
… |
class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { |
| 166 | 166 | |
| 167 | 167 | $post2 = array( 'title' => 'New Title', 'post_author' => $contributor_id ); |
| 168 | 168 | $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post2 ) ); |
| 169 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 169 | $this->assertNotIXRError( $result ); |
| 170 | 170 | $this->assertTrue($result); |
| 171 | 171 | |
| 172 | 172 | $out = get_post( $post_id ); |
| … |
… |
class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { |
| 174 | 174 | |
| 175 | 175 | $post3 = array( 'description' => 'New Content', 'post_author' => $contributor_id ); |
| 176 | 176 | $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post3 ) ); |
| 177 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 177 | $this->assertNotIXRError( $result ); |
| 178 | 178 | $this->assertTrue($result); |
| 179 | 179 | |
| 180 | 180 | $out = get_post( $post_id ); |
| … |
… |
class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { |
| 183 | 183 | |
| 184 | 184 | $post4 = array( 'mt_excerpt' => 'New Excerpt', 'post_author' => $contributor_id ); |
| 185 | 185 | $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post4 ) ); |
| 186 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 186 | $this->assertNotIXRError( $result ); |
| 187 | 187 | $this->assertTrue($result); |
| 188 | 188 | |
| 189 | 189 | $out = get_post( $post_id ); |
| … |
… |
class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { |
| 202 | 202 | $post_id = wp_insert_post( $post ); |
| 203 | 203 | |
| 204 | 204 | $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'editor', 'editor', array( 'sticky' => '1' ) ) ); |
| 205 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 205 | $this->assertNotIXRError( $result ); |
| 206 | 206 | $this->assertTrue( $result ); |
| 207 | 207 | } |
| 208 | 208 | |
| … |
… |
class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { |
| 215 | 215 | |
| 216 | 216 | $post2 = array( 'post_type' => 'page' ); |
| 217 | 217 | $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post2 ) ); |
| 218 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 218 | $this->assertIXRError( $result ); |
| 219 | 219 | $this->assertEquals( $result->code, 401 ); |
| 220 | 220 | } |
| 221 | 221 | |
-
diff --git tests/phpunit/tests/xmlrpc/mw/getPost.php tests/phpunit/tests/xmlrpc/mw/getPost.php
index 0d433d0804..924d6ff897 100644
|
|
|
class Tests_XMLRPC_mw_getPost extends WP_XMLRPC_UnitTestCase { |
| 19 | 19 | |
| 20 | 20 | function test_invalid_username_password() { |
| 21 | 21 | $result = $this->myxmlrpcserver->mw_getPost( array( self::$post_id, 'username', 'password' ) ); |
| 22 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 22 | $this->assertIXRError( $result ); |
| 23 | 23 | $this->assertEquals( 403, $result->code ); |
| 24 | 24 | } |
| 25 | 25 | |
| … |
… |
class Tests_XMLRPC_mw_getPost extends WP_XMLRPC_UnitTestCase { |
| 27 | 27 | $this->make_user_by_role( 'subscriber' ); |
| 28 | 28 | |
| 29 | 29 | $result = $this->myxmlrpcserver->mw_getPost( array( self::$post_id, 'subscriber', 'subscriber' ) ); |
| 30 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 30 | $this->assertIXRError( $result ); |
| 31 | 31 | $this->assertEquals( 401, $result->code ); |
| 32 | 32 | } |
| 33 | 33 | |
| … |
… |
class Tests_XMLRPC_mw_getPost extends WP_XMLRPC_UnitTestCase { |
| 36 | 36 | */ |
| 37 | 37 | function test_invalid_postid() { |
| 38 | 38 | $result = $this->myxmlrpcserver->mw_getPost( array( 9999, 'author', 'author' ) ); |
| 39 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 39 | $this->assertIXRError( $result ); |
| 40 | 40 | $this->assertEquals( 404, $result->code ); |
| 41 | 41 | } |
| 42 | 42 | |
| … |
… |
class Tests_XMLRPC_mw_getPost extends WP_XMLRPC_UnitTestCase { |
| 45 | 45 | |
| 46 | 46 | $fields = array( 'post' ); |
| 47 | 47 | $result = $this->myxmlrpcserver->mw_getPost( array( self::$post_id, 'author', 'author' ) ); |
| 48 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 48 | $this->assertNotIXRError( $result ); |
| 49 | 49 | |
| 50 | 50 | // Check data types |
| 51 | 51 | $this->assertInternalType( 'string', $result['userid'] ); |
| … |
… |
class Tests_XMLRPC_mw_getPost extends WP_XMLRPC_UnitTestCase { |
| 96 | 96 | |
| 97 | 97 | $fields = array( 'post' ); |
| 98 | 98 | $result = $this->myxmlrpcserver->mw_getPost( array( self::$post_id, 'author', 'author' ) ); |
| 99 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 99 | $this->assertNotIXRError( $result ); |
| 100 | 100 | |
| 101 | 101 | $this->assertInternalType( 'string', $result['wp_post_thumbnail'] ); |
| 102 | 102 | $this->assertStringMatchesFormat( '%d', $result['wp_post_thumbnail'] ); |
| … |
… |
class Tests_XMLRPC_mw_getPost extends WP_XMLRPC_UnitTestCase { |
| 108 | 108 | function test_date() { |
| 109 | 109 | $fields = array( 'post' ); |
| 110 | 110 | $result = $this->myxmlrpcserver->mw_getPost( array( self::$post_id, 'author', 'author' ) ); |
| 111 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 111 | $this->assertNotIXRError( $result ); |
| 112 | 112 | |
| 113 | 113 | $this->assertInstanceOf( 'IXR_Date', $result['dateCreated'] ); |
| 114 | 114 | $this->assertInstanceOf( 'IXR_Date', $result['date_created_gmt'] ); |
-
diff --git tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php
index a3b7cd4074..8ab76274b4 100644
|
|
|
class Tests_XMLRPC_mw_getRecentPosts extends WP_XMLRPC_UnitTestCase { |
| 20 | 20 | |
| 21 | 21 | function test_invalid_username_password() { |
| 22 | 22 | $result = $this->myxmlrpcserver->mw_getRecentPosts( array( 1, 'username', 'password' ) ); |
| 23 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 23 | $this->assertIXRError( $result ); |
| 24 | 24 | $this->assertEquals( 403, $result->code ); |
| 25 | 25 | } |
| 26 | 26 | |
| … |
… |
class Tests_XMLRPC_mw_getRecentPosts extends WP_XMLRPC_UnitTestCase { |
| 31 | 31 | $this->make_user_by_role( 'subscriber' ); |
| 32 | 32 | |
| 33 | 33 | $result = $this->myxmlrpcserver->mw_getRecentPosts( array( 1, 'subscriber', 'subscriber' ) ); |
| 34 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 34 | $this->assertIXRError( $result ); |
| 35 | 35 | $this->assertEquals( 401, $result->code ); |
| 36 | 36 | } |
| 37 | 37 | |
| … |
… |
class Tests_XMLRPC_mw_getRecentPosts extends WP_XMLRPC_UnitTestCase { |
| 39 | 39 | wp_delete_post( self::$post_id, true ); |
| 40 | 40 | |
| 41 | 41 | $result = $this->myxmlrpcserver->mw_getRecentPosts( array( 1, 'author', 'author' ) ); |
| 42 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 42 | $this->assertNotIXRError( $result ); |
| 43 | 43 | $this->assertEquals( 0, count( $result ) ); |
| 44 | 44 | } |
| 45 | 45 | |
| … |
… |
class Tests_XMLRPC_mw_getRecentPosts extends WP_XMLRPC_UnitTestCase { |
| 48 | 48 | |
| 49 | 49 | $fields = array( 'post' ); |
| 50 | 50 | $results = $this->myxmlrpcserver->mw_getRecentPosts( array( 1, 'author', 'author' ) ); |
| 51 | | $this->assertNotInstanceOf( 'IXR_Error', $results ); |
| | 51 | $this->assertNotIXRError( $results ); |
| 52 | 52 | |
| 53 | 53 | foreach( $results as $result ) { |
| 54 | 54 | $post = get_post( $result['postid'] ); |
| … |
… |
class Tests_XMLRPC_mw_getRecentPosts extends WP_XMLRPC_UnitTestCase { |
| 99 | 99 | set_post_thumbnail( self::$post_id, $attachment_id ); |
| 100 | 100 | |
| 101 | 101 | $results = $this->myxmlrpcserver->mw_getRecentPosts( array( self::$post_id, 'author', 'author' ) ); |
| 102 | | $this->assertNotInstanceOf( 'IXR_Error', $results ); |
| | 102 | $this->assertNotIXRError( $results ); |
| 103 | 103 | |
| 104 | 104 | foreach( $results as $result ) { |
| 105 | 105 | $this->assertInternalType( 'string', $result['wp_post_thumbnail'] ); |
| … |
… |
class Tests_XMLRPC_mw_getRecentPosts extends WP_XMLRPC_UnitTestCase { |
| 119 | 119 | $this->make_user_by_role( 'editor' ); |
| 120 | 120 | |
| 121 | 121 | $results = $this->myxmlrpcserver->mw_getRecentPosts( array( 1, 'editor', 'editor' ) ); |
| 122 | | $this->assertNotInstanceOf( 'IXR_Error', $results ); |
| | 122 | $this->assertNotIXRError( $results ); |
| 123 | 123 | |
| 124 | 124 | foreach( $results as $result ) { |
| 125 | 125 | $post = get_post( $result['postid'] ); |
-
diff --git tests/phpunit/tests/xmlrpc/mw/newPost.php tests/phpunit/tests/xmlrpc/mw/newPost.php
index 01316e62d5..06aaafc77f 100644
|
|
|
class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { |
| 8 | 8 | function test_invalid_username_password() { |
| 9 | 9 | $post = array(); |
| 10 | 10 | $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'username', 'password', $post ) ); |
| 11 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 11 | $this->assertIXRError( $result ); |
| 12 | 12 | $this->assertEquals( 403, $result->code ); |
| 13 | 13 | } |
| 14 | 14 | |
| … |
… |
class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { |
| 17 | 17 | |
| 18 | 18 | $post = array(); |
| 19 | 19 | $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'subscriber', 'subscriber', $post ) ); |
| 20 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 20 | $this->assertIXRError( $result ); |
| 21 | 21 | $this->assertEquals( 401, $result->code ); |
| 22 | 22 | } |
| 23 | 23 | |
| … |
… |
class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { |
| 26 | 26 | |
| 27 | 27 | $post = array(); |
| 28 | 28 | $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) ); |
| 29 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 29 | $this->assertIXRError( $result ); |
| 30 | 30 | $this->assertEquals( 500, $result->code ); |
| 31 | 31 | $this->assertEquals( 'Content, title, and excerpt are empty.', $result->message ); |
| 32 | 32 | } |
| … |
… |
class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { |
| 36 | 36 | |
| 37 | 37 | $post = array( 'title' => 'Test' ); |
| 38 | 38 | $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) ); |
| 39 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 39 | $this->assertNotIXRError( $result ); |
| 40 | 40 | $this->assertStringMatchesFormat( '%d', $result ); |
| 41 | 41 | } |
| 42 | 42 | |
| … |
… |
class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { |
| 45 | 45 | |
| 46 | 46 | $post = array( 'title' => 'Test', 'ID' => 103948 ); |
| 47 | 47 | $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) ); |
| 48 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 48 | $this->assertNotIXRError( $result ); |
| 49 | 49 | $this->assertNotEquals( '103948', $result ); |
| 50 | 50 | } |
| 51 | 51 | |
| … |
… |
class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { |
| 54 | 54 | |
| 55 | 55 | $post = array( 'title' => 'Test', 'post_status' => 'publish' ); |
| 56 | 56 | $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) ); |
| 57 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 57 | $this->assertNotIXRError( $result ); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | function test_incapable_publish() { |
| … |
… |
class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { |
| 62 | 62 | |
| 63 | 63 | $post = array( 'title' => 'Test', 'post_status' => 'publish' ); |
| 64 | 64 | $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'contributor', 'contributor', $post ) ); |
| 65 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 65 | $this->assertIXRError( $result ); |
| 66 | 66 | $this->assertEquals( 401, $result->code ); |
| 67 | 67 | } |
| 68 | 68 | |
| … |
… |
class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { |
| 72 | 72 | |
| 73 | 73 | $post = array( 'title' => 'Test', 'wp_author_id' => $other_author_id ); |
| 74 | 74 | $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'editor', 'editor', $post ) ); |
| 75 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 75 | $this->assertNotIXRError( $result ); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | function test_incapable_other_author() { |
| … |
… |
class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { |
| 81 | 81 | |
| 82 | 82 | $post = array( 'title' => 'Test', 'wp_author_id' => $other_author_id ); |
| 83 | 83 | $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'contributor', 'contributor', $post ) ); |
| 84 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 84 | $this->assertIXRError( $result ); |
| 85 | 85 | $this->assertEquals( 401, $result->code ); |
| 86 | 86 | } |
| 87 | 87 | |
| … |
… |
class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { |
| 93 | 93 | |
| 94 | 94 | $post = array( 'title' => 'Test', 'wp_author_id' => 99999999 ); |
| 95 | 95 | $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'editor', 'editor', $post ) ); |
| 96 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 96 | $this->assertIXRError( $result ); |
| 97 | 97 | $this->assertEquals( 404, $result->code ); |
| 98 | 98 | } |
| 99 | 99 | |
| … |
… |
class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { |
| 102 | 102 | |
| 103 | 103 | $post = array( 'title' => 'Test' ); |
| 104 | 104 | $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) ); |
| 105 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 105 | $this->assertNotIXRError( $result ); |
| 106 | 106 | $this->assertStringMatchesFormat( '%d', $result ); |
| 107 | 107 | |
| 108 | 108 | $out = get_post( $result ); |
| … |
… |
class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { |
| 121 | 121 | |
| 122 | 122 | $post = array( 'title' => 'Post Thumbnail Test', 'wp_post_thumbnail' => $attachment_id ); |
| 123 | 123 | $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) ); |
| 124 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 124 | $this->assertNotIXRError( $result ); |
| 125 | 125 | $this->assertEquals( $attachment_id, get_post_meta( $result, '_thumbnail_id', true ) ); |
| 126 | 126 | |
| 127 | 127 | remove_theme_support( 'post-thumbnails' ); |
| … |
… |
class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { |
| 132 | 132 | |
| 133 | 133 | $post = array( 'title' => 'Test', 'post_type' => 'page' ); |
| 134 | 134 | $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) ); |
| 135 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 135 | $this->assertIXRError( $result ); |
| 136 | 136 | $this->assertEquals( 401, $result->code ); |
| 137 | 137 | } |
| 138 | 138 | |
| … |
… |
class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { |
| 141 | 141 | |
| 142 | 142 | $post = array( 'title' => 'Test', 'post_type' => 'page' ); |
| 143 | 143 | $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'editor', 'editor', $post ) ); |
| 144 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 144 | $this->assertNotIXRError( $result ); |
| 145 | 145 | $this->assertStringMatchesFormat( '%d', $result ); |
| 146 | 146 | |
| 147 | 147 | $out = get_post( $result ); |
| … |
… |
class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { |
| 162 | 162 | 'post_status' => 'draft' |
| 163 | 163 | ); |
| 164 | 164 | $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'editor', 'editor', $post ) ); |
| 165 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 165 | $this->assertNotIXRError( $result ); |
| 166 | 166 | $this->assertStringMatchesFormat( '%d', $result ); |
| 167 | 167 | |
| 168 | 168 | $out = get_post( $result ); |
-
diff --git tests/phpunit/tests/xmlrpc/wp/deletePost.php tests/phpunit/tests/xmlrpc/wp/deletePost.php
index e7284a7cde..d2a5bc6460 100644
|
|
|
class Tests_XMLRPC_wp_deletePost extends WP_XMLRPC_UnitTestCase { |
| 7 | 7 | |
| 8 | 8 | function test_invalid_username_password() { |
| 9 | 9 | $result = $this->myxmlrpcserver->wp_deletePost( array( 1, 'username', 'password', 0 ) ); |
| 10 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 10 | $this->assertIXRError( $result ); |
| 11 | 11 | $this->assertEquals( 403, $result->code ); |
| 12 | 12 | } |
| 13 | 13 | |
| … |
… |
class Tests_XMLRPC_wp_deletePost extends WP_XMLRPC_UnitTestCase { |
| 15 | 15 | $this->make_user_by_role( 'editor' ); |
| 16 | 16 | |
| 17 | 17 | $result = $this->myxmlrpcserver->wp_deletePost( array( 1, 'editor', 'editor', 340982340 ) ); |
| 18 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 18 | $this->assertIXRError( $result ); |
| 19 | 19 | $this->assertEquals( 404, $result->code ); |
| 20 | 20 | } |
| 21 | 21 | |
| … |
… |
class Tests_XMLRPC_wp_deletePost extends WP_XMLRPC_UnitTestCase { |
| 24 | 24 | $post_id = self::factory()->post->create(); |
| 25 | 25 | |
| 26 | 26 | $result = $this->myxmlrpcserver->wp_deletePost( array( 1, 'subscriber', 'subscriber', $post_id ) ); |
| 27 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 27 | $this->assertIXRError( $result ); |
| 28 | 28 | $this->assertEquals( 401, $result->code ); |
| 29 | 29 | } |
| 30 | 30 | |
| … |
… |
class Tests_XMLRPC_wp_deletePost extends WP_XMLRPC_UnitTestCase { |
| 33 | 33 | $post_id = self::factory()->post->create(); |
| 34 | 34 | |
| 35 | 35 | $result = $this->myxmlrpcserver->wp_deletePost( array( 1, 'editor', 'editor', $post_id ) ); |
| 36 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 36 | $this->assertNotIXRError( $result ); |
| 37 | 37 | $this->assertTrue( $result ); |
| 38 | 38 | |
| 39 | 39 | $post = get_post( $post_id ); |
-
diff --git tests/phpunit/tests/xmlrpc/wp/deleteTerm.php tests/phpunit/tests/xmlrpc/wp/deleteTerm.php
index ee95c6ae76..94e25c9c3d 100644
|
|
|
class Tests_XMLRPC_wp_deleteTerm extends WP_XMLRPC_UnitTestCase { |
| 14 | 14 | |
| 15 | 15 | function test_invalid_username_password() { |
| 16 | 16 | $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'username', 'password', 'category', 0 ) ); |
| 17 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 17 | $this->assertIXRError( $result ); |
| 18 | 18 | $this->assertEquals( 403, $result->code ); |
| 19 | 19 | } |
| 20 | 20 | |
| … |
… |
class Tests_XMLRPC_wp_deleteTerm extends WP_XMLRPC_UnitTestCase { |
| 22 | 22 | $this->make_user_by_role( 'subscriber' ); |
| 23 | 23 | |
| 24 | 24 | $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'subscriber', 'subscriber', '', 0 ) ); |
| 25 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 25 | $this->assertIXRError( $result ); |
| 26 | 26 | $this->assertEquals( 403, $result->code ); |
| 27 | 27 | $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message ); |
| 28 | 28 | } |
| … |
… |
class Tests_XMLRPC_wp_deleteTerm extends WP_XMLRPC_UnitTestCase { |
| 31 | 31 | $this->make_user_by_role( 'subscriber' ); |
| 32 | 32 | |
| 33 | 33 | $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'subscriber', 'subscriber', 'not_existing', 0 ) ); |
| 34 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 34 | $this->assertIXRError( $result ); |
| 35 | 35 | $this->assertEquals( 403, $result->code ); |
| 36 | 36 | $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message ); |
| 37 | 37 | } |
| … |
… |
class Tests_XMLRPC_wp_deleteTerm extends WP_XMLRPC_UnitTestCase { |
| 40 | 40 | $this->make_user_by_role( 'subscriber' ); |
| 41 | 41 | |
| 42 | 42 | $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'subscriber', 'subscriber', 'category', self::$term_id ) ); |
| 43 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 43 | $this->assertIXRError( $result ); |
| 44 | 44 | $this->assertEquals( 401, $result->code ); |
| 45 | 45 | $this->assertEquals( __( 'Sorry, you are not allowed to delete this term.' ), $result->message ); |
| 46 | 46 | } |
| … |
… |
class Tests_XMLRPC_wp_deleteTerm extends WP_XMLRPC_UnitTestCase { |
| 49 | 49 | $this->make_user_by_role( 'editor' ); |
| 50 | 50 | |
| 51 | 51 | $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'editor', 'editor', 'category', '' ) ); |
| 52 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 52 | $this->assertIXRError( $result ); |
| 53 | 53 | $this->assertEquals( 500, $result->code ); |
| 54 | 54 | $this->assertEquals( __('Empty Term'), $result->message ); |
| 55 | 55 | } |
| … |
… |
class Tests_XMLRPC_wp_deleteTerm extends WP_XMLRPC_UnitTestCase { |
| 58 | 58 | $this->make_user_by_role( 'editor' ); |
| 59 | 59 | |
| 60 | 60 | $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'editor', 'editor', 'category', 9999 ) ); |
| 61 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 61 | $this->assertIXRError( $result ); |
| 62 | 62 | $this->assertEquals( 404, $result->code ); |
| 63 | 63 | $this->assertEquals( __( 'Invalid term ID.' ), $result->message ); |
| 64 | 64 | } |
| … |
… |
class Tests_XMLRPC_wp_deleteTerm extends WP_XMLRPC_UnitTestCase { |
| 67 | 67 | $this->make_user_by_role( 'editor' ); |
| 68 | 68 | |
| 69 | 69 | $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'editor', 'editor', 'category', self::$term_id ) ); |
| 70 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 70 | $this->assertNotIXRError( $result ); |
| 71 | 71 | $this->assertInternalType( 'boolean', $result ); |
| 72 | 72 | } |
| 73 | 73 | } |
-
diff --git tests/phpunit/tests/xmlrpc/wp/editComment.php tests/phpunit/tests/xmlrpc/wp/editComment.php
index b43beb6ee0..fcb3bb57f7 100644
|
|
|
class Tests_XMLRPC_wp_editComment extends WP_XMLRPC_UnitTestCase { |
| 22 | 22 | $result = $this->myxmlrpcserver->wp_editComment( array( 1, 'author', 'author', $comment_id, array( |
| 23 | 23 | 'status' => 'hold' |
| 24 | 24 | ) ) ); |
| 25 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 25 | $this->assertNotIXRError( $result ); |
| 26 | 26 | $this->assertTrue( $result ); |
| 27 | 27 | } |
| 28 | 28 | |
| … |
… |
class Tests_XMLRPC_wp_editComment extends WP_XMLRPC_UnitTestCase { |
| 42 | 42 | ) ); |
| 43 | 43 | |
| 44 | 44 | $result = $this->myxmlrpcserver->wp_editComment( array( 1, 'author', 'author', $comment_id, array( 'status' => 'hold' ) ) ); |
| 45 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 45 | $this->assertIXRError( $result ); |
| 46 | 46 | $this->assertEquals( 403, $result->code ); |
| 47 | 47 | $this->assertEquals( __( 'Sorry, you are not allowed to moderate or edit this comment.' ), $result->message ); |
| 48 | 48 | } |
-
diff --git tests/phpunit/tests/xmlrpc/wp/editPost.php tests/phpunit/tests/xmlrpc/wp/editPost.php
index 373d45870a..55f5be99a7 100644
|
|
|
class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { |
| 7 | 7 | |
| 8 | 8 | function test_invalid_username_password() { |
| 9 | 9 | $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'username', 'password', 0, array() ) ); |
| 10 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 10 | $this->assertIXRError( $result ); |
| 11 | 11 | $this->assertEquals( 403, $result->code ); |
| 12 | 12 | } |
| 13 | 13 | |
| … |
… |
class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { |
| 20 | 20 | $new_title = 'Post test (updated)'; |
| 21 | 21 | $post2 = array( 'post_title' => $new_title ); |
| 22 | 22 | $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'contributor', 'contributor', $post_id, $post2 ) ); |
| 23 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 23 | $this->assertNotIXRError( $result ); |
| 24 | 24 | $this->assertTrue($result); |
| 25 | 25 | |
| 26 | 26 | $out = get_post( $post_id ); |
| … |
… |
class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { |
| 37 | 37 | $new_title = 'Post test (updated)'; |
| 38 | 38 | $post2 = array( 'post_title' => $new_title ); |
| 39 | 39 | $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $post2 ) ); |
| 40 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 40 | $this->assertNotIXRError( $result ); |
| 41 | 41 | $this->assertTrue($result); |
| 42 | 42 | |
| 43 | 43 | $out = get_post( $post_id ); |
| … |
… |
class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { |
| 55 | 55 | $new_title = 'Post test (updated)'; |
| 56 | 56 | $post2 = array( 'post_title' => $new_title ); |
| 57 | 57 | $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'contributor', 'contributor', $post_id, $post2 ) ); |
| 58 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 58 | $this->assertIXRError( $result ); |
| 59 | 59 | $this->assertEquals( 401, $result->code ); |
| 60 | 60 | |
| 61 | 61 | $out = get_post( $post_id ); |
| … |
… |
class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { |
| 72 | 72 | |
| 73 | 73 | $post2 = array( 'post_author' => $author_id ); |
| 74 | 74 | $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $post2 ) ); |
| 75 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 75 | $this->assertNotIXRError( $result ); |
| 76 | 76 | $this->assertTrue($result); |
| 77 | 77 | |
| 78 | 78 | $out = get_post( $post_id ); |
| … |
… |
class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { |
| 88 | 88 | |
| 89 | 89 | $post2 = array( 'post_author' => $author_id ); |
| 90 | 90 | $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'contributor', 'contributor', $post_id, $post2 ) ); |
| 91 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 91 | $this->assertIXRError( $result ); |
| 92 | 92 | $this->assertEquals( 401, $result->code ); |
| 93 | 93 | |
| 94 | 94 | $out = get_post( $post_id ); |
| … |
… |
class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { |
| 107 | 107 | |
| 108 | 108 | $post2 = array( 'post_author' => $editor_id ); |
| 109 | 109 | $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $post2 ) ); |
| 110 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 110 | $this->assertNotIXRError( $result ); |
| 111 | 111 | $this->assertTrue($result); |
| 112 | 112 | |
| 113 | 113 | $out = get_post( $post_id ); |
| … |
… |
class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { |
| 131 | 131 | // add post thumbnail to post that does not have one |
| 132 | 132 | $post2 = array( 'post_thumbnail' => $attachment_id ); |
| 133 | 133 | $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'author', 'author', $post_id, $post2 ) ); |
| 134 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 134 | $this->assertNotIXRError( $result ); |
| 135 | 135 | $this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) ); |
| 136 | 136 | |
| 137 | 137 | // fetch the post to verify that it appears |
| 138 | 138 | $result = $this->myxmlrpcserver->wp_getPost( array( 1, 'author', 'author', $post_id ) ); |
| 139 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 139 | $this->assertNotIXRError( $result ); |
| 140 | 140 | $this->assertArrayHasKey( 'post_thumbnail', $result ); |
| 141 | 141 | $this->assertInternalType( 'array', $result['post_thumbnail'] ); |
| 142 | 142 | $this->assertEquals( $attachment_id, $result['post_thumbnail']['attachment_id'] ); |
| … |
… |
class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { |
| 144 | 144 | // edit the post without supplying a post_thumbnail and check that it didn't change |
| 145 | 145 | $post3 = array( 'post_content' => 'Updated post' ); |
| 146 | 146 | $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'author', 'author', $post_id, $post3 ) ); |
| 147 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 147 | $this->assertNotIXRError( $result ); |
| 148 | 148 | $this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) ); |
| 149 | 149 | |
| 150 | 150 | // create another attachment |
| … |
… |
class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { |
| 153 | 153 | // change the post's post_thumbnail |
| 154 | 154 | $post4 = array( 'post_thumbnail' => $attachment2_id ); |
| 155 | 155 | $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'author', 'author', $post_id, $post4 ) ); |
| 156 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 156 | $this->assertNotIXRError( $result ); |
| 157 | 157 | $this->assertEquals( $attachment2_id, get_post_meta( $post_id, '_thumbnail_id', true ) ); |
| 158 | 158 | |
| 159 | 159 | // unset the post's post_thumbnail |
| 160 | 160 | $post5 = array( 'post_thumbnail' => '' ); |
| 161 | 161 | $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'author', 'author', $post_id, $post5 ) ); |
| 162 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 162 | $this->assertNotIXRError( $result ); |
| 163 | 163 | $this->assertEquals( '', get_post_meta( $post_id, '_thumbnail_id', true ) ); |
| 164 | 164 | |
| 165 | 165 | // use invalid ID |
| 166 | 166 | $post6 = array( 'post_thumbnail' => 398420983409 ); |
| 167 | 167 | $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'author', 'author', $post_id, $post6 ) ); |
| 168 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 168 | $this->assertIXRError( $result ); |
| 169 | 169 | $this->assertEquals( 404, $result->code ); |
| 170 | 170 | |
| 171 | 171 | remove_theme_support( 'post-thumbnails' ); |
| … |
… |
class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { |
| 191 | 191 | ); |
| 192 | 192 | |
| 193 | 193 | $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'contributor', 'contributor', $post_id, $post2 ) ); |
| 194 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 194 | $this->assertNotIXRError( $result ); |
| 195 | 195 | $this->assertTrue($result); |
| 196 | 196 | |
| 197 | 197 | $out = get_post( $post_id ); |
| … |
… |
class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { |
| 213 | 213 | |
| 214 | 214 | $post2 = array( 'sticky' => false ); |
| 215 | 215 | $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $post2 ) ); |
| 216 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 216 | $this->assertNotIXRError( $result ); |
| 217 | 217 | $this->assertFalse( is_sticky( $post_id ) ); |
| 218 | 218 | } |
| 219 | 219 | |
| … |
… |
class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { |
| 225 | 225 | |
| 226 | 226 | $post2 = array( 'post_password' => 'foobar', 'sticky' => false ); |
| 227 | 227 | $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $post2 ) ); |
| 228 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 228 | $this->assertNotIXRError( $result ); |
| 229 | 229 | $this->assertFalse( is_sticky( $post_id ) ); |
| 230 | 230 | } |
| 231 | 231 | |
| … |
… |
class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { |
| 245 | 245 | // Modify the day old post. In this case, we think it was last modified yesterday. |
| 246 | 246 | $struct = array( 'post_content' => 'First edit', 'if_not_modified_since' => new IXR_Date( $yesterday ) ); |
| 247 | 247 | $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $struct ) ); |
| 248 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 248 | $this->assertNotIXRError( $result ); |
| 249 | 249 | |
| 250 | 250 | // Make sure the edit went through. |
| 251 | 251 | $this->assertEquals( 'First edit', get_post( $post_id )->post_content ); |
| … |
… |
class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { |
| 253 | 253 | // Modify it again. We think it was last modified yesterday, but we actually just modified it above. |
| 254 | 254 | $struct = array( 'post_content' => 'Second edit', 'if_not_modified_since' => new IXR_Date( $yesterday ) ); |
| 255 | 255 | $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $struct ) ); |
| 256 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 256 | $this->assertIXRError( $result ); |
| 257 | 257 | $this->assertEquals( 409, $result->code ); |
| 258 | 258 | |
| 259 | 259 | // Make sure the edit did not go through. |
| … |
… |
class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { |
| 273 | 273 | |
| 274 | 274 | $struct = array( 'post_content' => 'First edit' ); |
| 275 | 275 | $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $struct ) ); |
| 276 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 276 | $this->assertNotIXRError( $result ); |
| 277 | 277 | |
| 278 | 278 | // Make sure that the post status is still inherit |
| 279 | 279 | $this->assertEquals( 'inherit', get_post( $post_id )->post_status ); |
| … |
… |
class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { |
| 290 | 290 | |
| 291 | 291 | $struct = array( 'post_status' => 'doesnt_exists' ); |
| 292 | 292 | $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $struct ) ); |
| 293 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 293 | $this->assertNotIXRError( $result ); |
| 294 | 294 | |
| 295 | 295 | // Make sure that the post status is still inherit |
| 296 | 296 | $this->assertEquals( 'draft', get_post( $post_id )->post_status ); |
| … |
… |
class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { |
| 309 | 309 | $this->assertContains( $term_id, $term_ids ); |
| 310 | 310 | |
| 311 | 311 | $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, array( 'ID' => $post_id, 'post_title' => 'Updated' ) ) ); |
| 312 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 312 | $this->assertNotIXRError( $result ); |
| 313 | 313 | $this->assertEquals( 'Updated', get_post( $post_id )->post_title ); |
| 314 | 314 | |
| 315 | 315 | $term_ids = wp_list_pluck( get_the_category( $post_id ), 'term_id' ); |
| … |
… |
class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { |
| 336 | 336 | ) |
| 337 | 337 | ); |
| 338 | 338 | $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $new_post_content ) ); |
| 339 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 339 | $this->assertNotIXRError( $result ); |
| 340 | 340 | $this->assertEquals( 'Updated', get_post( $post_id )->post_title ); |
| 341 | 341 | |
| 342 | 342 | $term_ids = wp_list_pluck( get_the_category( $post_id ), 'term_id' ); |
-
diff --git tests/phpunit/tests/xmlrpc/wp/editProfile.php tests/phpunit/tests/xmlrpc/wp/editProfile.php
index 525f6a5652..6e3ced529a 100644
|
|
|
class Tests_XMLRPC_wp_editProfile extends WP_XMLRPC_UnitTestCase { |
| 8 | 8 | |
| 9 | 9 | function test_invalid_username_password() { |
| 10 | 10 | $result = $this->myxmlrpcserver->wp_editProfile( array( 1, 'username', 'password', array() ) ); |
| 11 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 11 | $this->assertIXRError( $result ); |
| 12 | 12 | $this->assertEquals( 403, $result->code ); |
| 13 | 13 | } |
| 14 | 14 | |
| … |
… |
class Tests_XMLRPC_wp_editProfile extends WP_XMLRPC_UnitTestCase { |
| 25 | 25 | 'bio' => rand_str(200) |
| 26 | 26 | ); |
| 27 | 27 | $result = $this->myxmlrpcserver->wp_editProfile( array( 1, 'subscriber', 'subscriber', $new_data ) ); |
| 28 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 28 | $this->assertNotIXRError( $result ); |
| 29 | 29 | $this->assertTrue( $result ); |
| 30 | 30 | |
| 31 | 31 | // verify that the new values were stored |
| … |
… |
class Tests_XMLRPC_wp_editProfile extends WP_XMLRPC_UnitTestCase { |
| 45 | 45 | $new_data = array( 'password' => $new_pass ); |
| 46 | 46 | |
| 47 | 47 | $result = $this->myxmlrpcserver->wp_editProfile( array( 1, 'author', 'author', $new_data ) ); |
| 48 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 48 | $this->assertNotIXRError( $result ); |
| 49 | 49 | $this->assertTrue( $result ); |
| 50 | 50 | |
| 51 | 51 | $auth_old = wp_authenticate( 'author', 'author' ); |
| … |
… |
class Tests_XMLRPC_wp_editProfile extends WP_XMLRPC_UnitTestCase { |
| 60 | 60 | $new_data = array( 'email' => $new_email ); |
| 61 | 61 | |
| 62 | 62 | $result = $this->myxmlrpcserver->wp_editProfile( array( 1, 'editor', 'editor', $new_data ) ); |
| 63 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 63 | $this->assertNotIXRError( $result ); |
| 64 | 64 | $this->assertTrue( $result ); |
| 65 | 65 | |
| 66 | 66 | $user_data = get_userdata( $editor_id ); |
-
diff --git tests/phpunit/tests/xmlrpc/wp/editTerm.php tests/phpunit/tests/xmlrpc/wp/editTerm.php
index b3f22d2a24..1e62de9d1f 100644
|
|
|
class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { |
| 22 | 22 | |
| 23 | 23 | function test_invalid_username_password() { |
| 24 | 24 | $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'username', 'password', 'category', 1 ) ); |
| 25 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 25 | $this->assertIXRError( $result ); |
| 26 | 26 | $this->assertEquals( 403, $result->code ); |
| 27 | 27 | } |
| 28 | 28 | |
| … |
… |
class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { |
| 30 | 30 | $this->make_user_by_role( 'subscriber' ); |
| 31 | 31 | |
| 32 | 32 | $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'subscriber', 'subscriber', '', array( 'taxonomy' => '' ) ) ); |
| 33 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 33 | $this->assertIXRError( $result ); |
| 34 | 34 | $this->assertEquals( 403, $result->code ); |
| 35 | 35 | $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message ); |
| 36 | 36 | } |
| … |
… |
class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { |
| 39 | 39 | $this->make_user_by_role( 'subscriber' ); |
| 40 | 40 | |
| 41 | 41 | $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'subscriber', 'subscriber', self::$parent_term, array( 'taxonomy' => 'not_existing' ) ) ); |
| 42 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 42 | $this->assertIXRError( $result ); |
| 43 | 43 | $this->assertEquals( 403, $result->code ); |
| 44 | 44 | $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message ); |
| 45 | 45 | } |
| … |
… |
class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { |
| 48 | 48 | $this->make_user_by_role( 'subscriber' ); |
| 49 | 49 | |
| 50 | 50 | $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'subscriber', 'subscriber', self::$parent_term, array( 'taxonomy' => 'category' ) ) ); |
| 51 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 51 | $this->assertIXRError( $result ); |
| 52 | 52 | $this->assertEquals( 401, $result->code ); |
| 53 | 53 | $this->assertEquals( __( 'Sorry, you are not allowed to edit this term.' ), $result->message ); |
| 54 | 54 | } |
| … |
… |
class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { |
| 57 | 57 | $this->make_user_by_role( 'editor' ); |
| 58 | 58 | |
| 59 | 59 | $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', 9999, array( 'taxonomy' => 'category' ) ) ); |
| 60 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 60 | $this->assertIXRError( $result ); |
| 61 | 61 | $this->assertEquals( 404, $result->code ); |
| 62 | 62 | $this->assertEquals( __( 'Invalid term ID.' ), $result->message ); |
| 63 | 63 | } |
| … |
… |
class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { |
| 66 | 66 | $this->make_user_by_role( 'editor' ); |
| 67 | 67 | |
| 68 | 68 | $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', '', array( 'taxonomy' => 'category' ) ) ); |
| 69 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 69 | $this->assertIXRError( $result ); |
| 70 | 70 | $this->assertEquals( 500, $result->code ); |
| 71 | 71 | $this->assertEquals( __('Empty Term'), $result->message ); |
| 72 | 72 | } |
| … |
… |
class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { |
| 75 | 75 | $this->make_user_by_role( 'editor' ); |
| 76 | 76 | |
| 77 | 77 | $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$parent_term, array( 'taxonomy' => 'category', 'name' => '' ) ) ); |
| 78 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 78 | $this->assertIXRError( $result ); |
| 79 | 79 | $this->assertEquals( 403, $result->code ); |
| 80 | 80 | $this->assertEquals( __( 'The term name cannot be empty.' ), $result->message ); |
| 81 | 81 | } |
| … |
… |
class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { |
| 84 | 84 | $this->make_user_by_role( 'editor' ); |
| 85 | 85 | |
| 86 | 86 | $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$post_tag, array( 'taxonomy' => 'post_tag', 'parent' => self::$parent_term ) ) ); |
| 87 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 87 | $this->assertIXRError( $result ); |
| 88 | 88 | $this->assertEquals( 403, $result->code ); |
| 89 | 89 | $this->assertEquals( __( "This taxonomy is not hierarchical so you can't set a parent." ), $result->message ); |
| 90 | 90 | } |
| … |
… |
class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { |
| 93 | 93 | $this->make_user_by_role( 'editor' ); |
| 94 | 94 | |
| 95 | 95 | $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'parent' => '', 'name' => 'test' ) ) ); |
| 96 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 96 | $this->assertNotIXRError( $result ); |
| 97 | 97 | $this->assertTrue( $result ); |
| 98 | 98 | } |
| 99 | 99 | |
| … |
… |
class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { |
| 102 | 102 | |
| 103 | 103 | $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'parent' => NULL, 'name' => 'test' ) ) ); |
| 104 | 104 | |
| 105 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 105 | $this->assertNotIXRError( $result ); |
| 106 | 106 | $this->assertInternalType( 'boolean', $result ); |
| 107 | 107 | |
| 108 | 108 | $term = get_term( self::$child_term, 'category' ); |
| … |
… |
class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { |
| 113 | 113 | $this->make_user_by_role( 'editor' ); |
| 114 | 114 | |
| 115 | 115 | $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'parent' => 'dasda', 'name' => 'test' ) ) ); |
| 116 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 116 | $this->assertIXRError( $result ); |
| 117 | 117 | $this->assertEquals( 500, $result->code ); |
| 118 | 118 | } |
| 119 | 119 | |
| … |
… |
class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { |
| 121 | 121 | $this->make_user_by_role( 'editor' ); |
| 122 | 122 | |
| 123 | 123 | $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'parent' => 9999, 'name' => 'test' ) ) ); |
| 124 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 124 | $this->assertIXRError( $result ); |
| 125 | 125 | $this->assertEquals( 403, $result->code ); |
| 126 | 126 | $this->assertEquals( __( 'Parent term does not exist.' ), $result->message ); |
| 127 | 127 | } |
| … |
… |
class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { |
| 131 | 131 | |
| 132 | 132 | $parent_term = get_term_by( 'id', self::$parent_term, 'category' ); |
| 133 | 133 | $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'slug' => $parent_term->slug ) ) ); |
| 134 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 134 | $this->assertIXRError( $result ); |
| 135 | 135 | $this->assertEquals( 500, $result->code ); |
| 136 | 136 | $this->assertEquals( htmlspecialchars( sprintf( __('The slug “%s” is already in use by another term'), $parent_term->slug ) ), $result->message ); |
| 137 | 137 | } |
| … |
… |
class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { |
| 142 | 142 | $fields = array( 'taxonomy' => 'category', 'name' => 'Child 2', 'parent' => self::$parent_term, 'description' => 'Child term', 'slug' => 'child_2' ); |
| 143 | 143 | $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, $fields ) ); |
| 144 | 144 | |
| 145 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 145 | $this->assertNotIXRError( $result ); |
| 146 | 146 | $this->assertInternalType( 'boolean', $result ); |
| 147 | 147 | } |
| 148 | 148 | } |
-
diff --git tests/phpunit/tests/xmlrpc/wp/getComment.php tests/phpunit/tests/xmlrpc/wp/getComment.php
index d66ccd8a0e..57ad8995f1 100644
|
|
|
class Tests_XMLRPC_wp_getComment extends WP_XMLRPC_UnitTestCase { |
| 35 | 35 | |
| 36 | 36 | function test_invalid_username_password() { |
| 37 | 37 | $result = $this->myxmlrpcserver->wp_getComment( array( 1, 'username', 'password', self::$parent_comment_id ) ); |
| 38 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 38 | $this->assertIXRError( $result ); |
| 39 | 39 | $this->assertEquals( 403, $result->code ); |
| 40 | 40 | } |
| 41 | 41 | |
| … |
… |
class Tests_XMLRPC_wp_getComment extends WP_XMLRPC_UnitTestCase { |
| 43 | 43 | $this->make_user_by_role( 'contributor' ); |
| 44 | 44 | |
| 45 | 45 | $result = $this->myxmlrpcserver->wp_getComment( array( 1, 'contributor', 'contributor', self::$parent_comment_id ) ); |
| 46 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 46 | $this->assertIXRError( $result ); |
| 47 | 47 | $this->assertEquals( 403, $result->code ); |
| 48 | 48 | } |
| 49 | 49 | |
| … |
… |
class Tests_XMLRPC_wp_getComment extends WP_XMLRPC_UnitTestCase { |
| 51 | 51 | $this->make_user_by_role( 'editor' ); |
| 52 | 52 | |
| 53 | 53 | $result = $this->myxmlrpcserver->wp_getComment( array( 1, 'editor', 'editor', self::$parent_comment_id ) ); |
| 54 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 54 | $this->assertNotIXRError( $result ); |
| 55 | 55 | |
| 56 | 56 | // Check data types |
| 57 | 57 | $this->assertInternalType( 'string', $result['user_id'] ); |
| … |
… |
class Tests_XMLRPC_wp_getComment extends WP_XMLRPC_UnitTestCase { |
| 87 | 87 | $this->make_user_by_role( 'editor' ); |
| 88 | 88 | |
| 89 | 89 | $result = $this->myxmlrpcserver->wp_getComment( array( 1, 'editor', 'editor', self::$child_comment_id ) ); |
| 90 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 90 | $this->assertNotIXRError( $result ); |
| 91 | 91 | |
| 92 | 92 | $this->assertEquals( self::$child_comment_id, $result['comment_id'] ); |
| 93 | 93 | $this->assertEquals( self::$parent_comment_id, $result['parent'] ); |
| … |
… |
class Tests_XMLRPC_wp_getComment extends WP_XMLRPC_UnitTestCase { |
| 97 | 97 | $this->make_user_by_role( 'editor' ); |
| 98 | 98 | |
| 99 | 99 | $result = $this->myxmlrpcserver->wp_getComment( array( 1, 'editor', 'editor', 123456789 ) ); |
| 100 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 100 | $this->assertIXRError( $result ); |
| 101 | 101 | $this->assertEquals( 404, $result->code ); |
| 102 | 102 | } |
| 103 | 103 | } |
| | 104 | No newline at end of file |
-
diff --git tests/phpunit/tests/xmlrpc/wp/getComments.php tests/phpunit/tests/xmlrpc/wp/getComments.php
index a4bdf22333..49b72535b7 100644
|
|
|
class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { |
| 8 | 8 | |
| 9 | 9 | function test_invalid_username_password() { |
| 10 | 10 | $result = $this->myxmlrpcserver->wp_getComments( array( 1, 'username', 'password', array() ) ); |
| 11 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 11 | $this->assertIXRError( $result ); |
| 12 | 12 | $this->assertEquals( 403, $result->code ); |
| 13 | 13 | } |
| 14 | 14 | |
| … |
… |
class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { |
| 16 | 16 | $this->make_user_by_role( 'contributor' ); |
| 17 | 17 | |
| 18 | 18 | $result = $this->myxmlrpcserver->wp_getComments( array( 1, 'contributor', 'contributor', array() ) ); |
| 19 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 19 | $this->assertIXRError( $result ); |
| 20 | 20 | $this->assertEquals( 401, $result->code ); |
| 21 | 21 | } |
| 22 | 22 | |
| … |
… |
class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { |
| 27 | 27 | $this->make_user_by_role( 'editor' ); |
| 28 | 28 | |
| 29 | 29 | $results = $this->myxmlrpcserver->wp_getComments( array( 1, 'editor', 'editor', array() ) ); |
| 30 | | $this->assertNotInstanceOf( 'IXR_Error', $results ); |
| | 30 | $this->assertNotIXRError( $results ); |
| 31 | 31 | |
| 32 | 32 | foreach( $results as $result ) { |
| 33 | 33 | $comment = get_comment( $result['comment_id'], ARRAY_A ); |
| … |
… |
class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { |
| 44 | 44 | $results = $this->myxmlrpcserver->wp_getComments( array( 1, 'editor', 'editor', array( |
| 45 | 45 | 'post_id' => $this->post_id |
| 46 | 46 | ) ) ); |
| 47 | | $this->assertNotInstanceOf( 'IXR_Error', $results ); |
| | 47 | $this->assertNotIXRError( $results ); |
| 48 | 48 | |
| 49 | 49 | foreach( $results as $result ) { |
| 50 | 50 | $this->assertEquals( $this->post_id, $result['post_id'] ); |
| … |
… |
class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { |
| 60 | 60 | $results = $this->myxmlrpcserver->wp_getComments( array( 1, 'editor', 'editor', array( |
| 61 | 61 | 'post_id' => $this->post_id, |
| 62 | 62 | ) ) ); |
| 63 | | $this->assertNotInstanceOf( 'IXR_Error', $results ); |
| | 63 | $this->assertNotIXRError( $results ); |
| 64 | 64 | |
| 65 | 65 | // if no 'number' filter is specified, default should be 10 |
| 66 | 66 | $this->assertCount( 10, $results ); |
| … |
… |
class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { |
| 69 | 69 | 'post_id' => $this->post_id, |
| 70 | 70 | 'number' => 5 |
| 71 | 71 | ) ) ); |
| 72 | | $this->assertNotInstanceOf( 'IXR_Error', $results2 ); |
| | 72 | $this->assertNotIXRError( $results2 ); |
| 73 | 73 | $this->assertCount( 5, $results2 ); |
| 74 | 74 | } |
| 75 | 75 | |
| … |
… |
class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { |
| 104 | 104 | ) ); |
| 105 | 105 | |
| 106 | 106 | $result = $this->myxmlrpcserver->wp_getComments( array( 1, 'contributor', 'contributor' ) ); |
| 107 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 107 | $this->assertIXRError( $result ); |
| 108 | 108 | $this->assertEquals( 401, $result->code ); |
| 109 | 109 | } |
| 110 | 110 | |
| … |
… |
class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { |
| 140 | 140 | $result1 = $this->myxmlrpcserver->wp_getComments( array( 1, 'author', 'author', array( |
| 141 | 141 | 'post_id' => $author_post_id |
| 142 | 142 | ) ) ); |
| 143 | | $this->assertInstanceOf( 'IXR_Error', $result1 ); |
| | 143 | $this->assertIXRError( $result1 ); |
| 144 | 144 | |
| 145 | 145 | $result2 = $this->myxmlrpcserver->wp_getComments( array( 1, 'author', 'author', array( |
| 146 | 146 | 'status' => 'approve', |
| … |
… |
class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { |
| 153 | 153 | $result3 = $this->myxmlrpcserver->wp_getComments( array( 1, 'author', 'author', array( |
| 154 | 154 | 'post_id' => $editor_post_id |
| 155 | 155 | ) ) ); |
| 156 | | $this->assertInstanceOf( 'IXR_Error', $result3 ); |
| | 156 | $this->assertIXRError( $result3 ); |
| 157 | 157 | |
| 158 | 158 | $result4 = $this->myxmlrpcserver->wp_getComments( array( 1, 'author', 'author', array( |
| 159 | 159 | 'status' => 'approve', |
-
diff --git tests/phpunit/tests/xmlrpc/wp/getMediaItem.php tests/phpunit/tests/xmlrpc/wp/getMediaItem.php
index 7b99dd5a04..a091f1c2b6 100644
|
|
|
class Tests_XMLRPC_wp_getMediaItem extends WP_XMLRPC_UnitTestCase { |
| 38 | 38 | |
| 39 | 39 | function test_invalid_username_password() { |
| 40 | 40 | $result = $this->myxmlrpcserver->wp_getMediaItem( array( 1, 'username', 'password', 0 ) ); |
| 41 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 41 | $this->assertIXRError( $result ); |
| 42 | 42 | $this->assertEquals( 403, $result->code ); |
| 43 | 43 | } |
| 44 | 44 | |
| … |
… |
class Tests_XMLRPC_wp_getMediaItem extends WP_XMLRPC_UnitTestCase { |
| 47 | 47 | |
| 48 | 48 | $fields = array( 'post' ); |
| 49 | 49 | $result = $this->myxmlrpcserver->wp_getMediaItem( array( 1, 'author', 'author', $this->attachment_id, $fields ) ); |
| 50 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 50 | $this->assertNotIXRError( $result ); |
| 51 | 51 | |
| 52 | 52 | // Check data types |
| 53 | 53 | $this->assertInternalType( 'string', $result['attachment_id'] ); |
-
diff --git tests/phpunit/tests/xmlrpc/wp/getOptions.php tests/phpunit/tests/xmlrpc/wp/getOptions.php
index 8b095f65c5..0dffcff231 100644
|
|
|
class Tests_XMLRPC_wp_getOptions extends WP_XMLRPC_UnitTestCase { |
| 7 | 7 | |
| 8 | 8 | function test_invalid_username_password() { |
| 9 | 9 | $result = $this->myxmlrpcserver->wp_getOptions( array( 1, 'username', 'password' ) ); |
| 10 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 10 | $this->assertIXRError( $result ); |
| 11 | 11 | $this->assertEquals( 403, $result->code ); |
| 12 | 12 | } |
| 13 | 13 | |
-
diff --git tests/phpunit/tests/xmlrpc/wp/getPage.php tests/phpunit/tests/xmlrpc/wp/getPage.php
index 0f377b13b8..eb57239c95 100644
|
|
|
class Tests_XMLRPC_wp_getPage extends WP_XMLRPC_UnitTestCase { |
| 20 | 20 | |
| 21 | 21 | function test_invalid_username_password() { |
| 22 | 22 | $result = $this->myxmlrpcserver->wp_getPage( array( 1, self::$post_id, 'username', 'password' ) ); |
| 23 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 23 | $this->assertIXRError( $result ); |
| 24 | 24 | $this->assertEquals( 403, $result->code ); |
| 25 | 25 | } |
| 26 | 26 | |
| … |
… |
class Tests_XMLRPC_wp_getPage extends WP_XMLRPC_UnitTestCase { |
| 31 | 31 | $this->make_user_by_role( 'editor' ); |
| 32 | 32 | |
| 33 | 33 | $result = $this->myxmlrpcserver->wp_getPage( array( 1, 9999, 'editor', 'editor' ) ); |
| 34 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 34 | $this->assertIXRError( $result ); |
| 35 | 35 | $this->assertEquals( 404, $result->code ); |
| 36 | 36 | } |
| 37 | 37 | |
| … |
… |
class Tests_XMLRPC_wp_getPage extends WP_XMLRPC_UnitTestCase { |
| 39 | 39 | $this->make_user_by_role( 'editor' ); |
| 40 | 40 | |
| 41 | 41 | $result = $this->myxmlrpcserver->wp_getPage( array( 1, self::$post_id, 'editor', 'editor' ) ); |
| 42 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 42 | $this->assertNotIXRError( $result ); |
| 43 | 43 | |
| 44 | 44 | // Check data types |
| 45 | 45 | $this->assertInternalType( 'string', $result['userid'] ); |
| … |
… |
class Tests_XMLRPC_wp_getPage extends WP_XMLRPC_UnitTestCase { |
| 80 | 80 | $this->make_user_by_role( 'editor' ); |
| 81 | 81 | |
| 82 | 82 | $result = $this->myxmlrpcserver->wp_getPage( array( 1, self::$post_id, 'editor', 'editor' ) ); |
| 83 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 83 | $this->assertNotIXRError( $result ); |
| 84 | 84 | |
| 85 | 85 | $this->assertInstanceOf( 'IXR_Date', $result['dateCreated'] ); |
| 86 | 86 | $this->assertInstanceOf( 'IXR_Date', $result['date_created_gmt'] ); |
-
diff --git tests/phpunit/tests/xmlrpc/wp/getPageList.php tests/phpunit/tests/xmlrpc/wp/getPageList.php
index ef8f793ca1..0e924c4ef4 100644
|
|
|
class Tests_XMLRPC_wp_getPageList extends WP_XMLRPC_UnitTestCase { |
| 20 | 20 | |
| 21 | 21 | function test_invalid_username_password() { |
| 22 | 22 | $result = $this->myxmlrpcserver->wp_getPageList( array( 1, 'username', 'password' ) ); |
| 23 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 23 | $this->assertIXRError( $result ); |
| 24 | 24 | $this->assertEquals( 403, $result->code ); |
| 25 | 25 | } |
| 26 | 26 | |
| … |
… |
class Tests_XMLRPC_wp_getPageList extends WP_XMLRPC_UnitTestCase { |
| 28 | 28 | $this->make_user_by_role( 'contributor' ); |
| 29 | 29 | |
| 30 | 30 | $result = $this->myxmlrpcserver->wp_getPageList( array( 1, 'contributor', 'contributor' ) ); |
| 31 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 31 | $this->assertIXRError( $result ); |
| 32 | 32 | $this->assertEquals( 401, $result->code ); |
| 33 | 33 | } |
| 34 | 34 | |
| … |
… |
class Tests_XMLRPC_wp_getPageList extends WP_XMLRPC_UnitTestCase { |
| 36 | 36 | $this->make_user_by_role( 'editor' ); |
| 37 | 37 | |
| 38 | 38 | $results = $this->myxmlrpcserver->wp_getPageList( array( 1, 'editor', 'editor' ) ); |
| 39 | | $this->assertNotInstanceOf( 'IXR_Error', $results ); |
| | 39 | $this->assertNotIXRError( $results ); |
| 40 | 40 | |
| 41 | 41 | foreach( $results as $result ) { |
| 42 | 42 | $page = get_post( $result->page_id ); |
-
diff --git tests/phpunit/tests/xmlrpc/wp/getPages.php tests/phpunit/tests/xmlrpc/wp/getPages.php
index 424238794a..f528d832ff 100644
|
|
|
class Tests_XMLRPC_wp_getPages extends WP_XMLRPC_UnitTestCase { |
| 26 | 26 | |
| 27 | 27 | function test_invalid_username_password() { |
| 28 | 28 | $result = $this->myxmlrpcserver->wp_getPages( array( 1, 'username', 'password' ) ); |
| 29 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 29 | $this->assertIXRError( $result ); |
| 30 | 30 | $this->assertEquals( 403, $result->code ); |
| 31 | 31 | } |
| 32 | 32 | |
| … |
… |
class Tests_XMLRPC_wp_getPages extends WP_XMLRPC_UnitTestCase { |
| 34 | 34 | $this->make_user_by_role( 'contributor' ); |
| 35 | 35 | |
| 36 | 36 | $result = $this->myxmlrpcserver->wp_getPages( array( 1, 'contributor', 'contributor' ) ); |
| 37 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 37 | $this->assertIXRError( $result ); |
| 38 | 38 | $this->assertEquals( 401, $result->code ); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | function test_capable_user() { |
| 42 | 42 | $results = $this->myxmlrpcserver->wp_getPages( array( 1, 'administrator', 'administrator' ) ); |
| 43 | | $this->assertNotInstanceOf( 'IXR_Error', $results ); |
| | 43 | $this->assertNotIXRError( $results ); |
| 44 | 44 | |
| 45 | 45 | foreach( $results as $result ) { |
| 46 | 46 | $page = get_post( $result['page_id'] ); |
| … |
… |
class Tests_XMLRPC_wp_getPages extends WP_XMLRPC_UnitTestCase { |
| 65 | 65 | add_filter( 'map_meta_cap', array( $this, 'remove_editor_edit_page_cap') , 10, 4 ); |
| 66 | 66 | |
| 67 | 67 | $results = $this->myxmlrpcserver->wp_getPages( array( 1, 'editor', 'editor' ) ); |
| 68 | | $this->assertNotInstanceOf( 'IXR_Error', $results ); |
| | 68 | $this->assertNotIXRError( $results ); |
| 69 | 69 | |
| 70 | 70 | $found_incapable = false; |
| 71 | 71 | foreach( $results as $result ) { |
| 72 | 72 | // WP#20629 |
| 73 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 73 | $this->assertNotIXRError( $result ); |
| 74 | 74 | |
| 75 | 75 | if ( $result['page_id'] == self::$post_id ) { |
| 76 | 76 | $found_incapable = true; |
-
diff --git tests/phpunit/tests/xmlrpc/wp/getPost.php tests/phpunit/tests/xmlrpc/wp/getPost.php
index 6e6ecaeae9..b33f8a3021 100644
|
|
|
class Tests_XMLRPC_wp_getPost extends WP_XMLRPC_UnitTestCase { |
| 27 | 27 | |
| 28 | 28 | function test_invalid_username_password() { |
| 29 | 29 | $result = $this->myxmlrpcserver->wp_getPost( array( 1, 'username', 'password', 1 ) ); |
| 30 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 30 | $this->assertIXRError( $result ); |
| 31 | 31 | $this->assertEquals( 403, $result->code ); |
| 32 | 32 | } |
| 33 | 33 | |
| … |
… |
class Tests_XMLRPC_wp_getPost extends WP_XMLRPC_UnitTestCase { |
| 36 | 36 | |
| 37 | 37 | $fields = array( 'post', 'custom_fields' ); |
| 38 | 38 | $result = $this->myxmlrpcserver->wp_getPost( array( 1, 'author', 'author', $this->post_id, $fields ) ); |
| 39 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 39 | $this->assertNotIXRError( $result ); |
| 40 | 40 | |
| 41 | 41 | // Check data types |
| 42 | 42 | $this->assertInternalType( 'string', $result['post_id'] ); |
| … |
… |
class Tests_XMLRPC_wp_getPost extends WP_XMLRPC_UnitTestCase { |
| 79 | 79 | function test_no_fields() { |
| 80 | 80 | $fields = array(); |
| 81 | 81 | $result = $this->myxmlrpcserver->wp_getPost( array( 1, 'author', 'author', $this->post_id, $fields ) ); |
| 82 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 82 | $this->assertNotIXRError( $result ); |
| 83 | 83 | |
| 84 | 84 | // when no fields are requested, only the IDs should be returned |
| 85 | 85 | $this->assertEquals( 1, count( $result ) ); |
| … |
… |
class Tests_XMLRPC_wp_getPost extends WP_XMLRPC_UnitTestCase { |
| 88 | 88 | |
| 89 | 89 | function test_default_fields() { |
| 90 | 90 | $result = $this->myxmlrpcserver->wp_getPost( array( 1, 'author', 'author', $this->post_id ) ); |
| 91 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 91 | $this->assertNotIXRError( $result ); |
| 92 | 92 | |
| 93 | 93 | $this->assertArrayHasKey( 'post_id', $result ); |
| 94 | 94 | $this->assertArrayHasKey( 'link', $result ); // random field from 'posts' group |
| … |
… |
class Tests_XMLRPC_wp_getPost extends WP_XMLRPC_UnitTestCase { |
| 99 | 99 | function test_date() { |
| 100 | 100 | $fields = array( 'post' ); |
| 101 | 101 | $result = $this->myxmlrpcserver->wp_getPost( array( 1, 'author', 'author', $this->post_id, $fields ) ); |
| 102 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 102 | $this->assertNotIXRError( $result ); |
| 103 | 103 | |
| 104 | 104 | $this->assertInstanceOf( 'IXR_Date', $result['post_date'] ); |
| 105 | 105 | $this->assertInstanceOf( 'IXR_Date', $result['post_date_gmt'] ); |
| … |
… |
class Tests_XMLRPC_wp_getPost extends WP_XMLRPC_UnitTestCase { |
| 130 | 130 | ) ); |
| 131 | 131 | |
| 132 | 132 | $result = $this->myxmlrpcserver->wp_getPost( array( 1, 'editor', 'editor', $child_page_id ) ); |
| 133 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 133 | $this->assertNotIXRError( $result ); |
| 134 | 134 | |
| 135 | 135 | $this->assertInternalType( 'string', $result['post_id'] ); |
| 136 | 136 | $this->assertInternalType( 'string', $result['post_parent'] ); |
-
diff --git tests/phpunit/tests/xmlrpc/wp/getPostType.php tests/phpunit/tests/xmlrpc/wp/getPostType.php
index a00dbda3f7..cef0fd6981 100644
|
|
|
class Tests_XMLRPC_wp_getPostType extends WP_XMLRPC_UnitTestCase { |
| 31 | 31 | |
| 32 | 32 | function test_invalid_username_password() { |
| 33 | 33 | $result = $this->myxmlrpcserver->wp_getPostType( array( 1, 'username', 'password', 'post' ) ); |
| 34 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 34 | $this->assertIXRError( $result ); |
| 35 | 35 | $this->assertEquals( 403, $result->code ); |
| 36 | 36 | } |
| 37 | 37 | |
| … |
… |
class Tests_XMLRPC_wp_getPostType extends WP_XMLRPC_UnitTestCase { |
| 39 | 39 | $this->make_user_by_role( 'editor' ); |
| 40 | 40 | |
| 41 | 41 | $result = $this->myxmlrpcserver->wp_getPostType( array( 1, 'editor', 'editor', 'foobar' ) ); |
| 42 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 42 | $this->assertIXRError( $result ); |
| 43 | 43 | $this->assertEquals( 403, $result->code ); |
| 44 | 44 | } |
| 45 | 45 | |
| … |
… |
class Tests_XMLRPC_wp_getPostType extends WP_XMLRPC_UnitTestCase { |
| 47 | 47 | $this->make_user_by_role( 'editor' ); |
| 48 | 48 | |
| 49 | 49 | $result = $this->myxmlrpcserver->wp_getPostType( array( 1, 'editor', 'editor', 'post' ) ); |
| 50 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 50 | $this->assertNotIXRError( $result ); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | function test_incapable_user() { |
| 54 | 54 | $this->make_user_by_role( 'subscriber' ); |
| 55 | 55 | |
| 56 | 56 | $result = $this->myxmlrpcserver->wp_getPostType( array( 1, 'subscriber', 'subscriber', 'post' ) ); |
| 57 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 57 | $this->assertIXRError( $result ); |
| 58 | 58 | $this->assertEquals( 401, $result->code ); |
| 59 | 59 | } |
| 60 | 60 | |
| … |
… |
class Tests_XMLRPC_wp_getPostType extends WP_XMLRPC_UnitTestCase { |
| 62 | 62 | $this->make_user_by_role( 'editor' ); |
| 63 | 63 | |
| 64 | 64 | $result = $this->myxmlrpcserver->wp_getPostType( array( 1, 'editor', 'editor', $this->cpt_name, array( 'labels', 'cap', 'menu', 'taxonomies' ) ) ); |
| 65 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 65 | $this->assertNotIXRError( $result ); |
| 66 | 66 | |
| 67 | 67 | // check data types |
| 68 | 68 | $this->assertInternalType( 'string', $result['name'] ); |
-
diff --git tests/phpunit/tests/xmlrpc/wp/getPostTypes.php tests/phpunit/tests/xmlrpc/wp/getPostTypes.php
index ae78a5db51..7188411931 100644
|
|
|
|
| 6 | 6 | class Tests_XMLRPC_wp_getPostTypes extends WP_XMLRPC_UnitTestCase { |
| 7 | 7 | function test_invalid_username_password() { |
| 8 | 8 | $result = $this->myxmlrpcserver->wp_getPostTypes( array( 1, 'username', 'password', 'post' ) ); |
| 9 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 9 | $this->assertIXRError( $result ); |
| 10 | 10 | $this->assertEquals( 403, $result->code ); |
| 11 | 11 | } |
| 12 | 12 | |
| … |
… |
class Tests_XMLRPC_wp_getPostTypes extends WP_XMLRPC_UnitTestCase { |
| 14 | 14 | $this->make_user_by_role( 'subscriber' ); |
| 15 | 15 | |
| 16 | 16 | $result = $this->myxmlrpcserver->wp_getPostTypes( array( 1, 'subscriber', 'subscriber' ) ); |
| 17 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 17 | $this->assertNotIXRError( $result ); |
| 18 | 18 | $this->assertInternalType( 'array', $result ); |
| 19 | 19 | $this->assertEquals( 0, count( $result ) ); |
| 20 | 20 | } |
| … |
… |
class Tests_XMLRPC_wp_getPostTypes extends WP_XMLRPC_UnitTestCase { |
| 23 | 23 | $this->make_user_by_role( 'editor' ); |
| 24 | 24 | |
| 25 | 25 | $result = $this->myxmlrpcserver->wp_getPostTypes( array( 1, 'editor', 'editor' ) ); |
| 26 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 26 | $this->assertNotIXRError( $result ); |
| 27 | 27 | $this->assertInternalType( 'array', $result ); |
| 28 | 28 | $this->assertGreaterThan( 0, count( $result ) ); |
| 29 | 29 | } |
| … |
… |
class Tests_XMLRPC_wp_getPostTypes extends WP_XMLRPC_UnitTestCase { |
| 32 | 32 | $this->make_user_by_role( 'editor' ); |
| 33 | 33 | |
| 34 | 34 | $result = $this->myxmlrpcserver->wp_getPostTypes( array( 1, 'editor', 'editor', array( 'hierarchical' => true ) ) ); |
| 35 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 35 | $this->assertNotIXRError( $result ); |
| 36 | 36 | $this->assertInternalType( 'array', $result ); |
| 37 | 37 | |
| 38 | 38 | // verify that pages is in the result, and post is not |
-
diff --git tests/phpunit/tests/xmlrpc/wp/getPosts.php tests/phpunit/tests/xmlrpc/wp/getPosts.php
index 3119fea61f..28d3c4b28d 100644
|
|
|
class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { |
| 7 | 7 | |
| 8 | 8 | function test_invalid_username_password() { |
| 9 | 9 | $result = $this->myxmlrpcserver->wp_getPosts( array( 1, 'username', 'password' ) ); |
| 10 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 10 | $this->assertIXRError( $result ); |
| 11 | 11 | $this->assertEquals( 403, $result->code ); |
| 12 | 12 | } |
| 13 | 13 | |
| … |
… |
class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { |
| 18 | 18 | $this->make_user_by_role( 'subscriber' ); |
| 19 | 19 | |
| 20 | 20 | $result = $this->myxmlrpcserver->wp_getPosts( array( 1, 'subscriber', 'subscriber' ) ); |
| 21 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 21 | $this->assertIXRError( $result ); |
| 22 | 22 | $this->assertEquals( 401, $result->code ); |
| 23 | 23 | |
| 24 | 24 | $filter = array( 'post_type' => 'page' ); |
| 25 | 25 | $result = $this->myxmlrpcserver->wp_getPosts( array( 1, 'subscriber', 'subscriber', $filter ) ); |
| 26 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 26 | $this->assertIXRError( $result ); |
| 27 | 27 | $this->assertEquals( 401, $result->code ); |
| 28 | 28 | } |
| 29 | 29 | |
| … |
… |
class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { |
| 31 | 31 | $this->make_user_by_role( 'editor' ); |
| 32 | 32 | |
| 33 | 33 | $result = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor' ) ); |
| 34 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 34 | $this->assertNotIXRError( $result ); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | function test_invalid_post_type() { |
| … |
… |
class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { |
| 39 | 39 | |
| 40 | 40 | $filter = array( 'post_type' => 'invalid_post_type_name' ); |
| 41 | 41 | $result = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter ) ); |
| 42 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 42 | $this->assertIXRError( $result ); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | function test_filters() { |
| … |
… |
class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { |
| 62 | 62 | // get them all |
| 63 | 63 | $filter = array( 'post_type' => $cpt_name, 'number' => $num_posts + 10 ); |
| 64 | 64 | $results = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter ) ); |
| 65 | | $this->assertNotInstanceOf( 'IXR_Error', $results ); |
| | 65 | $this->assertNotIXRError( $results ); |
| 66 | 66 | $this->assertEquals( $num_posts, count( $results ) ); |
| 67 | 67 | |
| 68 | 68 | // page through results |
| … |
… |
class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { |
| 86 | 86 | // get results ordered by comment count |
| 87 | 87 | $filter2 = array( 'post_type' => $cpt_name, 'number' => $num_posts, 'orderby' => 'comment_count', 'order' => 'DESC' ); |
| 88 | 88 | $results2 = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter2 ) ); |
| 89 | | $this->assertNotInstanceOf( 'IXR_Error', $results2 ); |
| | 89 | $this->assertNotIXRError( $results2 ); |
| 90 | 90 | $last_comment_count = 100; |
| 91 | 91 | foreach ( $results2 as $post ) { |
| 92 | 92 | $comment_count = intval( get_comments_number( $post['post_id'] ) ); |
| … |
… |
class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { |
| 100 | 100 | wp_update_post( $post ); |
| 101 | 101 | $filter3 = array( 'post_type' => $cpt_name, 'post_status' => 'draft' ); |
| 102 | 102 | $results3 = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter3 ) ); |
| 103 | | $this->assertNotInstanceOf( 'IXR_Error', $results3 ); |
| | 103 | $this->assertNotIXRError( $results3 ); |
| 104 | 104 | $this->assertEquals( 1, count( $results3 ) ); |
| 105 | 105 | $this->assertEquals( $post->ID, $results3[0]['post_id'] ); |
| 106 | 106 | |
| … |
… |
class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { |
| 113 | 113 | |
| 114 | 114 | // check default fields |
| 115 | 115 | $results = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor' ) ); |
| 116 | | $this->assertNotInstanceOf( 'IXR_Error', $results ); |
| | 116 | $this->assertNotIXRError( $results ); |
| 117 | 117 | $expected_fields = array( 'post_id', 'post_title', 'terms', 'custom_fields', 'link' ); // subset of expected fields |
| 118 | 118 | foreach( $expected_fields as $field ) { |
| 119 | 119 | $this->assertArrayHasKey( $field, $results[0] ); |
| … |
… |
class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { |
| 123 | 123 | $filter = array(); |
| 124 | 124 | $fields = array( 'post_name', 'post_author', 'enclosure' ); |
| 125 | 125 | $results2 = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter, $fields ) ); |
| 126 | | $this->assertNotInstanceOf( 'IXR_Error', $results2 ); |
| | 126 | $this->assertNotIXRError( $results2 ); |
| 127 | 127 | $expected_fields = array_merge( $fields, array( 'post_id' ) ); |
| 128 | 128 | foreach ( array_keys( $results2[0] ) as $field ) { |
| 129 | 129 | $this->assertContains( $field, $expected_fields ); |
| … |
… |
class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { |
| 142 | 142 | // Search for none of them |
| 143 | 143 | $filter = array( 's' => 'Third' ); |
| 144 | 144 | $results = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter ) ); |
| 145 | | $this->assertNotInstanceOf( 'IXR_Error', $results ); |
| | 145 | $this->assertNotIXRError( $results ); |
| 146 | 146 | $this->assertEquals( 0, count( $results ) ); |
| 147 | 147 | |
| 148 | 148 | // Search for one of them |
| 149 | 149 | $filter = array( 's' => 'First:' ); |
| 150 | 150 | $results = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter ) ); |
| 151 | | $this->assertNotInstanceOf( 'IXR_Error', $results ); |
| | 151 | $this->assertNotIXRError( $results ); |
| 152 | 152 | $this->assertEquals( 1, count( $results ) ); |
| 153 | 153 | } |
| 154 | 154 | |
-
diff --git tests/phpunit/tests/xmlrpc/wp/getProfile.php tests/phpunit/tests/xmlrpc/wp/getProfile.php
index cc2da3e46a..86fd8213dd 100644
|
|
|
class Tests_XMLRPC_wp_getProfile extends WP_XMLRPC_UnitTestCase { |
| 8 | 8 | |
| 9 | 9 | function test_invalid_username_password() { |
| 10 | 10 | $result = $this->myxmlrpcserver->wp_getProfile( array( 1, 'username', 'password' ) ); |
| 11 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 11 | $this->assertIXRError( $result ); |
| 12 | 12 | $this->assertEquals( 403, $result->code ); |
| 13 | 13 | } |
| 14 | 14 | |
| … |
… |
class Tests_XMLRPC_wp_getProfile extends WP_XMLRPC_UnitTestCase { |
| 16 | 16 | $subscriber_id = $this->make_user_by_role( 'subscriber' ); |
| 17 | 17 | |
| 18 | 18 | $result = $this->myxmlrpcserver->wp_getProfile( array( 1, 'subscriber', 'subscriber' ) ); |
| 19 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 19 | $this->assertNotIXRError( $result ); |
| 20 | 20 | $this->assertEquals( $subscriber_id, $result['user_id'] ); |
| 21 | 21 | $this->assertContains( 'subscriber', $result['roles'] ); |
| 22 | 22 | } |
| … |
… |
class Tests_XMLRPC_wp_getProfile extends WP_XMLRPC_UnitTestCase { |
| 25 | 25 | $administrator_id = $this->make_user_by_role( 'administrator' ); |
| 26 | 26 | |
| 27 | 27 | $result = $this->myxmlrpcserver->wp_getProfile( array( 1, 'administrator', 'administrator' ) ); |
| 28 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 28 | $this->assertNotIXRError( $result ); |
| 29 | 29 | $this->assertEquals( $administrator_id, $result['user_id'] ); |
| 30 | 30 | $this->assertContains( 'administrator', $result['roles'] ); |
| 31 | 31 | } |
| … |
… |
class Tests_XMLRPC_wp_getProfile extends WP_XMLRPC_UnitTestCase { |
| 36 | 36 | $fields = array( 'email', 'bio', 'user_contacts' ); |
| 37 | 37 | |
| 38 | 38 | $result = $this->myxmlrpcserver->wp_getProfile( array( 1, 'editor', 'editor', $fields ) ); |
| 39 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 39 | $this->assertNotIXRError( $result ); |
| 40 | 40 | $this->assertEquals( $editor_id, $result['user_id'] ); |
| 41 | 41 | |
| 42 | 42 | $expected_fields = array( 'user_id', 'email', 'bio' ); |
-
diff --git tests/phpunit/tests/xmlrpc/wp/getRevisions.php tests/phpunit/tests/xmlrpc/wp/getRevisions.php
index a407c65ae2..d1aad1e390 100644
|
|
|
class Tests_XMLRPC_wp_getRevisions extends WP_XMLRPC_UnitTestCase { |
| 7 | 7 | |
| 8 | 8 | function test_invalid_username_password() { |
| 9 | 9 | $result = $this->myxmlrpcserver->wp_getRevisions( array( 1, 'username', 'password', 0 ) ); |
| 10 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 10 | $this->assertIXRError( $result ); |
| 11 | 11 | $this->assertEquals( 403, $result->code ); |
| 12 | 12 | } |
| 13 | 13 | |
| … |
… |
class Tests_XMLRPC_wp_getRevisions extends WP_XMLRPC_UnitTestCase { |
| 17 | 17 | $post_id = self::factory()->post->create(); |
| 18 | 18 | |
| 19 | 19 | $result = $this->myxmlrpcserver->wp_getRevisions( array( 1, 'subscriber', 'subscriber', $post_id ) ); |
| 20 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 20 | $this->assertIXRError( $result ); |
| 21 | 21 | $this->assertEquals( 401, $result->code ); |
| 22 | 22 | } |
| 23 | 23 | |
| … |
… |
class Tests_XMLRPC_wp_getRevisions extends WP_XMLRPC_UnitTestCase { |
| 26 | 26 | |
| 27 | 27 | $post_id = self::factory()->post->create(); |
| 28 | 28 | $result = $this->myxmlrpcserver->wp_getRevisions( array( 1, 'editor', 'editor', $post_id ) ); |
| 29 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 29 | $this->assertNotIXRError( $result ); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | function test_revision_count() { |
-
diff --git tests/phpunit/tests/xmlrpc/wp/getTaxonomies.php tests/phpunit/tests/xmlrpc/wp/getTaxonomies.php
index cd2c86e3cc..97bd9cf467 100644
|
|
|
class Tests_XMLRPC_wp_getTaxonomies extends WP_XMLRPC_UnitTestCase { |
| 7 | 7 | |
| 8 | 8 | function test_invalid_username_password() { |
| 9 | 9 | $result = $this->myxmlrpcserver->wp_getTaxonomies( array( 1, 'username', 'password' ) ); |
| 10 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 10 | $this->assertIXRError( $result ); |
| 11 | 11 | $this->assertEquals( 403, $result->code ); |
| 12 | 12 | } |
| 13 | 13 | |
| … |
… |
class Tests_XMLRPC_wp_getTaxonomies extends WP_XMLRPC_UnitTestCase { |
| 15 | 15 | $this->make_user_by_role( 'editor' ); |
| 16 | 16 | |
| 17 | 17 | $result = $this->myxmlrpcserver->wp_getTaxonomies( array( 1, 'editor', 'editor' ) ); |
| 18 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 18 | $this->assertNotIXRError( $result ); |
| 19 | 19 | } |
| 20 | 20 | } |
| | 21 | No newline at end of file |
-
diff --git tests/phpunit/tests/xmlrpc/wp/getTaxonomy.php tests/phpunit/tests/xmlrpc/wp/getTaxonomy.php
index f8446bcbf9..5ffff80a81 100644
|
|
|
class Tests_XMLRPC_wp_getTaxonomy extends WP_XMLRPC_UnitTestCase { |
| 7 | 7 | |
| 8 | 8 | function test_invalid_username_password() { |
| 9 | 9 | $result = $this->myxmlrpcserver->wp_getTaxonomy( array( 1, 'username', 'password', 'category' ) ); |
| 10 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 10 | $this->assertIXRError( $result ); |
| 11 | 11 | $this->assertEquals( 403, $result->code ); |
| 12 | 12 | } |
| 13 | 13 | |
| … |
… |
class Tests_XMLRPC_wp_getTaxonomy extends WP_XMLRPC_UnitTestCase { |
| 15 | 15 | $this->make_user_by_role( 'editor' ); |
| 16 | 16 | |
| 17 | 17 | $result = $this->myxmlrpcserver->wp_getTaxonomy( array( 1, 'editor', 'editor', '' ) ); |
| 18 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 18 | $this->assertIXRError( $result ); |
| 19 | 19 | $this->assertEquals( 403, $result->code ); |
| 20 | 20 | $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message ); |
| 21 | 21 | } |
| … |
… |
class Tests_XMLRPC_wp_getTaxonomy extends WP_XMLRPC_UnitTestCase { |
| 24 | 24 | $this->make_user_by_role( 'editor' ); |
| 25 | 25 | |
| 26 | 26 | $result = $this->myxmlrpcserver->wp_getTaxonomy( array( 1, 'editor', 'editor', 'not_existing' ) ); |
| 27 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 27 | $this->assertIXRError( $result ); |
| 28 | 28 | $this->assertEquals( 403, $result->code ); |
| 29 | 29 | $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message ); |
| 30 | 30 | } |
| … |
… |
class Tests_XMLRPC_wp_getTaxonomy extends WP_XMLRPC_UnitTestCase { |
| 33 | 33 | $this->make_user_by_role( 'subscriber' ); |
| 34 | 34 | |
| 35 | 35 | $result = $this->myxmlrpcserver->wp_getTaxonomy( array( 1, 'subscriber', 'subscriber', 'category' ) ); |
| 36 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 36 | $this->assertIXRError( $result ); |
| 37 | 37 | $this->assertEquals( 401, $result->code ); |
| 38 | 38 | $this->assertEquals( __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ), $result->message ); |
| 39 | 39 | } |
| … |
… |
class Tests_XMLRPC_wp_getTaxonomy extends WP_XMLRPC_UnitTestCase { |
| 42 | 42 | $this->make_user_by_role( 'editor' ); |
| 43 | 43 | |
| 44 | 44 | $result = $this->myxmlrpcserver->wp_getTaxonomy( array( 1, 'editor', 'editor', 'category' ) ); |
| 45 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 45 | $this->assertNotIXRError( $result ); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | function test_prepare_taxonomy() { |
| 49 | 49 | $this->make_user_by_role( 'editor' ); |
| 50 | 50 | |
| 51 | 51 | $result = $this->myxmlrpcserver->wp_getTaxonomy( array( 1, 'editor', 'editor', 'category' ) ); |
| 52 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 52 | $this->assertNotIXRError( $result ); |
| 53 | 53 | $taxonomy = get_taxonomy( 'category' ); |
| 54 | 54 | $this->assertEquals( 'category', $result['name'], 'name' ); |
| 55 | 55 | $this->assertEquals( true, $result['_builtin'], '_builtin' ); |
-
diff --git tests/phpunit/tests/xmlrpc/wp/getTerm.php tests/phpunit/tests/xmlrpc/wp/getTerm.php
index 2edbaeb2ff..fca71a7a95 100644
|
|
|
class Tests_XMLRPC_wp_getTerm extends WP_XMLRPC_UnitTestCase { |
| 15 | 15 | |
| 16 | 16 | function test_invalid_username_password() { |
| 17 | 17 | $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'username', 'password', 'category', 1 ) ); |
| 18 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 18 | $this->assertIXRError( $result ); |
| 19 | 19 | $this->assertEquals( 403, $result->code ); |
| 20 | 20 | } |
| 21 | 21 | |
| … |
… |
class Tests_XMLRPC_wp_getTerm extends WP_XMLRPC_UnitTestCase { |
| 23 | 23 | $this->make_user_by_role( 'editor' ); |
| 24 | 24 | |
| 25 | 25 | $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'editor', 'editor', '', 0 ) ); |
| 26 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 26 | $this->assertIXRError( $result ); |
| 27 | 27 | $this->assertEquals( 403, $result->code ); |
| 28 | 28 | $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message ); |
| 29 | 29 | } |
| … |
… |
class Tests_XMLRPC_wp_getTerm extends WP_XMLRPC_UnitTestCase { |
| 32 | 32 | $this->make_user_by_role( 'editor' ); |
| 33 | 33 | |
| 34 | 34 | $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'editor', 'editor', 'not_existing', 0 ) ); |
| 35 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 35 | $this->assertIXRError( $result ); |
| 36 | 36 | $this->assertEquals( 403, $result->code ); |
| 37 | 37 | $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message ); |
| 38 | 38 | } |
| … |
… |
class Tests_XMLRPC_wp_getTerm extends WP_XMLRPC_UnitTestCase { |
| 41 | 41 | $this->make_user_by_role( 'subscriber' ); |
| 42 | 42 | |
| 43 | 43 | $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'subscriber', 'subscriber', 'category', self::$term_id ) ); |
| 44 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 44 | $this->assertIXRError( $result ); |
| 45 | 45 | $this->assertEquals( 401, $result->code ); |
| 46 | 46 | $this->assertEquals( __( 'Sorry, you are not allowed to assign this term.' ), $result->message ); |
| 47 | 47 | } |
| … |
… |
class Tests_XMLRPC_wp_getTerm extends WP_XMLRPC_UnitTestCase { |
| 51 | 51 | $this->make_user_by_role( 'editor' ); |
| 52 | 52 | |
| 53 | 53 | $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'editor', 'editor', 'category', '' ) ); |
| 54 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 54 | $this->assertIXRError( $result ); |
| 55 | 55 | $this->assertEquals( 500, $result->code ); |
| 56 | 56 | $this->assertEquals( __('Empty Term'), $result->message ); |
| 57 | 57 | } |
| … |
… |
class Tests_XMLRPC_wp_getTerm extends WP_XMLRPC_UnitTestCase { |
| 60 | 60 | $this->make_user_by_role( 'editor' ); |
| 61 | 61 | |
| 62 | 62 | $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'editor', 'editor', 'category', 9999 ) ); |
| 63 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 63 | $this->assertIXRError( $result ); |
| 64 | 64 | $this->assertEquals( 404, $result->code ); |
| 65 | 65 | $this->assertEquals( __( 'Invalid term ID.' ), $result->message ); |
| 66 | 66 | } |
| … |
… |
class Tests_XMLRPC_wp_getTerm extends WP_XMLRPC_UnitTestCase { |
| 72 | 72 | |
| 73 | 73 | $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'editor', 'editor', 'category', self::$term_id ) ); |
| 74 | 74 | |
| 75 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 75 | $this->assertNotIXRError( $result ); |
| 76 | 76 | $this->assertEquals( $result, $term ); |
| 77 | 77 | |
| 78 | 78 | // Check DataTypes |
-
diff --git tests/phpunit/tests/xmlrpc/wp/getTerms.php tests/phpunit/tests/xmlrpc/wp/getTerms.php
index 1673975f1f..b67cbde140 100644
|
|
|
class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase { |
| 7 | 7 | |
| 8 | 8 | function test_invalid_username_password() { |
| 9 | 9 | $result = $this->myxmlrpcserver->wp_getTerms( array( 1, 'username', 'password', 'category' ) ); |
| 10 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 10 | $this->assertIXRError( $result ); |
| 11 | 11 | $this->assertEquals( 403, $result->code ); |
| 12 | 12 | } |
| 13 | 13 | |
| … |
… |
class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase { |
| 15 | 15 | $this->make_user_by_role( 'editor' ); |
| 16 | 16 | |
| 17 | 17 | $result = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', '' ) ); |
| 18 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 18 | $this->assertIXRError( $result ); |
| 19 | 19 | $this->assertEquals( 403, $result->code ); |
| 20 | 20 | $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message ); |
| 21 | 21 | } |
| … |
… |
class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase { |
| 24 | 24 | $this->make_user_by_role( 'editor' ); |
| 25 | 25 | |
| 26 | 26 | $result = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'not_existing' ) ); |
| 27 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 27 | $this->assertIXRError( $result ); |
| 28 | 28 | $this->assertEquals( 403, $result->code ); |
| 29 | 29 | $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message ); |
| 30 | 30 | } |
| … |
… |
class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase { |
| 33 | 33 | $this->make_user_by_role( 'subscriber' ); |
| 34 | 34 | |
| 35 | 35 | $result = $this->myxmlrpcserver->wp_getTerms( array( 1, 'subscriber', 'subscriber', 'category' ) ); |
| 36 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 36 | $this->assertIXRError( $result ); |
| 37 | 37 | $this->assertEquals( 401, $result->code ); |
| 38 | 38 | $this->assertEquals( __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ), $result->message ); |
| 39 | 39 | } |
| … |
… |
class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase { |
| 45 | 45 | $cat = wp_insert_term( 'term_' . __FUNCTION__ , 'category' ); |
| 46 | 46 | |
| 47 | 47 | $results = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'category' ) ); |
| 48 | | $this->assertNotInstanceOf( 'IXR_Error', $results ); |
| | 48 | $this->assertNotIXRError( $results ); |
| 49 | 49 | |
| 50 | 50 | foreach( $results as $term ) { |
| 51 | 51 | $this->assertInternalType( 'int', $term['count'] ); |
| … |
… |
class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase { |
| 71 | 71 | |
| 72 | 72 | // test fetching all terms |
| 73 | 73 | $results = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', $tax_name ) ); |
| 74 | | $this->assertNotInstanceOf( 'IXR_Error', $results ); |
| | 74 | $this->assertNotIXRError( $results ); |
| 75 | 75 | |
| 76 | 76 | $this->assertEquals( $num_terms, count( $results ) ); |
| 77 | 77 | foreach ( $results as $term ) { |
| … |
… |
class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase { |
| 81 | 81 | // test paged results |
| 82 | 82 | $filter = array( 'number' => 5 ); |
| 83 | 83 | $results2 = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', $tax_name, $filter ) ); |
| 84 | | $this->assertNotInstanceOf( 'IXR_Error', $results ); |
| | 84 | $this->assertNotIXRError( $results ); |
| 85 | 85 | $this->assertEquals( 5, count( $results2 ) ); |
| 86 | 86 | $this->assertEquals( $results[1]['term_id'], $results2[1]['term_id'] ); // check one of the terms |
| 87 | 87 | |
| 88 | 88 | $filter['offset'] = 10; |
| 89 | 89 | $results3 = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', $tax_name, $filter ) ); |
| 90 | | $this->assertNotInstanceOf( 'IXR_Error', $results3 ); |
| | 90 | $this->assertNotIXRError( $results3 ); |
| 91 | 91 | $this->assertEquals( $num_terms - 10, count( $results3 ) ); |
| 92 | 92 | $this->assertEquals( $results[11]['term_id'], $results3[1]['term_id'] ); |
| 93 | 93 | |
| 94 | 94 | // test hide_empty (since none have been attached to posts yet, all should be hidden |
| 95 | 95 | $filter = array( 'hide_empty' => true ); |
| 96 | 96 | $results4 = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', $tax_name, $filter ) ); |
| 97 | | $this->assertNotInstanceOf( 'IXR_Error', $results4 ); |
| | 97 | $this->assertNotIXRError( $results4 ); |
| 98 | 98 | $this->assertEquals( 0, count( $results4 ) ); |
| 99 | 99 | |
| 100 | 100 | unset($GLOBALS['wp_taxonomies'][$tax_name]); |
| … |
… |
class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase { |
| 111 | 111 | |
| 112 | 112 | $filter = array( 'orderby' => 'count', 'order' => 'DESC' ); |
| 113 | 113 | $results = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'category', $filter ) ); |
| 114 | | $this->assertNotInstanceOf( 'IXR_Error', $results ); |
| | 114 | $this->assertNotIXRError( $results ); |
| 115 | 115 | $this->assertNotEquals( 0, count( $results ) ); |
| 116 | 116 | |
| 117 | 117 | foreach( $results as $term ) { |
| … |
… |
class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase { |
| 133 | 133 | // search by full name |
| 134 | 134 | $filter = array( 'search' => $name ); |
| 135 | 135 | $results = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'category', $filter ) ); |
| 136 | | $this->assertNotInstanceOf( 'IXR_Error', $results ); |
| | 136 | $this->assertNotIXRError( $results ); |
| 137 | 137 | $this->assertEquals( 1, count( $results ) ); |
| 138 | 138 | $this->assertEquals( $name, $results[0]['name'] ); |
| 139 | 139 | $this->assertEquals( $name_id, $results[0]['term_id'] ); |
| … |
… |
class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase { |
| 141 | 141 | // search by partial name |
| 142 | 142 | $filter = array( 'search' => substr( $name, 0, 10 ) ); |
| 143 | 143 | $results2 = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'category', $filter ) ); |
| 144 | | $this->assertNotInstanceOf( 'IXR_Error', $results2 ); |
| | 144 | $this->assertNotIXRError( $results2 ); |
| 145 | 145 | $this->assertEquals( 1, count( $results2 ) ); |
| 146 | 146 | $this->assertEquals( $name, $results2[0]['name'] ); |
| 147 | 147 | $this->assertEquals( $name_id, $results2[0]['term_id'] ); |
-
diff --git tests/phpunit/tests/xmlrpc/wp/getUser.php tests/phpunit/tests/xmlrpc/wp/getUser.php
index acef3c6a06..beda930f42 100644
|
|
|
class Tests_XMLRPC_wp_getUser extends WP_XMLRPC_UnitTestCase { |
| 25 | 25 | |
| 26 | 26 | function test_invalid_username_password() { |
| 27 | 27 | $result = $this->myxmlrpcserver->wp_getUser( array( 1, 'username', 'password', 1 ) ); |
| 28 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 28 | $this->assertIXRError( $result ); |
| 29 | 29 | $this->assertEquals( 403, $result->code ); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | function test_invalid_user() { |
| 33 | 33 | $result = $this->myxmlrpcserver->wp_getUser( array( 1, 'administrator', 'administrator', 34902348908234 ) ); |
| 34 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 34 | $this->assertIXRError( $result ); |
| 35 | 35 | $this->assertEquals( 404, $result->code ); |
| 36 | 36 | } |
| 37 | 37 | |
| … |
… |
class Tests_XMLRPC_wp_getUser extends WP_XMLRPC_UnitTestCase { |
| 40 | 40 | $editor_id = $this->make_user_by_role( 'editor' ); |
| 41 | 41 | |
| 42 | 42 | $result = $this->myxmlrpcserver->wp_getUser( array( 1, 'subscriber', 'subscriber', $editor_id ) ); |
| 43 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 43 | $this->assertIXRError( $result ); |
| 44 | 44 | $this->assertEquals( 401, $result->code ); |
| 45 | 45 | } |
| 46 | 46 | |
| … |
… |
class Tests_XMLRPC_wp_getUser extends WP_XMLRPC_UnitTestCase { |
| 48 | 48 | $subscriber_id = $this->make_user_by_role( 'subscriber' ); |
| 49 | 49 | |
| 50 | 50 | $result = $this->myxmlrpcserver->wp_getUser( array( 1, 'subscriber', 'subscriber', $subscriber_id ) ); |
| 51 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 51 | $this->assertNotIXRError( $result ); |
| 52 | 52 | $this->assertEquals( $subscriber_id, $result['user_id'] ); |
| 53 | 53 | } |
| 54 | 54 | |
| … |
… |
class Tests_XMLRPC_wp_getUser extends WP_XMLRPC_UnitTestCase { |
| 72 | 72 | $user_id = wp_insert_user( $user_data ); |
| 73 | 73 | |
| 74 | 74 | $result = $this->myxmlrpcserver->wp_getUser( array( 1, 'administrator', 'administrator', $user_id ) ); |
| 75 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 75 | $this->assertNotIXRError( $result ); |
| 76 | 76 | |
| 77 | 77 | // check data types |
| 78 | 78 | $this->assertInternalType( 'string', $result['user_id'] ); |
| … |
… |
class Tests_XMLRPC_wp_getUser extends WP_XMLRPC_UnitTestCase { |
| 111 | 111 | $editor_id = $this->make_user_by_role( 'editor' ); |
| 112 | 112 | |
| 113 | 113 | $result = $this->myxmlrpcserver->wp_getUser( array( 1, 'administrator', 'administrator', $editor_id, array() ) ); |
| 114 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 114 | $this->assertNotIXRError( $result ); |
| 115 | 115 | $this->assertEquals( $editor_id, $result['user_id'] ); |
| 116 | 116 | |
| 117 | 117 | $expected_fields = array( 'user_id' ); |
| … |
… |
class Tests_XMLRPC_wp_getUser extends WP_XMLRPC_UnitTestCase { |
| 122 | 122 | $editor_id = $this->make_user_by_role( 'editor' ); |
| 123 | 123 | |
| 124 | 124 | $result = $this->myxmlrpcserver->wp_getUser( array( 1, 'administrator', 'administrator', $editor_id, array( 'basic' ) ) ); |
| 125 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 125 | $this->assertNotIXRError( $result ); |
| 126 | 126 | $this->assertEquals( $editor_id, $result['user_id'] ); |
| 127 | 127 | |
| 128 | 128 | $expected_fields = array( 'user_id', 'username', 'email', 'registered', 'display_name', 'nicename' ); |
| … |
… |
class Tests_XMLRPC_wp_getUser extends WP_XMLRPC_UnitTestCase { |
| 138 | 138 | $fields = array( 'email', 'bio', 'user_contacts' ); |
| 139 | 139 | |
| 140 | 140 | $result = $this->myxmlrpcserver->wp_getUser( array( 1, 'administrator', 'administrator', $editor_id, $fields ) ); |
| 141 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 141 | $this->assertNotIXRError( $result ); |
| 142 | 142 | $this->assertEquals( $editor_id, $result['user_id'] ); |
| 143 | 143 | |
| 144 | 144 | $expected_fields = array( 'user_id', 'email', 'bio' ); |
-
diff --git tests/phpunit/tests/xmlrpc/wp/getUsers.php tests/phpunit/tests/xmlrpc/wp/getUsers.php
index 1860fd11d3..62169e0c64 100644
|
|
|
class Tests_XMLRPC_wp_getUsers extends WP_XMLRPC_UnitTestCase { |
| 8 | 8 | |
| 9 | 9 | function test_invalid_username_password() { |
| 10 | 10 | $results = $this->myxmlrpcserver->wp_getUsers( array( 1, 'username', 'password' ) ); |
| 11 | | $this->assertInstanceOf( 'IXR_Error', $results ); |
| | 11 | $this->assertIXRError( $results ); |
| 12 | 12 | $this->assertEquals( 403, $results->code ); |
| 13 | 13 | } |
| 14 | 14 | |
| … |
… |
class Tests_XMLRPC_wp_getUsers extends WP_XMLRPC_UnitTestCase { |
| 16 | 16 | $this->make_user_by_role( 'subscriber' ); |
| 17 | 17 | |
| 18 | 18 | $results = $this->myxmlrpcserver->wp_getUsers( array( 1, 'subscriber', 'subscriber' ) ); |
| 19 | | $this->assertInstanceOf( 'IXR_Error', $results ); |
| | 19 | $this->assertIXRError( $results ); |
| 20 | 20 | $this->assertEquals( 401, $results->code ); |
| 21 | 21 | } |
| 22 | 22 | |
| … |
… |
class Tests_XMLRPC_wp_getUsers extends WP_XMLRPC_UnitTestCase { |
| 24 | 24 | $this->make_user_by_role( 'administrator' ); |
| 25 | 25 | |
| 26 | 26 | $result = $this->myxmlrpcserver->wp_getUsers( array( 1, 'administrator', 'administrator' ) ); |
| 27 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 27 | $this->assertNotIXRError( $result ); |
| 28 | 28 | |
| 29 | 29 | // check data types |
| 30 | 30 | $this->assertInternalType( 'string', $result[0]['user_id'] ); |
| … |
… |
class Tests_XMLRPC_wp_getUsers extends WP_XMLRPC_UnitTestCase { |
| 49 | 49 | |
| 50 | 50 | $filter = array( 'role' => 'invalidrole' ); |
| 51 | 51 | $results = $this->myxmlrpcserver->wp_getUsers( array( 1, 'administrator', 'administrator', $filter ) ); |
| 52 | | $this->assertInstanceOf( 'IXR_Error', $results ); |
| | 52 | $this->assertIXRError( $results ); |
| 53 | 53 | $this->assertEquals( 403, $results->code ); |
| 54 | 54 | } |
| 55 | 55 | |
| … |
… |
class Tests_XMLRPC_wp_getUsers extends WP_XMLRPC_UnitTestCase { |
| 63 | 63 | // test a single role ('editor') |
| 64 | 64 | $filter = array( 'role' => 'editor' ); |
| 65 | 65 | $results = $this->myxmlrpcserver->wp_getUsers( array( 1, 'administrator', 'administrator', $filter ) ); |
| 66 | | $this->assertNotInstanceOf( 'IXR_Error', $results ); |
| | 66 | $this->assertNotIXRError( $results ); |
| 67 | 67 | $this->assertCount( 1, $results ); |
| 68 | 68 | $this->assertEquals( $editor_id, $results[0]['user_id'] ); |
| 69 | 69 | |
| 70 | 70 | // test 'authors', which should return all non-subscribers |
| 71 | 71 | $filter2 = array( 'who' => 'authors' ); |
| 72 | 72 | $results2 = $this->myxmlrpcserver->wp_getUsers( array( 1, 'administrator', 'administrator', $filter2 ) ); |
| 73 | | $this->assertNotInstanceOf( 'IXR_Error', $results2 ); |
| | 73 | $this->assertNotIXRError( $results2 ); |
| 74 | 74 | $this->assertCount( 3, array_intersect( array( $author_id, $editor_id, $administrator_id ), wp_list_pluck( $results2, 'user_id' ) ) ); |
| 75 | 75 | } |
| 76 | 76 | |
| … |
… |
class Tests_XMLRPC_wp_getUsers extends WP_XMLRPC_UnitTestCase { |
| 104 | 104 | |
| 105 | 105 | $filter = array( 'orderby' => 'email', 'order' => 'ASC' ); |
| 106 | 106 | $results = $this->myxmlrpcserver->wp_getUsers( array( 1, 'administrator', 'administrator', $filter ) ); |
| 107 | | $this->assertNotInstanceOf( 'IXR_Error', $results ); |
| | 107 | $this->assertNotIXRError( $results ); |
| 108 | 108 | |
| 109 | 109 | $last_email = ''; |
| 110 | 110 | foreach ( $results as $user ) { |
-
diff --git tests/phpunit/tests/xmlrpc/wp/newComment.php tests/phpunit/tests/xmlrpc/wp/newComment.php
index 80e70ef32e..148c6acc23 100644
|
|
|
class Tests_XMLRPC_wp_newComment extends WP_XMLRPC_UnitTestCase { |
| 13 | 13 | 'content' => rand_str( 100 ) |
| 14 | 14 | ) ) ); |
| 15 | 15 | |
| 16 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 16 | $this->assertNotIXRError( $result ); |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | function test_empty_comment() { |
| … |
… |
class Tests_XMLRPC_wp_newComment extends WP_XMLRPC_UnitTestCase { |
| 24 | 24 | 'content' => '' |
| 25 | 25 | ) ) ); |
| 26 | 26 | |
| 27 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 27 | $this->assertIXRError( $result ); |
| 28 | 28 | $this->assertEquals( 403, $result->code ); |
| 29 | 29 | } |
| 30 | 30 | |
| … |
… |
class Tests_XMLRPC_wp_newComment extends WP_XMLRPC_UnitTestCase { |
| 40 | 40 | 'content' => rand_str( 100 ), |
| 41 | 41 | ) ) ); |
| 42 | 42 | |
| 43 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 43 | $this->assertIXRError( $result ); |
| 44 | 44 | $this->assertEquals( 403, $result->code ); |
| 45 | 45 | } |
| 46 | 46 | |
| … |
… |
class Tests_XMLRPC_wp_newComment extends WP_XMLRPC_UnitTestCase { |
| 54 | 54 | |
| 55 | 55 | // First time it's a valid comment |
| 56 | 56 | $result = $this->myxmlrpcserver->wp_newComment( $comment_args ); |
| 57 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 57 | $this->assertNotIXRError( $result ); |
| 58 | 58 | |
| 59 | 59 | // Run second time for duplication error |
| 60 | 60 | $result = $this->myxmlrpcserver->wp_newComment( $comment_args ); |
| 61 | 61 | |
| 62 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 62 | $this->assertIXRError( $result ); |
| 63 | 63 | $this->assertEquals( 403, $result->code ); |
| 64 | 64 | } |
| 65 | 65 | |
-
diff --git tests/phpunit/tests/xmlrpc/wp/newPost.php tests/phpunit/tests/xmlrpc/wp/newPost.php
index 3092aef637..1b718bc563 100644
|
|
|
class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { |
| 7 | 7 | |
| 8 | 8 | function test_invalid_username_password() { |
| 9 | 9 | $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'username', 'password', array() ) ); |
| 10 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 10 | $this->assertIXRError( $result ); |
| 11 | 11 | $this->assertEquals( 403, $result->code ); |
| 12 | 12 | } |
| 13 | 13 | |
| … |
… |
class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { |
| 15 | 15 | $this->make_user_by_role( 'subscriber' ); |
| 16 | 16 | |
| 17 | 17 | $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'subscriber', 'subscriber', array() ) ); |
| 18 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 18 | $this->assertIXRError( $result ); |
| 19 | 19 | $this->assertEquals( 401, $result->code ); |
| 20 | 20 | } |
| 21 | 21 | |
| … |
… |
class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { |
| 23 | 23 | $this->make_user_by_role( 'author' ); |
| 24 | 24 | |
| 25 | 25 | $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', array() ) ); |
| 26 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 26 | $this->assertIXRError( $result ); |
| 27 | 27 | $this->assertEquals( 500, $result->code ); |
| 28 | 28 | $this->assertEquals( 'Content, title, and excerpt are empty.', $result->message ); |
| 29 | 29 | } |
| … |
… |
class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { |
| 33 | 33 | |
| 34 | 34 | $post = array( 'post_title' => 'Test' ); |
| 35 | 35 | $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) ); |
| 36 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 36 | $this->assertNotIXRError( $result ); |
| 37 | 37 | $this->assertStringMatchesFormat( '%d', $result ); |
| 38 | 38 | } |
| 39 | 39 | |
| … |
… |
class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { |
| 42 | 42 | |
| 43 | 43 | $post = array( 'post_title' => 'Test', 'ID' => 103948 ); |
| 44 | 44 | $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) ); |
| 45 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 45 | $this->assertNotIXRError( $result ); |
| 46 | 46 | $this->assertNotEquals( '103948', $result ); |
| 47 | 47 | } |
| 48 | 48 | |
| … |
… |
class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { |
| 51 | 51 | |
| 52 | 52 | $post = array( 'post_title' => 'Test', 'post_status' => 'publish' ); |
| 53 | 53 | $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) ); |
| 54 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 54 | $this->assertNotIXRError( $result ); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | function test_incapable_publish() { |
| … |
… |
class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { |
| 59 | 59 | |
| 60 | 60 | $post = array( 'post_title' => 'Test', 'post_status' => 'publish' ); |
| 61 | 61 | $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'contributor', 'contributor', $post ) ); |
| 62 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 62 | $this->assertIXRError( $result ); |
| 63 | 63 | $this->assertEquals( 401, $result->code ); |
| 64 | 64 | } |
| 65 | 65 | |
| … |
… |
class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { |
| 68 | 68 | |
| 69 | 69 | $post = array( 'post_title' => 'Test', 'post_status' => 'private' ); |
| 70 | 70 | $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) ); |
| 71 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 71 | $this->assertNotIXRError( $result ); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | function test_incapable_private() { |
| … |
… |
class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { |
| 76 | 76 | |
| 77 | 77 | $post = array( 'post_title' => 'Test', 'post_status' => 'private' ); |
| 78 | 78 | $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'contributor', 'contributor', $post ) ); |
| 79 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 79 | $this->assertIXRError( $result ); |
| 80 | 80 | $this->assertEquals( 401, $result->code ); |
| 81 | 81 | } |
| 82 | 82 | |
| … |
… |
class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { |
| 86 | 86 | |
| 87 | 87 | $post = array( 'post_title' => 'Test', 'post_author' => $other_author_id ); |
| 88 | 88 | $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) ); |
| 89 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 89 | $this->assertNotIXRError( $result ); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | function test_incapable_other_author() { |
| … |
… |
class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { |
| 95 | 95 | |
| 96 | 96 | $post = array( 'post_title' => 'Test', 'post_author' => $other_author_id ); |
| 97 | 97 | $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'contributor', 'contributor', $post ) ); |
| 98 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 98 | $this->assertIXRError( $result ); |
| 99 | 99 | $this->assertEquals( 401, $result->code ); |
| 100 | 100 | } |
| 101 | 101 | |
| … |
… |
class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { |
| 104 | 104 | |
| 105 | 105 | $post = array( 'post_title' => 'Test', 'post_author' => 99999999 ); |
| 106 | 106 | $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) ); |
| 107 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 107 | $this->assertIXRError( $result ); |
| 108 | 108 | $this->assertEquals( 404, $result->code ); |
| 109 | 109 | } |
| 110 | 110 | |
| … |
… |
class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { |
| 113 | 113 | |
| 114 | 114 | $post = array( 'post_title' => 'Test' ); |
| 115 | 115 | $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) ); |
| 116 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 116 | $this->assertNotIXRError( $result ); |
| 117 | 117 | $this->assertStringMatchesFormat( '%d', $result ); |
| 118 | 118 | |
| 119 | 119 | $out = get_post( $result ); |
| … |
… |
class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { |
| 132 | 132 | |
| 133 | 133 | $post = array( 'post_title' => 'Post Thumbnail Test', 'post_thumbnail' => $attachment_id ); |
| 134 | 134 | $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) ); |
| 135 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 135 | $this->assertNotIXRError( $result ); |
| 136 | 136 | $this->assertEquals( $attachment_id, get_post_meta( $result, '_thumbnail_id', true ) ); |
| 137 | 137 | |
| 138 | 138 | remove_theme_support( 'post-thumbnails' ); |
| … |
… |
class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { |
| 143 | 143 | |
| 144 | 144 | $post = array( 'post_title' => 'Test', 'post_status' => 'foobar_status' ); |
| 145 | 145 | $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) ); |
| 146 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 146 | $this->assertNotIXRError( $result ); |
| 147 | 147 | $this->assertEquals( 'draft', get_post_status( $result ) ); |
| 148 | 148 | } |
| 149 | 149 | |
| … |
… |
class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { |
| 152 | 152 | |
| 153 | 153 | $post = array( 'post_title' => 'Test', 'sticky' => true ); |
| 154 | 154 | $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'contributor', 'contributor', $post ) ); |
| 155 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 155 | $this->assertIXRError( $result ); |
| 156 | 156 | $this->assertEquals( 401, $result->code ); |
| 157 | 157 | } |
| 158 | 158 | |
| … |
… |
class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { |
| 161 | 161 | |
| 162 | 162 | $post = array( 'post_title' => 'Test', 'sticky' => true ); |
| 163 | 163 | $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) ); |
| 164 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 164 | $this->assertNotIXRError( $result ); |
| 165 | 165 | $this->assertTrue( is_sticky( $result ) ); |
| 166 | 166 | } |
| 167 | 167 | |
| … |
… |
class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { |
| 170 | 170 | |
| 171 | 171 | $post = array( 'post_title' => 'Test', 'post_status' => 'private', 'sticky' => true ); |
| 172 | 172 | $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) ); |
| 173 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 173 | $this->assertIXRError( $result ); |
| 174 | 174 | $this->assertEquals( 401, $result->code ); |
| 175 | 175 | } |
| 176 | 176 | |
| … |
… |
class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { |
| 179 | 179 | |
| 180 | 180 | $post = array( 'post_title' => 'Test', 'post_format' => 'quote' ); |
| 181 | 181 | $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) ); |
| 182 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 182 | $this->assertNotIXRError( $result ); |
| 183 | 183 | $this->assertEquals( 'quote', get_post_format( $result ) ); |
| 184 | 184 | } |
| 185 | 185 | |
| … |
… |
class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { |
| 188 | 188 | |
| 189 | 189 | $post = array( 'post_title' => 'Test', 'post_format' => 'tumblr' ); |
| 190 | 190 | $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) ); |
| 191 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 191 | $this->assertNotIXRError( $result ); |
| 192 | 192 | $this->assertEquals( '', get_post_format( $result ) ); |
| 193 | 193 | } |
| 194 | 194 | |
| … |
… |
class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { |
| 202 | 202 | ) |
| 203 | 203 | ); |
| 204 | 204 | $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) ); |
| 205 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 205 | $this->assertIXRError( $result ); |
| 206 | 206 | $this->assertEquals( 401, $result->code ); |
| 207 | 207 | |
| 208 | 208 | $post2 = array( |
| … |
… |
class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { |
| 212 | 212 | ) |
| 213 | 213 | ); |
| 214 | 214 | $result2 = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post2 ) ); |
| 215 | | $this->assertInstanceOf( 'IXR_Error', $result2 ); |
| | 215 | $this->assertIXRError( $result2 ); |
| 216 | 216 | $this->assertEquals( 401, $result2->code ); |
| 217 | 217 | } |
| 218 | 218 | |
| … |
… |
class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { |
| 226 | 226 | ) |
| 227 | 227 | ); |
| 228 | 228 | $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) ); |
| 229 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 229 | $this->assertIXRError( $result ); |
| 230 | 230 | $this->assertEquals( 403, $result->code ); |
| 231 | 231 | } |
| 232 | 232 | |
| … |
… |
class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { |
| 247 | 247 | ) |
| 248 | 248 | ); |
| 249 | 249 | $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) ); |
| 250 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 250 | $this->assertNotIXRError( $result ); |
| 251 | 251 | |
| 252 | 252 | $post_tags = wp_get_object_terms( $result, 'post_tag', array( 'fields' => 'ids' ) ); |
| 253 | 253 | $this->assertNotContains( $tag1['term_id'], $post_tags ); |
| … |
… |
class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { |
| 274 | 274 | ) |
| 275 | 275 | ); |
| 276 | 276 | $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) ); |
| 277 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 277 | $this->assertNotIXRError( $result ); |
| 278 | 278 | // verify that cat2 was created |
| 279 | 279 | $cat2 = get_term_by( 'name', $cat2_name, 'category' ); |
| 280 | 280 | $this->assertNotEmpty( $cat2 ); |
| … |
… |
class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { |
| 291 | 291 | ) |
| 292 | 292 | ); |
| 293 | 293 | $result2 = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post2 ) ); |
| 294 | | $this->assertInstanceOf( 'IXR_Error', $result2 ); |
| | 294 | $this->assertIXRError( $result2 ); |
| 295 | 295 | $this->assertEquals( 401, $result2->code ); |
| 296 | 296 | } |
| 297 | 297 | |
-
diff --git tests/phpunit/tests/xmlrpc/wp/newTerm.php tests/phpunit/tests/xmlrpc/wp/newTerm.php
index 860e5c8dcb..f5f012f3eb 100644
|
|
|
class Tests_XMLRPC_wp_newTerm extends WP_XMLRPC_UnitTestCase { |
| 15 | 15 | |
| 16 | 16 | function test_invalid_username_password() { |
| 17 | 17 | $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'username', 'password', array() ) ); |
| 18 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 18 | $this->assertIXRError( $result ); |
| 19 | 19 | $this->assertEquals( 403, $result->code ); |
| 20 | 20 | } |
| 21 | 21 | |
| … |
… |
class Tests_XMLRPC_wp_newTerm extends WP_XMLRPC_UnitTestCase { |
| 23 | 23 | $this->make_user_by_role( 'editor' ); |
| 24 | 24 | |
| 25 | 25 | $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => '' ) ) ); |
| 26 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 26 | $this->assertIXRError( $result ); |
| 27 | 27 | $this->assertEquals( 403, $result->code ); |
| 28 | 28 | $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message ); |
| 29 | 29 | } |
| … |
… |
class Tests_XMLRPC_wp_newTerm extends WP_XMLRPC_UnitTestCase { |
| 32 | 32 | $this->make_user_by_role( 'editor' ); |
| 33 | 33 | |
| 34 | 34 | $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'not_existing' ) ) ); |
| 35 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 35 | $this->assertIXRError( $result ); |
| 36 | 36 | $this->assertEquals( 403, $result->code ); |
| 37 | 37 | $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message ); |
| 38 | 38 | } |
| … |
… |
class Tests_XMLRPC_wp_newTerm extends WP_XMLRPC_UnitTestCase { |
| 41 | 41 | $this->make_user_by_role( 'subscriber' ); |
| 42 | 42 | |
| 43 | 43 | $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'subscriber', 'subscriber', array( 'taxonomy' => 'category' ) ) ); |
| 44 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 44 | $this->assertIXRError( $result ); |
| 45 | 45 | $this->assertEquals( 401, $result->code ); |
| 46 | 46 | $this->assertEquals( __( 'Sorry, you are not allowed to create terms in this taxonomy.' ), $result->message ); |
| 47 | 47 | } |
| … |
… |
class Tests_XMLRPC_wp_newTerm extends WP_XMLRPC_UnitTestCase { |
| 50 | 50 | $this->make_user_by_role( 'editor' ); |
| 51 | 51 | |
| 52 | 52 | $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'category', 'name' => '' ) ) ); |
| 53 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 53 | $this->assertIXRError( $result ); |
| 54 | 54 | $this->assertEquals( 403, $result->code ); |
| 55 | 55 | $this->assertEquals( __( 'The term name cannot be empty.' ), $result->message ); |
| 56 | 56 | } |
| … |
… |
class Tests_XMLRPC_wp_newTerm extends WP_XMLRPC_UnitTestCase { |
| 59 | 59 | $this->make_user_by_role( 'editor' ); |
| 60 | 60 | |
| 61 | 61 | $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'post_tag', 'parent' => self::$parent_term_id, 'name' => 'test' ) ) ); |
| 62 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 62 | $this->assertIXRError( $result ); |
| 63 | 63 | $this->assertEquals( 403, $result->code ); |
| 64 | 64 | $this->assertEquals( __( 'This taxonomy is not hierarchical.' ), $result->message ); |
| 65 | 65 | } |
| … |
… |
class Tests_XMLRPC_wp_newTerm extends WP_XMLRPC_UnitTestCase { |
| 68 | 68 | $this->make_user_by_role( 'editor' ); |
| 69 | 69 | |
| 70 | 70 | $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'category', 'parent' => 'dasda', 'name' => 'test' ) ) ); |
| 71 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 71 | $this->assertIXRError( $result ); |
| 72 | 72 | $this->assertEquals( 500, $result->code ); |
| 73 | 73 | } |
| 74 | 74 | |
| … |
… |
class Tests_XMLRPC_wp_newTerm extends WP_XMLRPC_UnitTestCase { |
| 76 | 76 | $this->make_user_by_role( 'editor' ); |
| 77 | 77 | |
| 78 | 78 | $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'category', 'parent' => 9999, 'name' => 'test' ) ) ); |
| 79 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 79 | $this->assertIXRError( $result ); |
| 80 | 80 | $this->assertEquals( 403, $result->code ); |
| 81 | 81 | $this->assertEquals( __( 'Parent term does not exist.' ), $result->message ); |
| 82 | 82 | } |
| … |
… |
class Tests_XMLRPC_wp_newTerm extends WP_XMLRPC_UnitTestCase { |
| 86 | 86 | $this->make_user_by_role( 'editor' ); |
| 87 | 87 | |
| 88 | 88 | $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'category', 'name' => 'test' ) ) ); |
| 89 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 89 | $this->assertNotIXRError( $result ); |
| 90 | 90 | $this->assertStringMatchesFormat( '%d', $result ); |
| 91 | 91 | } |
| 92 | 92 | |
| … |
… |
class Tests_XMLRPC_wp_newTerm extends WP_XMLRPC_UnitTestCase { |
| 94 | 94 | $this->make_user_by_role( 'editor' ); |
| 95 | 95 | |
| 96 | 96 | $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'category', 'parent' => self::$parent_term_id, 'name' => 'test' ) ) ); |
| 97 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 97 | $this->assertNotIXRError( $result ); |
| 98 | 98 | $this->assertStringMatchesFormat( '%d', $result ); |
| 99 | 99 | } |
| 100 | 100 | |
| … |
… |
class Tests_XMLRPC_wp_newTerm extends WP_XMLRPC_UnitTestCase { |
| 103 | 103 | |
| 104 | 104 | $taxonomy = array( 'taxonomy' => 'category', 'parent' => self::$parent_term_id, 'name' => 'test_all', 'description' => 'Test all', 'slug' => 'test_all' ); |
| 105 | 105 | $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', $taxonomy ) ); |
| 106 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 106 | $this->assertNotIXRError( $result ); |
| 107 | 107 | $this->assertStringMatchesFormat( '%d', $result ); |
| 108 | 108 | } |
| 109 | 109 | } |
-
diff --git tests/phpunit/tests/xmlrpc/wp/restoreRevision.php tests/phpunit/tests/xmlrpc/wp/restoreRevision.php
index 75f5d74fa0..be9d1916af 100644
|
|
|
class Tests_XMLRPC_wp_restoreRevision extends WP_XMLRPC_UnitTestCase { |
| 23 | 23 | |
| 24 | 24 | function test_invalid_username_password() { |
| 25 | 25 | $result = $this->myxmlrpcserver->wp_restoreRevision( array( 1, 'username', 'password', $this->revision_id ) ); |
| 26 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 26 | $this->assertIXRError( $result ); |
| 27 | 27 | $this->assertEquals( 403, $result->code ); |
| 28 | 28 | } |
| 29 | 29 | |
| … |
… |
class Tests_XMLRPC_wp_restoreRevision extends WP_XMLRPC_UnitTestCase { |
| 31 | 31 | $this->make_user_by_role( 'subscriber' ); |
| 32 | 32 | |
| 33 | 33 | $result = $this->myxmlrpcserver->wp_restoreRevision( array( 1, 'subscriber', 'subscriber', $this->revision_id ) ); |
| 34 | | $this->assertInstanceOf( 'IXR_Error', $result ); |
| | 34 | $this->assertIXRError( $result ); |
| 35 | 35 | $this->assertEquals( 401, $result->code ); |
| 36 | 36 | } |
| 37 | 37 | |
| … |
… |
class Tests_XMLRPC_wp_restoreRevision extends WP_XMLRPC_UnitTestCase { |
| 39 | 39 | $this->make_user_by_role( 'editor' ); |
| 40 | 40 | |
| 41 | 41 | $result = $this->myxmlrpcserver->wp_restoreRevision( array( 1, 'editor', 'editor', $this->revision_id ) ); |
| 42 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 42 | $this->assertNotIXRError( $result ); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | function test_revision_restored() { |
-
diff --git tests/phpunit/tests/xmlrpc/wp/uploadFile.php tests/phpunit/tests/xmlrpc/wp/uploadFile.php
index 8baa3f6cff..e15f85d420 100644
|
|
|
class Tests_XMLRPC_wp_uploadFile extends WP_XMLRPC_UnitTestCase { |
| 25 | 25 | |
| 26 | 26 | |
| 27 | 27 | $result = $this->myxmlrpcserver->mw_newMediaObject( array( 0, 'editor', 'editor', $data ) ); |
| 28 | | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
| | 28 | $this->assertNotIXRError( $result ); |
| 29 | 29 | |
| 30 | 30 | // check data types |
| 31 | 31 | $this->assertInternalType( 'string', $result['id'] ); |