Changeset 42343 for trunk/tests/phpunit/tests/xmlrpc/mw/editPost.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/xmlrpc/mw/editPost.php
r40417 r42343 7 7 8 8 function test_invalid_username_password() { 9 $post = array();9 $post = array(); 10 10 $result = $this->myxmlrpcserver->mw_editPost( array( 1, 'username', 'password', $post ) ); 11 11 $this->assertIXRError( $result ); … … 15 15 function test_edit_own_post() { 16 16 $contributor_id = $this->make_user_by_role( 'contributor' ); 17 $post = array( 'post_title' => 'Post test', 'post_author' => $contributor_id ); 18 $post_id = wp_insert_post( $post ); 17 $post = array( 18 'post_title' => 'Post test', 19 'post_author' => $contributor_id, 20 ); 21 $post_id = wp_insert_post( $post ); 19 22 20 23 $new_title = 'Post test (updated)'; 21 $post2 = array( 'title' => $new_title );22 $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post2 ) );23 $this->assertNotIXRError( $result ); 24 $this->assertTrue( $result);24 $post2 = array( 'title' => $new_title ); 25 $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post2 ) ); 26 $this->assertNotIXRError( $result ); 27 $this->assertTrue( $result ); 25 28 26 29 $out = get_post( $post_id ); … … 32 35 $contributor_id = $this->make_user_by_role( 'contributor' ); 33 36 34 $post = array( 'post_title' => 'Post test', 'post_author' => $contributor_id ); 37 $post = array( 38 'post_title' => 'Post test', 39 'post_author' => $contributor_id, 40 ); 35 41 $post_id = wp_insert_post( $post ); 36 42 37 43 $new_title = 'Post test (updated)'; 38 $post2 = array( 'title' => $new_title );39 $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'editor', 'editor', $post2 ) );40 $this->assertNotIXRError( $result ); 41 $this->assertTrue( $result);44 $post2 = array( 'title' => $new_title ); 45 $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'editor', 'editor', $post2 ) ); 46 $this->assertNotIXRError( $result ); 47 $this->assertTrue( $result ); 42 48 43 49 $out = get_post( $post_id ); … … 50 56 51 57 $original_title = 'Post test'; 52 $post = array( 'post_title' => $original_title, 'post_author' => $author_id ); 53 $post_id = wp_insert_post( $post ); 58 $post = array( 59 'post_title' => $original_title, 60 'post_author' => $author_id, 61 ); 62 $post_id = wp_insert_post( $post ); 54 63 55 64 $new_title = 'Post test (updated)'; 56 $post2 = array( 'title' => $new_title );57 $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post2 ) );65 $post2 = array( 'title' => $new_title ); 66 $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post2 ) ); 58 67 $this->assertIXRError( $result ); 59 68 $this->assertEquals( 401, $result->code ); … … 65 74 function test_capable_reassign_author() { 66 75 $contributor_id = $this->make_user_by_role( 'contributor' ); 67 $author_id = $this->make_user_by_role( 'author' );76 $author_id = $this->make_user_by_role( 'author' ); 68 77 $this->make_user_by_role( 'editor' ); 69 78 70 $post = array( 'post_title' => 'Post test', 'post_author' => $contributor_id ); 71 $post_id = wp_insert_post( $post ); 72 73 $post2 = array( 'wp_author_id' => $author_id ); 79 $post = array( 80 'post_title' => 'Post test', 81 'post_author' => $contributor_id, 82 ); 83 $post_id = wp_insert_post( $post ); 84 85 $post2 = array( 'wp_author_id' => $author_id ); 74 86 $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'editor', 'editor', $post2 ) ); 75 87 $this->assertNotIXRError( $result ); 76 $this->assertTrue( $result);88 $this->assertTrue( $result ); 77 89 78 90 $out = get_post( $post_id ); … … 82 94 function test_incapable_reassign_author() { 83 95 $contributor_id = $this->make_user_by_role( 'contributor' ); 84 $author_id = $this->make_user_by_role( 'author' ); 85 86 $post = array( 'post_title' => 'Post test', 'post_author' => $contributor_id ); 87 $post_id = wp_insert_post( $post ); 88 89 $post2 = array( 'wp_author_id' => $author_id ); 96 $author_id = $this->make_user_by_role( 'author' ); 97 98 $post = array( 99 'post_title' => 'Post test', 100 'post_author' => $contributor_id, 101 ); 102 $post_id = wp_insert_post( $post ); 103 104 $post2 = array( 'wp_author_id' => $author_id ); 90 105 $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post2 ) ); 91 106 $this->assertIXRError( $result ); … … 101 116 function test_capable_reassign_author_to_self() { 102 117 $contributor_id = $this->make_user_by_role( 'contributor' ); 103 $editor_id = $this->make_user_by_role( 'editor' ); 104 105 $post = array( 'post_title' => 'Post test', 'post_author' => $contributor_id ); 106 $post_id = wp_insert_post( $post ); 107 108 $post2 = array( 'wp_author_id' => $editor_id ); 118 $editor_id = $this->make_user_by_role( 'editor' ); 119 120 $post = array( 121 'post_title' => 'Post test', 122 'post_author' => $contributor_id, 123 ); 124 $post_id = wp_insert_post( $post ); 125 126 $post2 = array( 'wp_author_id' => $editor_id ); 109 127 $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'editor', 'editor', $post2 ) ); 110 128 $this->assertNotIXRError( $result ); 111 $this->assertTrue( $result);129 $this->assertTrue( $result ); 112 130 113 131 $out = get_post( $post_id ); … … 120 138 $author_id = $this->make_user_by_role( 'author' ); 121 139 122 $post = array( 'post_title' => 'Post Thumbnail Test', 'post_author' => $author_id ); 140 $post = array( 141 'post_title' => 'Post Thumbnail Test', 142 'post_author' => $author_id, 143 ); 123 144 $post_id = wp_insert_post( $post ); 124 145 … … 126 147 127 148 // create attachment 128 $filename = ( DIR_TESTDATA.'/images/a2-small.jpg' );149 $filename = ( DIR_TESTDATA . '/images/a2-small.jpg' ); 129 150 $attachment_id = self::factory()->attachment->create_upload_object( $filename, $post_id ); 130 151 131 152 // add post thumbnail to post that does not have one 132 $post2 = array( 'wp_post_thumbnail' => $attachment_id );153 $post2 = array( 'wp_post_thumbnail' => $attachment_id ); 133 154 $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'author', 'author', $post2 ) ); 134 155 $this->assertNotIXRError( $result ); … … 136 157 137 158 // edit the post without supplying a post_thumbnail and check that it didn't change 138 $post3 = array( 'post_content' => 'Updated post' );159 $post3 = array( 'post_content' => 'Updated post' ); 139 160 $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'author', 'author', $post3 ) ); 140 161 $this->assertNotIXRError( $result ); … … 145 166 146 167 // change the post's post_thumbnail 147 $post4 = array( 'wp_post_thumbnail' => $attachment2_id );168 $post4 = array( 'wp_post_thumbnail' => $attachment2_id ); 148 169 $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'author', 'author', $post4 ) ); 149 170 $this->assertNotIXRError( $result ); … … 151 172 152 173 // unset the post's post_thumbnail 153 $post5 = array( 'wp_post_thumbnail' => '' );154 $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'author', 'author', $post5 ) );174 $post5 = array( 'wp_post_thumbnail' => '' ); 175 $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'author', 'author', $post5 ) ); 155 176 $this->assertNotIXRError( $result ); 156 177 $this->assertEquals( '', get_post_meta( $post_id, '_thumbnail_id', true ) ); … … 162 183 $contributor_id = $this->make_user_by_role( 'contributor' ); 163 184 164 $post = array( 'post_title' => 'Title', 'post_content' => 'Content', 'post_excerpt' => 'Excerpt', 'post_author' => $contributor_id ); 165 $post_id = wp_insert_post( $post ); 166 167 $post2 = array( 'title' => 'New Title', 'post_author' => $contributor_id ); 185 $post = array( 186 'post_title' => 'Title', 187 'post_content' => 'Content', 188 'post_excerpt' => 'Excerpt', 189 'post_author' => $contributor_id, 190 ); 191 $post_id = wp_insert_post( $post ); 192 193 $post2 = array( 194 'title' => 'New Title', 195 'post_author' => $contributor_id, 196 ); 168 197 $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post2 ) ); 169 198 $this->assertNotIXRError( $result ); 170 $this->assertTrue( $result);199 $this->assertTrue( $result ); 171 200 172 201 $out = get_post( $post_id ); 173 202 $this->assertEquals( $post2['title'], $out->post_title ); 174 203 175 $post3 = array( 'description' => 'New Content', 'post_author' => $contributor_id ); 204 $post3 = array( 205 'description' => 'New Content', 206 'post_author' => $contributor_id, 207 ); 176 208 $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post3 ) ); 177 209 $this->assertNotIXRError( $result ); 178 $this->assertTrue( $result);210 $this->assertTrue( $result ); 179 211 180 212 $out = get_post( $post_id ); … … 182 214 $this->assertEquals( $post3['description'], $out->post_content ); 183 215 184 $post4 = array( 'mt_excerpt' => 'New Excerpt', 'post_author' => $contributor_id ); 216 $post4 = array( 217 'mt_excerpt' => 'New Excerpt', 218 'post_author' => $contributor_id, 219 ); 185 220 $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post4 ) ); 186 221 $this->assertNotIXRError( $result ); 187 $this->assertTrue( $result);222 $this->assertTrue( $result ); 188 223 189 224 $out = get_post( $post_id ); … … 199 234 $author_id = $this->make_user_by_role( 'editor' ); 200 235 201 $post = array( 'post_title' => 'Title', 'post_content' => 'Content', 'post_author' => $author_id, 'post_status' => 'publish' ); 236 $post = array( 237 'post_title' => 'Title', 238 'post_content' => 'Content', 239 'post_author' => $author_id, 240 'post_status' => 'publish', 241 ); 202 242 $post_id = wp_insert_post( $post ); 203 243 … … 211 251 $contributor_id = $this->make_user_by_role( 'contributor' ); 212 252 213 $post = array( 'post_title' => 'Title', 'post_author' => $contributor_id ); 214 $post_id = wp_insert_post( $post ); 215 216 $post2 = array( 'post_type' => 'page' ); 253 $post = array( 254 'post_title' => 'Title', 255 'post_author' => $contributor_id, 256 ); 257 $post_id = wp_insert_post( $post ); 258 259 $post2 = array( 'post_type' => 'page' ); 217 260 $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post2 ) ); 218 261 $this->assertIXRError( $result ); … … 226 269 $editor_id = $this->make_user_by_role( 'editor' ); 227 270 228 $post_id = self::factory()->post->create( array( 229 'post_title' => 'Title', 230 'post_author' => $editor_id, 231 'tags_input' => 'taco' 232 ) ); 271 $post_id = self::factory()->post->create( 272 array( 273 'post_title' => 'Title', 274 'post_author' => $editor_id, 275 'tags_input' => 'taco', 276 ) 277 ); 233 278 234 279 $tags1 = get_the_tags( $post_id ); 235 280 $this->assertNotEmpty( $tags1 ); 236 281 237 $this->myxmlrpcserver->mw_editPost( array( $post_id, 'editor', 'editor', array( 238 'mt_keywords' => '' 239 ) ) ); 282 $this->myxmlrpcserver->mw_editPost( 283 array( 284 $post_id, 285 'editor', 286 'editor', 287 array( 288 'mt_keywords' => '', 289 ), 290 ) 291 ); 240 292 241 293 $tags2 = get_the_tags( $post_id ); … … 263 315 $future_time = strtotime( '+1 day' ); 264 316 $future_date = new IXR_Date( $future_time ); 265 $this->myxmlrpcserver->mw_editPost( array( 266 $post_id, 267 'editor', 268 'editor', 317 $this->myxmlrpcserver->mw_editPost( 269 318 array( 270 'dateCreated' => $future_date, 271 'post_status' => 'publish', 272 ), 273 ) ); 319 $post_id, 320 'editor', 321 'editor', 322 array( 323 'dateCreated' => $future_date, 324 'post_status' => 'publish', 325 ), 326 ) 327 ); 274 328 275 329 $after = get_post( $post_id );
Note: See TracChangeset
for help on using the changeset viewer.