WordPress.org

Make WordPress Core

Ticket #40036: 40036.tests.patch

File 40036.tests.patch, 6.6 KB (added by shadyvb, 3 years ago)
  • src/wp-admin/includes/upgrade.php

     
    194194        $wpdb->insert( $wpdb->term_relationships, array('term_taxonomy_id' => $cat_tt_id, 'object_id' => 1) );
    195195
    196196        // Default comment
    197         $first_comment_author = __( 'A WordPress Commenter' );
    198         $first_comment_email = 'wapuu@wordpress.example';
    199         $first_comment_url = 'https://wordpress.org/';
    200         $first_comment = __( 'Hi, this is a comment.
    201 To get started with moderating, editing, and deleting comments, please visit the Comments screen in the dashboard.
    202 Commenter avatars come from <a href="https://gravatar.com">Gravatar</a>.' );
    203197        if ( is_multisite() ) {
    204                 $first_comment_author = get_site_option( 'first_comment_author', $first_comment_author );
    205                 $first_comment_email = get_site_option( 'first_comment_email', $first_comment_email );
     198                $first_comment_author = get_site_option( 'first_comment_author' );
     199                $first_comment_email = get_site_option( 'first_comment_email' );
    206200                $first_comment_url = get_site_option( 'first_comment_url', network_home_url() );
    207                 $first_comment = get_site_option( 'first_comment', $first_comment );
     201                $first_comment = get_site_option( 'first_comment' );
    208202        }
     203
     204        $first_comment_author = ! empty( $first_comment_author ) ? $first_comment_author : __( 'A WordPress Commenter' );
     205        $first_comment_email = ! empty( $first_comment_email ) ? $first_comment_email : 'wapuu@wordpress.example';
     206        $first_comment_url = ! empty( $first_comment_url ) ? $first_comment_url : 'https://wordpress.org/';
     207        $first_comment = ! empty( $first_comment ) ? $first_comment :  __( 'Hi, this is a comment.
     208To get started with moderating, editing, and deleting comments, please visit the Comments screen in the dashboard.
     209Commenter avatars come from <a href="https://gravatar.com">Gravatar</a>.' );
    209210        $wpdb->insert( $wpdb->comments, array(
    210211                'comment_post_ID' => 1,
    211212                'comment_author' => $first_comment_author,
     
    217218        ));
    218219
    219220        // First Page
    220         $first_page = sprintf( __( "This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:
     221        if ( is_multisite() )
     222                $first_page = get_site_option( 'first_page' );
    221223
    222 <blockquote>Hi there! I'm a bike messenger by day, aspiring actor by night, and this is my website. I live in Los Angeles, have a great dog named Jack, and I like pi&#241;a coladas. (And gettin' caught in the rain.)</blockquote>
     224        $first_page = ! empty( $first_page ) ? $first_page : sprintf( __( "This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:
     225               
     226                <blockquote>Hi there! I'm a bike messenger by day, aspiring actor by night, and this is my website. I live in Los Angeles, have a great dog named Jack, and I like pi&#241;a coladas. (And gettin' caught in the rain.)</blockquote>
     227               
     228                ...or something like this:
     229               
     230                <blockquote>The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.</blockquote>
     231               
     232                As a new WordPress user, you should go to <a href=\"%s\">your dashboard</a> to delete this page and create new pages for your content. Have fun!" ), admin_url() );
    223233
    224 ...or something like this:
    225 
    226 <blockquote>The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.</blockquote>
    227 
    228 As a new WordPress user, you should go to <a href=\"%s\">your dashboard</a> to delete this page and create new pages for your content. Have fun!" ), admin_url() );
    229         if ( is_multisite() )
    230                 $first_page = get_site_option( 'first_page', $first_page );
    231234        $first_post_guid = get_option('home') . '/?page_id=2';
    232235        $wpdb->insert( $wpdb->posts, array(
    233236                'post_author' => $user_id,
  • tests/phpunit/tests/multisite.php

     
    3434                $reg_blog = $wpdb->get_col( "SELECT email FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.blog_id = 1 AND IP LIKE '" . $ip . "'" );
    3535                $this->assertEquals( $user->user_email, $reg_blog[ count( $reg_blog )-1 ] );
    3636        }
     37
     38        /**
     39         * Saving network settings without altering starter content ( first page, post, and comment ) shouldn't affect
     40         * the way it is added to new sites
     41         */
     42        function test_wp_install_defaults_after_updating_settings() {
     43                $blog_ids = [];
     44
     45                $blog_id = self::factory()->blog->create();
     46                $blog_ids[] = $blog_id;
     47                switch_to_blog( $blog_id );
     48
     49                $first_page = get_page_by_path( '/sample-page' );
     50                $this->assertNotEmpty( $first_page->post_content );
     51
     52                $first_comment = get_comments();
     53                $this->assertNotEmpty( $first_comment[0]->comment_content );
     54
     55                // Update first_page / first_comment options, just like what happens when the network settings page is saved
     56                update_site_option( 'first_page', '' );
     57                update_site_option( 'first_comment', '' );
     58
     59                $blog_id = self::factory()->blog->create();
     60                $blog_ids[] = $blog_id;
     61                switch_to_blog( $blog_id );
     62
     63                $first_page = get_page_by_path( '/sample-page' );
     64                $this->assertNotEmpty( $first_page->post_content );
     65
     66                $first_comment = get_comments();
     67                $this->assertNotEmpty( $first_comment[0]->comment_content );
     68
     69                // Update first_page / first_comment options, just like what happens when the network settings page is saved
     70                update_site_option( 'first_page', 'Some page content' );
     71                update_site_option( 'first_comment', 'Some comment content' );
     72
     73                $blog_id = self::factory()->blog->create();
     74                $blog_ids[] = $blog_id;
     75                switch_to_blog( $blog_id );
     76
     77                $first_page = get_page_by_path( '/sample-page' );
     78                $this->assertEquals( 'Some page content', $first_page->post_content );
     79
     80                $first_comment = get_comments();
     81                $this->assertEquals( 'Some comment content', $first_comment[0]->comment_content );
     82
     83                restore_current_blog();
     84
     85                foreach ( $blog_ids as $blog_id ) {
     86                        wpmu_delete_blog( $blog_id, true );
     87                }
     88        }
    3789}
    3890
    3991endif;