Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (7 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/multisite/wpInstallDefaults.php

    r40296 r42343  
    22
    33if ( is_multisite() ) :
    4 /**
    5  * Saving network settings without altering starter content ( first page, post, and comment ) shouldn't affect
    6  * the way it is added to new sites.
    7  *
    8  * @group ms-site
    9  * @group multisite
    10  */
    11 class Tests_Multisite_Install_Defaults extends WP_UnitTestCase {
    124    /**
    13      * @ticket 40036
     5     * Saving network settings without altering starter content ( first page, post, and comment ) shouldn't affect
     6     * the way it is added to new sites.
     7     *
     8     * @group ms-site
     9     * @group multisite
    1410     */
    15     public function test_option_should_not_be_empty_by_default() {
    16         $blog_id = $this->factory->blog->create();
     11    class Tests_Multisite_Install_Defaults extends WP_UnitTestCase {
     12        /**
     13         * @ticket 40036
     14         */
     15        public function test_option_should_not_be_empty_by_default() {
     16            $blog_id = $this->factory->blog->create();
    1717
    18         switch_to_blog( $blog_id );
     18            switch_to_blog( $blog_id );
    1919
    20         $first_page = get_page_by_path( '/sample-page' );
    21         $first_comment = get_comments();
     20            $first_page    = get_page_by_path( '/sample-page' );
     21            $first_comment = get_comments();
    2222
    23         restore_current_blog();
    24         wpmu_delete_blog( $blog_id, true );
     23            restore_current_blog();
     24            wpmu_delete_blog( $blog_id, true );
    2525
    26         $this->assertNotEmpty( $first_page->post_content );
    27         $this->assertNotEmpty( $first_comment[0]->comment_content );
     26            $this->assertNotEmpty( $first_page->post_content );
     27            $this->assertNotEmpty( $first_comment[0]->comment_content );
     28        }
     29
     30        /**
     31         * @ticket 40036
     32         */
     33        public function test_empty_option_should_fall_back_to_default() {
     34            /*
     35             * Update first_page / first_comment options,
     36             * just like what happens when the network settings page is saved
     37             */
     38            update_site_option( 'first_page', '' );
     39            update_site_option( 'first_comment', '' );
     40
     41            $blog_id = $this->factory->blog->create();
     42
     43            switch_to_blog( $blog_id );
     44
     45            $first_page    = get_page_by_path( '/sample-page' );
     46            $first_comment = get_comments();
     47
     48            restore_current_blog();
     49            wpmu_delete_blog( $blog_id, true );
     50
     51            $this->assertNotEmpty( $first_page->post_content );
     52            $this->assertNotEmpty( $first_comment[0]->comment_content );
     53        }
     54
     55        /**
     56         * @ticket 40036
     57         */
     58        public function test_non_default_option_values() {
     59            /*
     60             * Update first_page / first_comment options,
     61             * just like what happens when the network settings page is saved
     62             */
     63            update_site_option( 'first_page', 'Some page content' );
     64            update_site_option( 'first_comment', 'Some comment content' );
     65
     66            $blog_id = $this->factory->blog->create();
     67
     68            switch_to_blog( $blog_id );
     69
     70            $first_page    = get_page_by_path( '/sample-page' );
     71            $first_comment = get_comments();
     72
     73            restore_current_blog();
     74            wpmu_delete_blog( $blog_id, true );
     75
     76            $this->assertEquals( 'Some page content', $first_page->post_content );
     77            $this->assertEquals( 'Some comment content', $first_comment[0]->comment_content );
     78        }
    2879    }
    2980
    30     /**
    31      * @ticket 40036
    32      */
    33     public function test_empty_option_should_fall_back_to_default() {
    34         /*
    35          * Update first_page / first_comment options,
    36          * just like what happens when the network settings page is saved
    37          */
    38         update_site_option( 'first_page', '' );
    39         update_site_option( 'first_comment', '' );
    40 
    41         $blog_id = $this->factory->blog->create();
    42 
    43         switch_to_blog( $blog_id );
    44 
    45         $first_page = get_page_by_path( '/sample-page' );
    46         $first_comment = get_comments();
    47 
    48         restore_current_blog();
    49         wpmu_delete_blog( $blog_id, true );
    50 
    51         $this->assertNotEmpty( $first_page->post_content );
    52         $this->assertNotEmpty( $first_comment[0]->comment_content );
    53     }
    54 
    55     /**
    56      * @ticket 40036
    57      */
    58     public function test_non_default_option_values() {
    59         /*
    60          * Update first_page / first_comment options,
    61          * just like what happens when the network settings page is saved
    62          */
    63         update_site_option( 'first_page', 'Some page content' );
    64         update_site_option( 'first_comment', 'Some comment content' );
    65 
    66         $blog_id = $this->factory->blog->create();
    67 
    68         switch_to_blog( $blog_id );
    69 
    70         $first_page = get_page_by_path( '/sample-page' );
    71         $first_comment = get_comments();
    72 
    73         restore_current_blog();
    74         wpmu_delete_blog( $blog_id, true );
    75 
    76         $this->assertEquals( 'Some page content', $first_page->post_content );
    77         $this->assertEquals( 'Some comment content', $first_comment[0]->comment_content );
    78     }
    79 }
    80 
    8181endif;
Note: See TracChangeset for help on using the changeset viewer.