| | 400 | |
| | 401 | /** |
| | 402 | * @ticket 30225 |
| | 403 | * @ticket 34594 |
| | 404 | */ |
| | 405 | function test_prepare_controls_stable_sorting() { |
| | 406 | $manager = new WP_Customize_Manager(); |
| | 407 | $manager->register_controls(); |
| | 408 | $section_id = 'foo-section'; |
| | 409 | wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); |
| | 410 | $manager->add_section( $section_id, array( |
| | 411 | 'title' => 'Section', |
| | 412 | 'priority' => 1, |
| | 413 | ) ); |
| | 414 | |
| | 415 | $added_control_ids = array(); |
| | 416 | $count = 9; |
| | 417 | for ( $i = 0; $i < $count; $i += 1 ) { |
| | 418 | $id = 'sort-test-' . $i; |
| | 419 | $added_control_ids[] = $id; |
| | 420 | $manager->add_setting( $id ); |
| | 421 | $control = new WP_Customize_Control( $manager, $id, array( |
| | 422 | 'section' => $section_id, |
| | 423 | 'priority' => 1, |
| | 424 | 'setting' => $id, |
| | 425 | ) ); |
| | 426 | $manager->add_control( $control ); |
| | 427 | } |
| | 428 | |
| | 429 | $manager->prepare_controls(); |
| | 430 | |
| | 431 | $sorted_control_ids = wp_list_pluck( $manager->get_section( $section_id )->controls, 'id' ); |
| | 432 | $this->assertEquals( $added_control_ids, $sorted_control_ids ); |
| | 433 | } |