Ticket #34596: 34596.2.diff
File 34596.2.diff, 5.7 KB (added by , 9 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..862e65d 100644
final class WP_Customize_Manager { 980 980 * @param WP_Customize_Setting|string $id Customize Setting object, or ID. 981 981 * @param array $args Setting arguments; passed to WP_Customize_Setting 982 982 * constructor. 983 * @return WP_Customize_Setting The instance of the setting that was added 983 984 */ 984 985 public function add_setting( $id, $args = array() ) { 985 986 if ( $id instanceof WP_Customize_Setting ) { … … final class WP_Customize_Manager { 987 988 } else { 988 989 $setting = new WP_Customize_Setting( $this, $id, $args ); 989 990 } 990 $this->settings[ $setting->id ] = $setting;991 return $this->settings[ $setting->id ] = $setting; 991 992 } 992 993 993 994 /** … … final class WP_Customize_Manager { 1084 1085 * 1085 1086 * @param WP_Customize_Panel|string $id Customize Panel object, or Panel ID. 1086 1087 * @param array $args Optional. Panel arguments. Default empty array. 1088 * @return WP_Customize_Panel The instance of the panel that was added 1087 1089 */ 1088 1090 public function add_panel( $id, $args = array() ) { 1089 1091 if ( $id instanceof WP_Customize_Panel ) { … … final class WP_Customize_Manager { 1091 1093 } else { 1092 1094 $panel = new WP_Customize_Panel( $this, $id, $args ); 1093 1095 } 1094 1095 $this->panels[ $panel->id ] = $panel; 1096 return $this->panels[ $panel->id ] = $panel; 1096 1097 } 1097 1098 1098 1099 /** … … final class WP_Customize_Manager { 1158 1159 * 1159 1160 * @param WP_Customize_Section|string $id Customize Section object, or Section ID. 1160 1161 * @param array $args Section arguments. 1162 * @return WP_Customize_Section The instance of the section that was added 1161 1163 */ 1162 1164 public function add_section( $id, $args = array() ) { 1163 1165 if ( $id instanceof WP_Customize_Section ) { … … final class WP_Customize_Manager { 1165 1167 } else { 1166 1168 $section = new WP_Customize_Section( $this, $id, $args ); 1167 1169 } 1168 $this->sections[ $section->id ] = $section;1170 return $this->sections[ $section->id ] = $section; 1169 1171 } 1170 1172 1171 1173 /** … … final class WP_Customize_Manager { 1229 1231 * @param WP_Customize_Control|string $id Customize Control object, or ID. 1230 1232 * @param array $args Control arguments; passed to WP_Customize_Control 1231 1233 * constructor. 1234 * @return WP_Customize_Control The instance of the control that was added 1232 1235 */ 1233 1236 public function add_control( $id, $args = array() ) { 1234 1237 if ( $id instanceof WP_Customize_Control ) { … … final class WP_Customize_Manager { 1236 1239 } else { 1237 1240 $control = new WP_Customize_Control( $this, $id, $args ); 1238 1241 } 1239 $this->controls[ $control->id ] = $control;1242 return $this->controls[ $control->id ] = $control; 1240 1243 } 1241 1244 1242 1245 /** -
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 { 431 431 $sorted_control_ids = wp_list_pluck( $manager->get_section( $section_id )->controls, 'id' ); 432 432 $this->assertEquals( $added_control_ids, $sorted_control_ids ); 433 433 } 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 } 434 501 }