Changeset 52010 for trunk/tests/phpunit/tests/customize/widgets.php
- Timestamp:
- 11/04/2021 03:22:47 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/customize/widgets.php
r51568 r52010 21 21 protected $backup_registered_sidebars; 22 22 23 function set_up() {23 public function set_up() { 24 24 parent::set_up(); 25 25 require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; … … 79 79 } 80 80 81 function clean_up_global_scope() {81 public function clean_up_global_scope() { 82 82 global $wp_widget_factory, $wp_registered_sidebars, $wp_registered_widgets, $wp_registered_widget_controls, $wp_registered_widget_updates; 83 83 … … 91 91 } 92 92 93 function tear_down() {93 public function tear_down() { 94 94 $this->manager = null; 95 95 unset( $GLOBALS['wp_customize'] ); … … 99 99 } 100 100 101 function set_customized_post_data( $customized ) {101 private function set_customized_post_data( $customized ) { 102 102 $_POST['customized'] = wp_slash( wp_json_encode( $customized ) ); 103 103 if ( $this->manager ) { … … 108 108 } 109 109 110 function do_customize_boot_actions() {110 private function do_customize_boot_actions() { 111 111 $_SERVER['REQUEST_METHOD'] = 'POST'; 112 112 $_REQUEST['nonce'] = wp_create_nonce( 'preview-customize_' . $this->manager->theme()->get_stylesheet() ); … … 118 118 } 119 119 120 function remove_widgets_block_editor() {120 public function remove_widgets_block_editor() { 121 121 remove_theme_support( 'widgets-block-editor' ); 122 122 } … … 125 125 * Test WP_Customize_Widgets::__construct() 126 126 */ 127 function test_construct() {127 public function test_construct() { 128 128 $this->assertInstanceOf( 'WP_Customize_Widgets', $this->manager->widgets ); 129 129 $this->assertSame( $this->manager, $this->manager->widgets->manager ); … … 137 137 * @ticket 36660 138 138 */ 139 function test_customize_register_with_deleted_sidebars() {139 public function test_customize_register_with_deleted_sidebars() { 140 140 $sidebar_id = 'sidebar-1'; 141 141 delete_option( 'sidebars_widgets' ); … … 229 229 * @see WP_Customize_Widgets::get_selective_refreshable_widgets() 230 230 */ 231 function test_get_selective_refreshable_widgets_when_theme_supports() {231 public function test_get_selective_refreshable_widgets_when_theme_supports() { 232 232 global $wp_widget_factory; 233 233 add_action( 'widgets_init', array( $this, 'override_search_widget_customize_selective_refresh' ), 90 ); … … 249 249 * @see WP_Customize_Widgets::get_selective_refreshable_widgets() 250 250 */ 251 function test_get_selective_refreshable_widgets_when_no_theme_supports() {251 public function test_get_selective_refreshable_widgets_when_no_theme_supports() { 252 252 add_action( 'widgets_init', array( $this, 'override_search_widget_customize_selective_refresh' ), 90 ); 253 253 remove_theme_support( 'customize-selective-refresh-widgets' ); … … 263 263 * @see Tests_WP_Customize_Widgets::test_get_selective_refreshable_widgets_when_no_theme_supports() 264 264 */ 265 function override_search_widget_customize_selective_refresh() {265 public function override_search_widget_customize_selective_refresh() { 266 266 global $wp_widget_factory; 267 267 $wp_widget_factory->widgets['WP_Widget_Search']->widget_options['customize_selective_refresh'] = false; … … 273 273 * @see WP_Customize_Widgets::is_widget_selective_refreshable() 274 274 */ 275 function test_is_widget_selective_refreshable() {275 public function test_is_widget_selective_refreshable() { 276 276 add_action( 'widgets_init', array( $this, 'override_search_widget_customize_selective_refresh' ), 90 ); 277 277 add_theme_support( 'customize-selective-refresh-widgets' ); … … 289 289 * @ticket 36389 290 290 */ 291 function test_register_settings() {291 public function test_register_settings() { 292 292 add_theme_support( 'customize-selective-refresh-widgets' ); 293 293 … … 341 341 * @ticket 36389 342 342 */ 343 function test_register_settings_without_selective_refresh() {343 public function test_register_settings_without_selective_refresh() { 344 344 remove_theme_support( 'customize-selective-refresh-widgets' ); 345 345 $this->test_register_settings(); … … 351 351 * @ticket 36389 352 352 */ 353 function test_register_settings_with_late_theme_support_added() {353 public function test_register_settings_with_late_theme_support_added() { 354 354 remove_theme_support( 'customize-selective-refresh-widgets' ); 355 355 add_action( 'after_setup_theme', array( $this, 'add_customize_selective_refresh_theme_support' ), 100 ); … … 360 360 * Add customize-selective-refresh-widgets theme support. 361 361 */ 362 function add_customize_selective_refresh_theme_support() {362 public function add_customize_selective_refresh_theme_support() { 363 363 add_theme_support( 'customize-selective-refresh-widgets' ); 364 364 } … … 367 367 * Test WP_Customize_Widgets::get_setting_args() 368 368 */ 369 function test_get_setting_args() {369 public function test_get_setting_args() { 370 370 add_theme_support( 'customize-selective-refresh-widgets' ); 371 371 $this->do_customize_boot_actions(); … … 448 448 } 449 449 450 function filter_widget_customizer_setting_args( $args, $id ) {450 public function filter_widget_customizer_setting_args( $args, $id ) { 451 451 $args['uppercase_id_set_by_filter'] = strtoupper( $id ); 452 452 return $args; … … 456 456 * Test WP_Customize_Widgets::sanitize_widget_js_instance() and WP_Customize_Widgets::sanitize_widget_instance() 457 457 */ 458 function test_sanitize_widget_js_instance() {458 public function test_sanitize_widget_js_instance() { 459 459 $this->do_customize_boot_actions(); 460 460 … … 487 487 * @ticket 53489 488 488 */ 489 function test_sanitize_widget_instance_raw_instance() {489 public function test_sanitize_widget_instance_raw_instance() { 490 490 remove_action( 'widgets_init', array( $this, 'remove_widgets_block_editor' ) ); 491 491 $this->do_customize_boot_actions(); … … 514 514 * @ticket 53489 515 515 */ 516 function test_sanitize_widget_instance_with_no_show_instance_in_rest() {516 public function test_sanitize_widget_instance_with_no_show_instance_in_rest() { 517 517 global $wp_widget_factory; 518 518 … … 545 545 * @ticket 53479 546 546 */ 547 function test_sanitize_widget_instance_empty_instance() {547 public function test_sanitize_widget_instance_empty_instance() { 548 548 $this->do_customize_boot_actions(); 549 549 $this->assertSame( $this->manager->widgets->sanitize_widget_instance( array() ), array() ); … … 555 555 * @return array 556 556 */ 557 function get_test_widget_control_args() {557 private function get_test_widget_control_args() { 558 558 global $wp_registered_widgets; 559 559 require_once ABSPATH . '/wp-admin/includes/widgets.php'; … … 576 576 * @see WP_Customize_Widgets::get_widget_control() 577 577 */ 578 function test_get_widget_control() {578 public function test_get_widget_control() { 579 579 $this->do_customize_boot_actions(); 580 580 $widget_control = $this->manager->widgets->get_widget_control( $this->get_test_widget_control_args() ); … … 589 589 * @see WP_Customize_Widgets::get_widget_control_parts() 590 590 */ 591 function test_get_widget_control_parts() {591 public function test_get_widget_control_parts() { 592 592 $this->do_customize_boot_actions(); 593 593 $widget_control_parts = $this->manager->widgets->get_widget_control_parts( $this->get_test_widget_control_args() ); … … 605 605 * @see WP_Widget_Form_Customize_Control::json() 606 606 */ 607 function test_wp_widget_form_customize_control_json() {607 public function test_wp_widget_form_customize_control_json() { 608 608 $this->do_customize_boot_actions(); 609 609 $control = $this->manager->get_control( 'widget_search[2]' ); … … 627 627 * @see WP_Customize_Widgets::is_panel_active() 628 628 */ 629 function test_is_panel_active() {629 public function test_is_panel_active() { 630 630 global $wp_registered_sidebars; 631 631 $this->do_customize_boot_actions(); … … 644 644 * @see WP_Customize_Widgets::call_widget_update() 645 645 */ 646 function test_call_widget_update() {646 public function test_call_widget_update() { 647 647 648 648 $widget_number = 2; … … 700 700 * @see WP_Customize_Widgets::customize_dynamic_partial_args() 701 701 */ 702 function test_customize_dynamic_partial_args() {702 public function test_customize_dynamic_partial_args() { 703 703 do_action( 'customize_register', $this->manager ); 704 704 … … 726 726 * @see WP_Customize_Widgets::selective_refresh_init() 727 727 */ 728 function test_selective_refresh_init_with_theme_support() {728 public function test_selective_refresh_init_with_theme_support() { 729 729 add_theme_support( 'customize-selective-refresh-widgets' ); 730 730 $this->manager->widgets->selective_refresh_init(); … … 740 740 * @see WP_Customize_Widgets::selective_refresh_init() 741 741 */ 742 function test_selective_refresh_init_without_theme_support() {742 public function test_selective_refresh_init_without_theme_support() { 743 743 remove_theme_support( 'customize-selective-refresh-widgets' ); 744 744 $this->manager->widgets->selective_refresh_init(); … … 754 754 * @see WP_Customize_Widgets::customize_preview_enqueue() 755 755 */ 756 function test_customize_preview_enqueue() {756 public function test_customize_preview_enqueue() { 757 757 $this->manager->widgets->customize_preview_enqueue(); 758 758 $this->assertTrue( wp_script_is( 'customize-preview-widgets', 'enqueued' ) ); … … 769 769 * @see WP_Customize_Widgets::end_dynamic_sidebar() 770 770 */ 771 function test_filter_dynamic_sidebar_params() {771 public function test_filter_dynamic_sidebar_params() { 772 772 global $wp_registered_sidebars; 773 773 register_sidebar( … … 824 824 * @see WP_Customize_Widgets::render_widget_partial() 825 825 */ 826 function test_render_widget_partial() {826 public function test_render_widget_partial() { 827 827 add_theme_support( 'customize-selective-refresh-widgets' ); 828 828 $this->do_customize_boot_actions();
Note: See TracChangeset
for help on using the changeset viewer.