Ticket #34596: 34596.3.diff
File 34596.3.diff, 5.4 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..6351a23 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 { 988 989 $setting = new WP_Customize_Setting( $this, $id, $args ); 989 990 } 990 991 $this->settings[ $setting->id ] = $setting; 992 return $setting; 991 993 } 992 994 993 995 /** … … final class WP_Customize_Manager { 1084 1086 * 1085 1087 * @param WP_Customize_Panel|string $id Customize Panel object, or Panel ID. 1086 1088 * @param array $args Optional. Panel arguments. Default empty array. 1089 * @return WP_Customize_Panel The instance of the panel that was added 1087 1090 */ 1088 1091 public function add_panel( $id, $args = array() ) { 1089 1092 if ( $id instanceof WP_Customize_Panel ) { … … final class WP_Customize_Manager { 1091 1094 } else { 1092 1095 $panel = new WP_Customize_Panel( $this, $id, $args ); 1093 1096 } 1094 1095 1097 $this->panels[ $panel->id ] = $panel; 1098 return $panel; 1096 1099 } 1097 1100 1098 1101 /** … … final class WP_Customize_Manager { 1158 1161 * 1159 1162 * @param WP_Customize_Section|string $id Customize Section object, or Section ID. 1160 1163 * @param array $args Section arguments. 1164 * @return WP_Customize_Section The instance of the section that was added 1161 1165 */ 1162 1166 public function add_section( $id, $args = array() ) { 1163 1167 if ( $id instanceof WP_Customize_Section ) { … … final class WP_Customize_Manager { 1166 1170 $section = new WP_Customize_Section( $this, $id, $args ); 1167 1171 } 1168 1172 $this->sections[ $section->id ] = $section; 1173 return $section; 1169 1174 } 1170 1175 1171 1176 /** … … final class WP_Customize_Manager { 1229 1234 * @param WP_Customize_Control|string $id Customize Control object, or ID. 1230 1235 * @param array $args Control arguments; passed to WP_Customize_Control 1231 1236 * constructor. 1237 * @return WP_Customize_Control The instance of the control that was added 1232 1238 */ 1233 1239 public function add_control( $id, $args = array() ) { 1234 1240 if ( $id instanceof WP_Customize_Control ) { … … final class WP_Customize_Manager { 1237 1243 $control = new WP_Customize_Control( $this, $id, $args ); 1238 1244 } 1239 1245 $this->controls[ $control->id ] = $control; 1246 return $control; 1240 1247 } 1241 1248 1242 1249 /** -
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 { 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 = $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 } 434 501 }