WordPress.org

Make WordPress Core

Ticket #34596: 34596.diff

File 34596.diff, 3.9 KB (added by fusillicode, 4 years ago)
  • src/wp-includes/class-wp-customize-manager.php

    diff --git src/wp-includes/class-wp-customize-manager.php src/wp-includes/class-wp-customize-manager.php
    index fcc9697..c2c44bc 100644
    final class WP_Customize_Manager { 
    987987                } else {
    988988                        $setting = new WP_Customize_Setting( $this, $id, $args );
    989989                }
    990                 $this->settings[ $setting->id ] = $setting;
     990                return $this->settings[ $setting->id ] = $setting;
    991991        }
    992992
    993993        /**
    final class WP_Customize_Manager { 
    10911091                } else {
    10921092                        $panel = new WP_Customize_Panel( $this, $id, $args );
    10931093                }
    1094 
    1095                 $this->panels[ $panel->id ] = $panel;
     1094                return $this->panels[ $panel->id ] = $panel;
    10961095        }
    10971096
    10981097        /**
    final class WP_Customize_Manager { 
    11651164                } else {
    11661165                        $section = new WP_Customize_Section( $this, $id, $args );
    11671166                }
    1168                 $this->sections[ $section->id ] = $section;
     1167                return $this->sections[ $section->id ] = $section;
    11691168        }
    11701169
    11711170        /**
    final class WP_Customize_Manager { 
    12361235                } else {
    12371236                        $control = new WP_Customize_Control( $this, $id, $args );
    12381237                }
    1239                 $this->controls[ $control->id ] = $control;
     1238                return $this->controls[ $control->id ] = $control;
    12401239        }
    12411240
    12421241        /**
  • tests/phpunit/tests/customize/manager.php

    diff --git tests/phpunit/tests/customize/manager.php tests/phpunit/tests/customize/manager.php
    index 247f765..2fc06ca 100644
    class Tests_WP_Customize_Manager extends WP_UnitTestCase { 
    431431                $sorted_control_ids = wp_list_pluck( $manager->get_section( $section_id )->controls, 'id' );
    432432                $this->assertEquals( $added_control_ids, $sorted_control_ids );
    433433        }
     434
     435        /**
     436         * @ticket 34596
     437         */
     438        function test_add_setting_returns_same_setting_instance_as_the_one_passed_in_as_argument() {
     439                $setting = new WP_Customize_Setting( $this->manager, 'foo' );
     440                $this->assertSame( $setting, $this->manager->add_setting( $setting ) );
     441        }
     442
     443        /**
     444         * @ticket 34596
     445         */
     446        function test_add_setting_returns_a_new_setting_instance_created_with_the_arguments_passed_in() {
     447                $setting = new WP_Customize_Setting( $this->manager, 'foo' );
     448                $this->assertEquals( $setting, $this->manager->add_setting( 'foo' ) );
     449        }
     450
     451        /**
     452         * @ticket 34596
     453         */
     454        function test_add_control_returns_same_control_instance_as_the_one_passed_in_as_argument() {
     455                $control = new WP_Customize_Control( $this->manager, 'foo' );
     456                $this->assertSame( $control, $this->manager->add_control( $control ) );
     457        }
     458
     459        /**
     460         * @ticket 34596
     461         */
     462        function test_add_control_returns_a_new_control_instance_created_with_the_arguments_passed_in() {
     463                $control = new WP_Customize_Control( $this->manager, 'foo' );
     464                $inside_control = $this->manager->add_control( 'foo' );
     465                $this->assertEquals( $control->id, $inside_control->id );
     466        }
     467
     468        /**
     469         * @ticket 34596
     470         */
     471        function test_add_section_returns_same_section_instance_as_the_one_passed_in_as_argument() {
     472                $section = new WP_Customize_Section( $this->manager, 'foo' );
     473                $this->assertSame( $section, $this->manager->add_section( $section ) );
     474        }
     475
     476        /**
     477         * @ticket 34596
     478         */
     479        function test_add_section_returns_a_new_section_instance_created_with_the_arguments_passed_in() {
     480                $section = new WP_Customize_Section( $this->manager, 'foo' );
     481                $inside_section = $this->manager->add_section( 'foo' );
     482                $this->assertEquals( $section->id, $inside_section->id );
     483        }
     484
     485        /**
     486         * @ticket 34596
     487         */
     488        function test_add_panel_returns_same_panel_instance_as_the_one_passed_in_as_argument() {
     489                $panel = new WP_Customize_Panel( $this->manager, 'foo' );
     490                $this->assertSame( $panel, $this->manager->add_panel( $panel ) );
     491        }
     492
     493        /**
     494         * @ticket 34596
     495         */
     496        function test_add_panel_returns_a_new_panel_instance_created_with_the_arguments_passed_in() {
     497                $panel = new WP_Customize_Panel( $this->manager, 'foo' );
     498                $inside_panel = $this->manager->add_panel( 'foo' );
     499                $this->assertEquals( $panel->id, $inside_panel->id );
     500        }
    434501}