@@ -570,7 +570,8 @@ public function test_rest_autosave_published_post() {
570570 }
571571
572572 public function test_rest_autosave_draft_post_same_author () {
573- add_filter ( 'pre_option_wp_disable_real_time_collaboration ' , '__return_true ' );
573+ $ original_option = get_option ( 'wp_enable_real_time_collaboration ' );
574+ update_option ( 'wp_enable_real_time_collaboration ' , false );
574575
575576 wp_set_current_user ( self ::$ editor_id );
576577
@@ -606,7 +607,7 @@ public function test_rest_autosave_draft_post_same_author() {
606607 $ this ->assertSame ( $ post_data ['post_excerpt ' ], $ post ->post_excerpt );
607608
608609 wp_delete_post ( $ post_id );
609- remove_filter ( 'pre_option_wp_disable_real_time_collaboration ' , ' __return_true ' );
610+ update_option ( 'wp_enable_real_time_collaboration ' , $ original_option );
610611 }
611612
612613 public function test_rest_autosave_draft_post_different_author () {
@@ -747,7 +748,8 @@ public function test_get_item_sets_up_postdata() {
747748 }
748749
749750 public function test_update_item_draft_page_with_parent () {
750- add_filter ( 'pre_option_wp_disable_real_time_collaboration ' , '__return_true ' );
751+ $ original_option = get_option ( 'wp_enable_real_time_collaboration ' );
752+ update_option ( 'wp_enable_real_time_collaboration ' , false );
751753
752754 wp_set_current_user ( self ::$ editor_id );
753755 $ request = new WP_REST_Request ( 'POST ' , '/wp/v2/pages/ ' . self ::$ child_draft_page_id . '/autosaves ' );
@@ -766,8 +768,7 @@ public function test_update_item_draft_page_with_parent() {
766768
767769 $ this ->assertSame ( self ::$ child_draft_page_id , $ data ['id ' ] );
768770 $ this ->assertSame ( self ::$ parent_page_id , $ data ['parent ' ] );
769-
770- remove_filter ( 'pre_option_wp_disable_real_time_collaboration ' , '__return_true ' );
771+ update_option ( 'wp_enable_real_time_collaboration ' , $ original_option );
771772 }
772773
773774 public function test_schema_validation_is_applied () {
@@ -933,7 +934,8 @@ public static function data_head_request_with_specified_fields_returns_success_r
933934 * same author should create a revision instead of updating the post directly.
934935 */
935936 public function test_rest_autosave_draft_post_same_author_with_rtc () {
936- add_filter ( 'pre_option_wp_disable_real_time_collaboration ' , '__return_false ' );
937+ $ original_option = get_option ( 'wp_enable_real_time_collaboration ' );
938+ update_option ( 'wp_enable_real_time_collaboration ' , true );
937939
938940 wp_set_current_user ( self ::$ editor_id );
939941
@@ -972,15 +974,16 @@ public function test_rest_autosave_draft_post_same_author_with_rtc() {
972974 $ this ->assertSame ( $ post_data ['post_excerpt ' ], $ post ->post_excerpt );
973975
974976 wp_delete_post ( $ post_id );
975- remove_filter ( 'pre_option_wp_disable_real_time_collaboration ' , ' __return_false ' );
977+ update_option ( 'wp_enable_real_time_collaboration ' , $ original_option );
976978 }
977979
978980 /**
979981 * When real-time collaboration is enabled, autosaving a draft page with
980982 * a parent should create a revision instead of updating the page directly.
981983 */
982984 public function test_update_item_draft_page_with_parent_with_rtc () {
983- add_filter ( 'pre_option_wp_disable_real_time_collaboration ' , '__return_false ' );
985+ $ original_option = get_option ( 'wp_enable_real_time_collaboration ' );
986+ update_option ( 'wp_enable_real_time_collaboration ' , true );
984987
985988 wp_set_current_user ( self ::$ editor_id );
986989 $ request = new WP_REST_Request ( 'POST ' , '/wp/v2/pages/ ' . self ::$ child_draft_page_id . '/autosaves ' );
@@ -1000,7 +1003,6 @@ public function test_update_item_draft_page_with_parent_with_rtc() {
10001003 // With RTC enabled, a revision is created instead of updating the page.
10011004 $ this ->assertNotSame ( self ::$ child_draft_page_id , $ data ['id ' ] );
10021005 $ this ->assertSame ( self ::$ child_draft_page_id , $ data ['parent ' ] );
1003-
1004- remove_filter ( 'pre_option_wp_disable_real_time_collaboration ' , '__return_false ' );
1006+ update_option ( 'wp_enable_real_time_collaboration ' , $ original_option );
10051007 }
10061008}
0 commit comments