Make WordPress Core


Ignore:
Timestamp:
04/09/2025 01:29:39 PM (5 weeks ago)
Author:
SergeyBiryukov
Message:

Tests: Use the ms-required group where appropriate.

This replaces the if ( is_multisite() ) conditional wrapping entire test classes with the ms-required group for more consistency across the test suite.

Follow-up to [40520].

See #63167.

File:
1 edited

Legend:

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

    r54090 r60148  
    11<?php
    22
    3 if ( is_multisite() ) :
     3/**
     4 * Saving network settings without altering starter content ( first page, post, and comment ) shouldn't affect
     5 * the way it is added to new sites.
     6 *
     7 * @group ms-required
     8 * @group ms-site
     9 * @group multisite
     10 */
     11class Tests_Multisite_wpInstallDefaults extends WP_UnitTestCase {
    412    /**
    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
     13     * @ticket 40036
    1014     */
    11     class Tests_Multisite_wpInstallDefaults extends WP_UnitTestCase {
    12         /**
    13          * @ticket 40036
    14          */
    15         public function test_option_should_not_be_empty_by_default() {
    16             $blog_id = self::factory()->blog->create();
     15    public function test_option_should_not_be_empty_by_default() {
     16        $blog_id = self::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();
     23        restore_current_blog();
    2424
    25             wp_delete_site( $blog_id );
     25        wp_delete_site( $blog_id );
    2626
    27             $this->assertNotEmpty( $first_page->post_content );
    28             $this->assertNotEmpty( $first_comment[0]->comment_content );
    29         }
    30 
    31         /**
    32          * @ticket 40036
    33          */
    34         public function test_empty_option_should_fall_back_to_default() {
    35             /*
    36              * Update first_page / first_comment options,
    37              * just like what happens when the network settings page is saved
    38              */
    39             update_site_option( 'first_page', '' );
    40             update_site_option( 'first_comment', '' );
    41 
    42             $blog_id = self::factory()->blog->create();
    43 
    44             switch_to_blog( $blog_id );
    45 
    46             $first_page    = get_page_by_path( '/sample-page' );
    47             $first_comment = get_comments();
    48 
    49             restore_current_blog();
    50 
    51             wp_delete_site( $blog_id );
    52 
    53             $this->assertNotEmpty( $first_page->post_content );
    54             $this->assertNotEmpty( $first_comment[0]->comment_content );
    55         }
    56 
    57         /**
    58          * @ticket 40036
    59          */
    60         public function test_non_default_option_values() {
    61             /*
    62              * Update first_page / first_comment options,
    63              * just like what happens when the network settings page is saved
    64              */
    65             update_site_option( 'first_page', 'Some page content' );
    66             update_site_option( 'first_comment', 'Some comment content' );
    67 
    68             $blog_id = self::factory()->blog->create();
    69 
    70             switch_to_blog( $blog_id );
    71 
    72             $first_page    = get_page_by_path( '/sample-page' );
    73             $first_comment = get_comments();
    74 
    75             restore_current_blog();
    76 
    77             wp_delete_site( $blog_id );
    78 
    79             $this->assertSame( 'Some page content', $first_page->post_content );
    80             $this->assertSame( 'Some comment content', $first_comment[0]->comment_content );
    81         }
     27        $this->assertNotEmpty( $first_page->post_content );
     28        $this->assertNotEmpty( $first_comment[0]->comment_content );
    8229    }
    8330
    84 endif;
     31    /**
     32     * @ticket 40036
     33     */
     34    public function test_empty_option_should_fall_back_to_default() {
     35        /*
     36         * Update first_page / first_comment options,
     37         * just like what happens when the network settings page is saved
     38         */
     39        update_site_option( 'first_page', '' );
     40        update_site_option( 'first_comment', '' );
     41
     42        $blog_id = self::factory()->blog->create();
     43
     44        switch_to_blog( $blog_id );
     45
     46        $first_page    = get_page_by_path( '/sample-page' );
     47        $first_comment = get_comments();
     48
     49        restore_current_blog();
     50
     51        wp_delete_site( $blog_id );
     52
     53        $this->assertNotEmpty( $first_page->post_content );
     54        $this->assertNotEmpty( $first_comment[0]->comment_content );
     55    }
     56
     57    /**
     58     * @ticket 40036
     59     */
     60    public function test_non_default_option_values() {
     61        /*
     62         * Update first_page / first_comment options,
     63         * just like what happens when the network settings page is saved
     64         */
     65        update_site_option( 'first_page', 'Some page content' );
     66        update_site_option( 'first_comment', 'Some comment content' );
     67
     68        $blog_id = self::factory()->blog->create();
     69
     70        switch_to_blog( $blog_id );
     71
     72        $first_page    = get_page_by_path( '/sample-page' );
     73        $first_comment = get_comments();
     74
     75        restore_current_blog();
     76
     77        wp_delete_site( $blog_id );
     78
     79        $this->assertSame( 'Some page content', $first_page->post_content );
     80        $this->assertSame( 'Some comment content', $first_comment[0]->comment_content );
     81    }
     82}
Note: See TracChangeset for help on using the changeset viewer.