mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-03-31 10:44:26 +00:00
Taxonomy: Make sure wp_terms_checklist() and Walker_Category_Checklist::start_el() properly handle an array of strings as selected_cats or popular_cats values.
Even with these values documented as an array of integers, they can technically also accept an array of strings, e.g. as form results. Add a unit test. Props brianhogg, TimothyBlynJacobs, SergeyBiryukov. Fixes #51137. git-svn-id: https://develop.svn.wordpress.org/trunk@48880 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
* @group admin
|
||||
*/
|
||||
class Tests_Admin_includesTemplate extends WP_UnitTestCase {
|
||||
|
||||
function test_equal() {
|
||||
$this->assertEquals( ' selected=\'selected\'', selected( 'foo', 'foo', false ) );
|
||||
$this->assertEquals( ' checked=\'checked\'', checked( 'foo', 'foo', false ) );
|
||||
@@ -46,6 +47,45 @@ class Tests_Admin_includesTemplate extends WP_UnitTestCase {
|
||||
$this->assertEquals( '', checked( 0, false, false ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 51147
|
||||
* @dataProvider data_wp_terms_checklist_with_selected_cats
|
||||
*/
|
||||
public function test_wp_terms_checklist_with_selected_cats( $term_id ) {
|
||||
$output = wp_terms_checklist(
|
||||
0,
|
||||
array(
|
||||
'selected_cats' => array( $term_id ),
|
||||
'echo' => false,
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertContains( "checked='checked'", $output );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 51147
|
||||
* @dataProvider data_wp_terms_checklist_with_selected_cats
|
||||
*/
|
||||
public function test_wp_terms_checklist_with_popular_cats( $term_id ) {
|
||||
$output = wp_terms_checklist(
|
||||
0,
|
||||
array(
|
||||
'popular_cats' => array( $term_id ),
|
||||
'echo' => false,
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertContains( 'class="popular-category"', $output );
|
||||
}
|
||||
|
||||
public function data_wp_terms_checklist_with_selected_cats() {
|
||||
return array(
|
||||
array( '1' ),
|
||||
array( 1 ),
|
||||
);
|
||||
}
|
||||
|
||||
public function test_add_meta_box() {
|
||||
global $wp_meta_boxes;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user