- Timestamp:
- 04/09/2025 01:29:39 PM (5 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/multisite/wpInstallDefaults.php
r54090 r60148 1 1 <?php 2 2 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 */ 11 class Tests_Multisite_wpInstallDefaults extends WP_UnitTestCase { 4 12 /** 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 10 14 */ 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(); 17 17 18 18 switch_to_blog( $blog_id ); 19 19 20 21 20 $first_page = get_page_by_path( '/sample-page' ); 21 $first_comment = get_comments(); 22 22 23 23 restore_current_blog(); 24 24 25 25 wp_delete_site( $blog_id ); 26 26 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 ); 82 29 } 83 30 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.