WordPress.org

Make WordPress Core

Ticket #34596: 34596.3.diff

File 34596.3.diff, 5.4 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..6351a23 100644
    final class WP_Customize_Manager { 
    980980         * @param WP_Customize_Setting|string $id Customize Setting object, or ID.
    981981         * @param array $args                     Setting arguments; passed to WP_Customize_Setting
    982982         *                                        constructor.
     983         * @return WP_Customize_Setting           The instance of the setting that was added
    983984         */
    984985        public function add_setting( $id, $args = array() ) {
    985986                if ( $id instanceof WP_Customize_Setting ) {
    final class WP_Customize_Manager { 
    988989                        $setting = new WP_Customize_Setting( $this, $id, $args );
    989990                }
    990991                $this->settings[ $setting->id ] = $setting;
     992                return $setting;
    991993        }
    992994
    993995        /**
    final class WP_Customize_Manager { 
    10841086         *
    10851087         * @param WP_Customize_Panel|string $id   Customize Panel object, or Panel ID.
    10861088         * @param array                     $args Optional. Panel arguments. Default empty array.
     1089         * @return WP_Customize_Panel             The instance of the panel that was added
    10871090         */
    10881091        public function add_panel( $id, $args = array() ) {
    10891092                if ( $id instanceof WP_Customize_Panel ) {
    final class WP_Customize_Manager { 
    10911094                } else {
    10921095                        $panel = new WP_Customize_Panel( $this, $id, $args );
    10931096                }
    1094 
    10951097                $this->panels[ $panel->id ] = $panel;
     1098                return $panel;
    10961099        }
    10971100
    10981101        /**
    final class WP_Customize_Manager { 
    11581161         *
    11591162         * @param WP_Customize_Section|string $id   Customize Section object, or Section ID.
    11601163         * @param array                       $args Section arguments.
     1164         * @return WP_Customize_Section             The instance of the section that was added
    11611165         */
    11621166        public function add_section( $id, $args = array() ) {
    11631167                if ( $id instanceof WP_Customize_Section ) {
    final class WP_Customize_Manager { 
    11661170                        $section = new WP_Customize_Section( $this, $id, $args );
    11671171                }
    11681172                $this->sections[ $section->id ] = $section;
     1173                return $section;
    11691174        }
    11701175
    11711176        /**
    final class WP_Customize_Manager { 
    12291234         * @param WP_Customize_Control|string $id   Customize Control object, or ID.
    12301235         * @param array                       $args Control arguments; passed to WP_Customize_Control
    12311236         *                                          constructor.
     1237         * @return WP_Customize_Control             The instance of the control that was added
    12321238         */
    12331239        public function add_control( $id, $args = array() ) {
    12341240                if ( $id instanceof WP_Customize_Control ) {
    final class WP_Customize_Manager { 
    12371243                        $control = new WP_Customize_Control( $this, $id, $args );
    12381244                }
    12391245                $this->controls[ $control->id ] = $control;
     1246                return $control;
    12401247        }
    12411248
    12421249        /**
  • tests/phpunit/tests/customize/manager.php

    diff --git tests/phpunit/tests/customize/manager.php tests/phpunit/tests/customize/manager.php
    index 247f765..cc1c183 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 = $this->manager->add_control( 'foo' );
     464                $this->assertInstanceOf( 'WP_Customize_Control', $control );
     465                $this->assertEquals( 'foo', $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 = $this->manager->add_section( 'foo' );
     481                $this->assertInstanceOf( 'WP_Customize_Section', $section );
     482                $this->assertEquals( 'foo', $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 = $this->manager->add_panel( 'foo' );
     498                $this->assertInstanceOf( 'WP_Customize_Panel', $panel );
     499                $this->assertEquals( 'foo', $panel->id );
     500        }
    434501}