Changeset 47122 for trunk/tests/phpunit/tests/xmlrpc/wp/editPost.php
- Timestamp:
- 01/29/2020 12:43:23 AM (6 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/xmlrpc/wp/editPost.php (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/xmlrpc/wp/editPost.php
r46586 r47122 146 146 $this->assertEquals( '', get_post_meta( $post_id, '_thumbnail_id', true ) ); 147 147 148 // create attachment148 // Create attachment. 149 149 $filename = ( DIR_TESTDATA . '/images/a2-small.jpg' ); 150 150 $attachment_id = self::factory()->attachment->create_upload_object( $filename, $post_id ); 151 151 152 // add post thumbnail to post that does not have one152 // Add post thumbnail to post that does not have one. 153 153 $post2 = array( 'post_thumbnail' => $attachment_id ); 154 154 $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'author', 'author', $post_id, $post2 ) ); … … 156 156 $this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) ); 157 157 158 // fetch the post to verify that it appears158 // Fetch the post to verify that it appears. 159 159 $result = $this->myxmlrpcserver->wp_getPost( array( 1, 'author', 'author', $post_id ) ); 160 160 $this->assertNotIXRError( $result ); … … 163 163 $this->assertEquals( $attachment_id, $result['post_thumbnail']['attachment_id'] ); 164 164 165 // edit the post without supplying a post_thumbnail and check that it didn't change165 // Edit the post without supplying a post_thumbnail and check that it didn't change. 166 166 $post3 = array( 'post_content' => 'Updated post' ); 167 167 $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'author', 'author', $post_id, $post3 ) ); … … 169 169 $this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) ); 170 170 171 // create another attachment171 // Create another attachment. 172 172 $attachment2_id = self::factory()->attachment->create_upload_object( $filename, $post_id ); 173 173 174 // change the post's post_thumbnail174 // Change the post's post_thumbnail. 175 175 $post4 = array( 'post_thumbnail' => $attachment2_id ); 176 176 $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'author', 'author', $post_id, $post4 ) ); … … 178 178 $this->assertEquals( $attachment2_id, get_post_meta( $post_id, '_thumbnail_id', true ) ); 179 179 180 // unset the post's post_thumbnail180 // Unset the post's post_thumbnail. 181 181 $post5 = array( 'post_thumbnail' => '' ); 182 182 $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'author', 'author', $post_id, $post5 ) ); … … 184 184 $this->assertEquals( '', get_post_meta( $post_id, '_thumbnail_id', true ) ); 185 185 186 // use invalid ID186 // Use invalid ID. 187 187 $post6 = array( 'post_thumbnail' => 398420983409 ); 188 188 $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'author', 'author', $post_id, $post6 ) ); … … 250 250 251 251 function test_password_transition_unsticky() { 252 // when transitioning to private status or adding a post password, post should be un-stuck252 // When transitioning to private status or adding a post password, post should be un-stuck. 253 253 $editor_id = $this->make_user_by_role( 'editor' ); 254 254 $post_id = self::factory()->post->create( array( 'post_author' => $editor_id ) ); … … 320 320 $this->assertNotIXRError( $result ); 321 321 322 // Make sure that the post status is still inherit 322 // Make sure that the post status is still inherit. 323 323 $this->assertEquals( 'inherit', get_post( $post_id )->post_status ); 324 324 } … … 339 339 $this->assertNotIXRError( $result ); 340 340 341 // Make sure that the post status is still inherit 341 // Make sure that the post status is still inherit. 342 342 $this->assertEquals( 'draft', get_post( $post_id )->post_status ); 343 343 } … … 405 405 */ 406 406 function test_add_enclosure_if_new() { 407 // Sample enclosure data 407 // Sample enclosure data. 408 408 $enclosure = array( 409 409 'url' => 'http://example.com/sound.mp3', … … 412 412 ); 413 413 414 // Second sample enclosure data array 414 // Second sample enclosure data array. 415 415 $new_enclosure = array( 416 416 'url' => 'http://example.com/sound2.mp3', … … 419 419 ); 420 420 421 // Create a test user 422 $editor_id = $this->make_user_by_role( 'editor' ); 423 424 // Add a dummy post 421 // Create a test user. 422 $editor_id = $this->make_user_by_role( 'editor' ); 423 424 // Add a dummy post. 425 425 $post_id = self::factory()->post->create( 426 426 array( … … 432 432 ); 433 433 434 // Add the enclosure as it is added in "do_enclose()" 434 // Add the enclosure as it is added in "do_enclose()". 435 435 $enclosure_string = "{$enclosure['url']}\n{$enclosure['length']}\n{$enclosure['type']}\n"; 436 436 add_post_meta( $post_id, 'enclosure', $enclosure_string ); 437 437 438 // Verify that the correct data is there 438 // Verify that the correct data is there. 439 439 $this->assertEquals( $enclosure_string, get_post_meta( $post_id, 'enclosure', true ) ); 440 440 441 // Attempt to add the enclosure a second time 441 // Attempt to add the enclosure a second time. 442 442 $this->myxmlrpcserver->add_enclosure_if_new( $post_id, $enclosure ); 443 443 444 // Verify that there is only a single value in the array and that a duplicate is not present 444 // Verify that there is only a single value in the array and that a duplicate is not present. 445 445 $this->assertEquals( 1, count( get_post_meta( $post_id, 'enclosure' ) ) ); 446 446 447 // For good measure, check that the expected value is in the array 447 // For good measure, check that the expected value is in the array. 448 448 $this->assertTrue( in_array( $enclosure_string, get_post_meta( $post_id, 'enclosure' ), true ) ); 449 449 450 // Attempt to add a brand new enclosure via XML-RPC 450 // Attempt to add a brand new enclosure via XML-RPC. 451 451 $this->myxmlrpcserver->add_enclosure_if_new( $post_id, $new_enclosure ); 452 452 453 // Having added the new enclosure, 2 values are expected in the array 453 // Having added the new enclosure, 2 values are expected in the array. 454 454 $this->assertEquals( 2, count( get_post_meta( $post_id, 'enclosure' ) ) ); 455 455 456 // Check that the new enclosure is in the enclosure meta 456 // Check that the new enclosure is in the enclosure meta. 457 457 $new_enclosure_string = "{$new_enclosure['url']}\n{$new_enclosure['length']}\n{$new_enclosure['type']}\n"; 458 458 $this->assertTrue( in_array( $new_enclosure_string, get_post_meta( $post_id, 'enclosure' ), true ) ); 459 459 460 // Check that the old enclosure is in the enclosure meta 460 // Check that the old enclosure is in the enclosure meta. 461 461 $this->assertTrue( in_array( $enclosure_string, get_post_meta( $post_id, 'enclosure' ), true ) ); 462 462 }
Note: See TracChangeset
for help on using the changeset viewer.