WordPress.org

Make WordPress Core

Ticket #20396: 20396_unittests.patch

File 20396_unittests.patch, 15.5 KB (added by maxcutler, 3 years ago)
  • wp-testcase/test-xmlrpc-api/test_mw_editPost.php

     
    8484                $this->assertEquals( $contributor_id, $out->post_author ); 
    8585        } 
    8686 
    87         function test_featured_image() { 
     87        function test_post_thumbnail() { 
    8888                add_theme_support( 'post-thumbnails' ); 
    8989 
    9090                $author_id = get_user_by( 'login', 'author' )->ID; 
    91                 $post = array( 'post_title' => 'Featured Image Test', 'post_author' => $author_id ); 
     91                $post = array( 'post_title' => 'Post Thumbnail Test', 'post_author' => $author_id ); 
    9292                $post_id = wp_insert_post( $post ); 
    9393 
    9494                $this->assertEquals( '', get_post_meta( $post_id, '_thumbnail_id', true ) ); 
     
    100100                $this->assertTrue( empty( $upload['error'] ) ); 
    101101 
    102102                $attachment = array( 
    103                         'post_title' => 'Featured Image', 
     103                        'post_title' => 'Post Thumbnail', 
    104104                        'post_type' => 'attachment', 
    105105                        'post_mime_type' => 'image/jpeg', 
    106106                        'guid' => $upload['url'] 
    107107                ); 
    108108                $attachment_id = wp_insert_attachment( $attachment, $upload['file'], $post_id ); 
    109109 
    110                 // add featured image to post that does not have one 
    111                 $post2 = array( 'wp_featured_image' => $attachment_id ); 
     110                // add post thumbnail to post that does not have one 
     111                $post2 = array( 'wp_post_thumbnail' => $attachment_id ); 
    112112                $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'author', 'author', $post2 ) ); 
    113113                $this->assertNotInstanceOf( 'IXR_Error', $result ); 
    114114                $this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) ); 
    115115 
    116                 // edit the post without supplying a featured_image and check that it didn't change 
     116                // edit the post without supplying a post thumbnail and check that it didn't change 
    117117                $post3 = array( 'post_content' => 'Updated post' ); 
    118118                $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'author', 'author', $post3 ) ); 
    119119                $this->assertNotInstanceOf( 'IXR_Error', $result ); 
    120120                $this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) ); 
    121121 
    122122                // create another attachment 
    123                 $attachment2 = array_merge( $attachment, array( 'title' => 'Featured Image 2' ) ); 
     123                $attachment2 = array_merge( $attachment, array( 'title' => 'Post Thumbnail 2' ) ); 
    124124                $attachment2_id = wp_insert_attachment( $attachment2, $upload['file'], $post_id ); 
    125125 
    126                 // change the post's featured_image 
    127                 $post4 = array( 'wp_featured_image' => $attachment2_id ); 
     126                // change the post's thumbnail 
     127                $post4 = array( 'wp_post_thumbnail' => $attachment2_id ); 
    128128                $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'author', 'author', $post4 ) ); 
    129129                $this->assertNotInstanceOf( 'IXR_Error', $result ); 
    130130                $this->assertEquals( $attachment2_id, get_post_meta( $post_id, '_thumbnail_id', true ) ); 
    131131 
    132                 // unset the post's featured_image 
    133                 $post5 = array( 'wp_featured_image' => '' ); 
     132                // unset the post's post thumbnail 
     133                $post5 = array( 'wp_post_thumbnail' => '' ); 
    134134                $result = $this->myxmlrpcserver->mw_editPost( array($post_id, 'author', 'author', $post5 ) ); 
    135135                $this->assertNotInstanceOf( 'IXR_Error', $result ); 
    136136                $this->assertEquals( '', get_post_meta( $post_id, '_thumbnail_id', true ) ); 
  • wp-testcase/test-xmlrpc-api/test_mw_getPost.php

     
    8787                $this->assertEquals( $this->post_data['post_excerpt'], $result['mt_excerpt'] ); 
    8888                $this->assertEquals( url_to_postid( $result['link'] ), $this->post_id ); 
    8989 
    90                 $this->assertEquals( '', $result['wp_featured_image'] ); 
    91                 $this->assertEquals( '', $result['wp_featured_image_url'] ); 
     90                $this->assertEquals( '', $result['wp_post_thumbnail'] ); 
     91                $this->assertEquals( '', $result['wp_post_thumbnail_url'] ); 
    9292 
    9393                remove_theme_support( 'post-thumbnails' ); 
    9494        } 
    9595 
    96         function test_featured_image() { 
     96        function test_post_thumbnail() { 
    9797                add_theme_support( 'post-thumbnails' ); 
    9898 
    9999                // create attachment 
     
    103103                $this->assertTrue( empty( $upload['error'] ) ); 
    104104 
    105105                $attachment = array( 
    106                         'post_title' => 'Featured Image', 
     106                        'post_title' => 'Post Thumbnail', 
    107107                        'post_type' => 'attachment', 
    108108                        'post_mime_type' => 'image/jpeg', 
    109109                        'guid' => $upload['url'] 
     
    116116                $result = $this->myxmlrpcserver->mw_getPost( array( $this->post_id, 'author', 'author' ) ); 
    117117                $this->assertNotInstanceOf( 'IXR_Error', $result ); 
    118118 
    119                 $this->assertInternalType( 'string', $result['wp_featured_image'] ); 
    120                 $this->assertStringMatchesFormat( '%d', $result['wp_featured_image'] ); 
    121                 $this->assertEquals( $attachment_id, $result['wp_featured_image'] ); 
     119                $this->assertInternalType( 'string', $result['wp_post_thumbnail'] ); 
     120                $this->assertStringMatchesFormat( '%d', $result['wp_post_thumbnail'] ); 
     121                $this->assertEquals( $attachment_id, $result['wp_post_thumbnail'] ); 
    122122 
    123                 $this->assertInternalType( 'string', $result['wp_featured_image_url'] ); 
    124                 $this->assertEquals( wp_get_attachment_url( $attachment_id ), $result['wp_featured_image_url'] ); 
     123                $this->assertInternalType( 'string', $result['wp_post_thumbnail_url'] ); 
     124                $this->assertEquals( wp_get_attachment_url( $attachment_id ), $result['wp_post_thumbnail_url'] ); 
    125125 
    126126                delete_post_thumbnail( $this->post_id ); 
    127127                remove_theme_support( 'post-thumbnails' ); 
  • wp-testcase/test-xmlrpc-api/test_mw_getRecentPosts.php

     
    8383                        $this->assertEquals( $post->post_excerpt, $result['mt_excerpt'] ); 
    8484                        $this->assertEquals( url_to_postid( $result['link'] ), $post->ID ); 
    8585 
    86                         $this->assertEquals( '', $result['wp_featured_image'] ); 
    87                         $this->assertEquals( '', $result['wp_featured_image_url'] ); 
     86                        $this->assertEquals( '', $result['wp_post_thumbnail'] ); 
     87                        $this->assertEquals( '', $result['wp_post_thumbnail_url'] ); 
    8888                } 
    8989 
    9090                remove_theme_support( 'post-thumbnails' ); 
    9191        } 
    9292 
    93         function test_featured_image() { 
     93        function test_post_thumbnail() { 
    9494                add_theme_support( 'post-thumbnails' ); 
    9595 
    9696                // create attachment 
     
    100100                $this->assertTrue( empty( $upload['error'] ) ); 
    101101 
    102102                $attachment = array( 
    103                         'post_title' => 'Featured Image', 
     103                        'post_title' => 'Post Thumbnail', 
    104104                        'post_type' => 'attachment', 
    105105                        'post_mime_type' => 'image/jpeg', 
    106106                        'guid' => $upload['url'] 
     
    112112                $this->assertNotInstanceOf( 'IXR_Error', $results ); 
    113113 
    114114                foreach( $results as $result ) { 
    115                         $this->assertInternalType( 'string', $result['wp_featured_image'] ); 
    116                         $this->assertStringMatchesFormat( '%d', $result['wp_featured_image'] ); 
    117                         $this->assertInternalType( 'string', $result['wp_featured_image_url'] ); 
     115                        $this->assertInternalType( 'string', $result['wp_post_thumbnail'] ); 
     116                        $this->assertStringMatchesFormat( '%d', $result['wp_post_thumbnail'] ); 
     117                        $this->assertInternalType( 'string', $result['wp_post_thumbnail_url'] ); 
    118118 
    119                         if( ! empty( $result['wp_featured_image'] ) || $result['postid'] == $this->post_id ) { 
     119                        if( ! empty( $result['wp_post_thumbnail'] ) || $result['postid'] == $this->post_id ) { 
    120120                                $attachment_id = get_post_meta( $result['postid'], '_thumbnail_id', true ); 
    121121 
    122                                 $this->assertEquals( $attachment_id, $result['wp_featured_image'] ); 
    123                                 $this->assertEquals( wp_get_attachment_url( $attachment_id ), $result['wp_featured_image_url'] ); 
     122                                $this->assertEquals( $attachment_id, $result['wp_post_thumbnail'] ); 
     123                                $this->assertEquals( wp_get_attachment_url( $attachment_id ), $result['wp_post_thumbnail_url'] ); 
    124124                        } 
    125125                } 
    126126 
  • wp-testcase/test-xmlrpc-api/test_mw_newPost.php

     
    8383                $this->assertEquals( 'Test', $out->post_title ); 
    8484        } 
    8585 
    86         function test_featured_image() { 
     86        function test_post_thumbnail() { 
    8787                add_theme_support( 'post-thumbnails' ); 
    8888 
    8989                // create attachment 
     
    9393                $this->assertTrue( empty( $upload['error'] ) ); 
    9494 
    9595                $attachment = array( 
    96                         'post_title' => 'Featured Image', 
     96                        'post_title' => 'Post Thumbnail', 
    9797                        'post_type' => 'attachment', 
    9898                        'post_mime_type' => 'image/jpeg', 
    9999                        'guid' => $upload['url'] 
    100100                ); 
    101101                $attachment_id = wp_insert_attachment( $attachment, $upload['file'] ); 
    102102 
    103                 $post = array( 'title' => 'Featured Image Test', 'wp_featured_image' => $attachment_id ); 
     103                $post = array( 'title' => 'Post Thumbnail Test', 'wp_post_thumbnail' => $attachment_id ); 
    104104                $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) ); 
    105105                $this->assertNotInstanceOf( 'IXR_Error', $result ); 
    106106                $this->assertEquals( $attachment_id, get_post_meta( $result, '_thumbnail_id', true ) ); 
  • wp-testcase/test-xmlrpc-api/test_wp_editPost.php

     
    8484                $this->assertEquals( $contributor_id, $out->post_author ); 
    8585        } 
    8686 
    87         function test_featured_image() { 
     87        function test_post_thumbnail() { 
    8888                add_theme_support( 'post-thumbnails' ); 
    8989 
    9090                $author_id = get_user_by( 'login', 'author' )->ID; 
    91                 $post = array( 'post_title' => 'Featured Image Test', 'post_author' => $author_id ); 
     91                $post = array( 'post_title' => 'Post Thumbnail Test', 'post_author' => $author_id ); 
    9292                $post_id = wp_insert_post( $post ); 
    9393 
    9494                $this->assertEquals( '', get_post_meta( $post_id, '_thumbnail_id', true ) ); 
     
    100100                $this->assertTrue( empty( $upload['error'] ) ); 
    101101 
    102102                $attachment = array( 
    103                         'post_title' => 'Featured Image', 
     103                        'post_title' => 'Post Thumbnail', 
    104104                        'post_type' => 'attachment', 
    105105                        'post_mime_type' => 'image/jpeg', 
    106106                        'guid' => $upload['url'] 
     
    108108                $attachment_id = wp_insert_attachment( $attachment, $upload['file'], $post_id ); 
    109109 
    110110                // add featured image to post that does not have one 
    111                 $post2 = array( 'featured_image' => $attachment_id ); 
     111                $post2 = array( 'post_thumbnail' => $attachment_id ); 
    112112                $result = $this->myxmlrpcserver->wp_editPost( array(1, 'author', 'author', $post_id, $post2 ) ); 
    113113                $this->assertNotInstanceOf( 'IXR_Error', $result ); 
    114114                $this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) ); 
     
    120120                $this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) ); 
    121121 
    122122                // create another attachment 
    123                 $attachment2 = array_merge( $attachment, array( 'post_title' => 'Featured Image 2' ) ); 
     123                $attachment2 = array_merge( $attachment, array( 'post_title' => 'Post Thumbnail 2' ) ); 
    124124                $attachment2_id = wp_insert_attachment( $attachment2, $upload['file'], $post_id ); 
    125125 
    126126                // change the post's featured_image 
    127                 $post4 = array( 'featured_image' => $attachment2_id ); 
     127                $post4 = array( 'post_thumbnail' => $attachment2_id ); 
    128128                $result = $this->myxmlrpcserver->wp_editPost( array(1, 'author', 'author', $post_id, $post4 ) ); 
    129129                $this->assertNotInstanceOf( 'IXR_Error', $result ); 
    130130                $this->assertEquals( $attachment2_id, get_post_meta( $post_id, '_thumbnail_id', true ) ); 
    131131 
    132132                // unset the post's featured_image 
    133                 $post5 = array( 'featured_image' => '' ); 
     133                $post5 = array( 'post_thumbnail' => '' ); 
    134134                $result = $this->myxmlrpcserver->wp_editPost( array(1, 'author', 'author', $post_id, $post5 ) ); 
    135135                $this->assertNotInstanceOf( 'IXR_Error', $result ); 
    136136                $this->assertEquals( '', get_post_meta( $post_id, '_thumbnail_id', true ) ); 
  • wp-testcase/test-xmlrpc-api/test_wp_getOptions.php

     
    5757                $this->assertEquals( get_stylesheet(), $result['stylesheet']['value'] ); 
    5858                $this->assertTrue( $result['stylesheet']['readonly'] ); 
    5959 
    60                 $this->assertEquals( current_theme_supports( 'post-thumbnails' ), $result['featured_image']['value'] ); 
    61                 $this->assertTrue( $result['featured_image']['readonly'] ); 
     60                $this->assertEquals( current_theme_supports( 'post-thumbnails' ), $result['post_thumbnail']['value'] ); 
     61                $this->assertTrue( $result['post_thumbnail']['readonly'] ); 
    6262 
    6363                // Updatable options 
    6464                $this->assertEquals( get_option( 'gmt_offset' ), $result['time_zone']['value'] ); 
     
    140140                $this->assertEquals( get_stylesheet(), $result['stylesheet']['value'] ); 
    141141                $this->assertTrue( $result['stylesheet']['readonly'] ); 
    142142 
    143                 $this->assertEquals( current_theme_supports( 'post-thumbnails' ), $result['featured_image']['value'] ); 
    144                 $this->assertTrue( $result['featured_image']['readonly'] ); 
     143                $this->assertEquals( current_theme_supports( 'post-thumbnails' ), $result['post_thumbnail']['value'] ); 
     144                $this->assertTrue( $result['post_thumbnail']['readonly'] ); 
    145145 
    146146                // Updatable options 
    147147                $this->assertEquals( get_option( 'gmt_offset' ), $result['time_zone']['value'] ); 
  • wp-testcase/test-xmlrpc-api/test_wp_getPost.php

     
    5959                $this->assertInternalType( 'string', $result['ping_status'] ); 
    6060                $this->assertInternalType( 'bool', $result['sticky'] ); 
    6161                $this->assertInternalType( 'string', $result['post_format'] ); 
    62                 $this->assertInternalType( 'string', $result['featured_image'] ); 
     62                $this->assertInternalType( 'string', $result['post_thumbnail'] ); 
    6363 
    6464                // Check expected values 
    6565                $this->assertStringMatchesFormat( '%d', $result['post_id'] ); 
     
    7070                $this->assertEquals( $this->post_data['post_excerpt'], $result['post_excerpt'] ); 
    7171                $this->assertEquals( $this->post_data['post_content'], $result['post_content'] ); 
    7272                $this->assertEquals( url_to_postid( $result['link'] ), $this->post_id ); 
    73                 $this->assertEquals( '', $result['featured_image'] ); 
     73                $this->assertEquals( '', $result['post_thumbnail'] ); 
    7474 
    7575                remove_theme_support( 'post-thumbnails' ); 
    7676        } 
  • wp-testcase/test-xmlrpc-api/test_wp_newPost.php

     
    8282                $this->assertEquals( 'Test', $out->post_title ); 
    8383        } 
    8484 
    85         function test_featured_image() { 
     85        function test_post_thumbnail() { 
    8686                add_theme_support( 'post-thumbnails' ); 
    8787 
    8888                // create attachment 
     
    9292                $this->assertTrue( empty( $upload['error'] ) ); 
    9393 
    9494                $attachment = array( 
    95                         'post_title' => 'Featured Image', 
     95                        'post_title' => 'Post Thumbnail', 
    9696                        'post_type' => 'attachment', 
    9797                        'post_mime_type' => 'image/jpeg', 
    9898                        'guid' => $upload['url'] 
    9999                ); 
    100100                $attachment_id = wp_insert_attachment( $attachment, $upload['file'] ); 
    101101 
    102                 $post = array( 'post_title' => 'Featured Image Test', 'featured_image' => $attachment_id ); 
     102                $post = array( 'post_title' => 'Post Thumbnail Test', 'post_thumbnail' => $attachment_id ); 
    103103                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) ); 
    104104                $this->assertNotInstanceOf( 'IXR_Error', $result ); 
    105105                $this->assertEquals( $attachment_id, get_post_meta( $result, '_thumbnail_id', true ) );