- Timestamp:
- 02/03/2023 12:13:52 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-sidebars-controller.php
r54896 r55200 862 862 863 863 /** 864 * @ticket 57531 865 * @covers WP_Test_REST_Sidebars_Controller::prepare_item_for_response 866 */ 867 public function test_prepare_item_for_response_to_set_inactive_on_theme_switch() { 868 $request = new WP_REST_Request( 'GET', '/wp/v2/sidebars/sidebar-1' ); 869 870 // Set up the test. 871 wp_widgets_init(); 872 $this->setup_widget( 873 'widget_rss', 874 1, 875 array( 876 'title' => 'RSS test', 877 ) 878 ); 879 $this->setup_widget( 880 'widget_text', 881 1, 882 array( 883 'text' => 'Custom text test', 884 ) 885 ); 886 $this->setup_sidebar( 887 'sidebar-1', 888 array( 889 'name' => 'Sidebar 1', 890 ), 891 array( 'text-1', 'rss-1' ) 892 ); 893 894 // Validate the state before a theme switch. 895 $response = rest_get_server()->dispatch( $request ); 896 $data = $response->get_data(); 897 $data = $this->remove_links( $data ); 898 899 $this->assertSame( 'active', $data['status'] ); 900 $this->assertFalse( 901 get_theme_mod( 'wp_classic_sidebars' ), 902 'wp_classic_sidebars theme mod should not exist before switching to block theme' 903 ); 904 905 switch_theme( 'block-theme' ); 906 wp_widgets_init(); 907 908 // Validate the state after a theme switch. 909 $response = rest_get_server()->dispatch( $request ); 910 $data = $response->get_data(); 911 $data = $this->remove_links( $data ); 912 913 $this->assertSame( 914 'inactive', 915 $data['status'], 916 'Sidebar status should have changed to inactive' 917 ); 918 $this->assertSame( 919 array( 'text-1', 'rss-1' ), 920 $data['widgets'], 921 'The text and rss widgets should still in sidebar-1' 922 ); 923 $this->assertArrayHasKey( 924 'sidebar-1', 925 get_theme_mod( 'wp_classic_sidebars' ), 926 'sidebar-1 should be in "wp_classic_sidebars" theme mod' 927 ); 928 } 929 930 /** 864 931 * @ticket 41683 865 932 */
Note: See TracChangeset
for help on using the changeset viewer.