Make WordPress Core


Ignore:
Timestamp:
05/11/2015 01:10:19 PM (9 years ago)
Author:
boonebgorges
Message:

In category dropdown, 'selected' should match against 'value_field'.

Props tlexcellent.
Fixes #32330.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/category.php

    r31622 r32484  
    328328        $this->assertContains( 'value="' . $cat_id . '"', $found );
    329329    }
     330
     331    /**
     332     * @ticket 32330
     333     */
     334    public function test_wp_dropdown_categories_selected_should_respect_custom_value_field() {
     335        $c1 = $this->factory->category->create( array(
     336            'name' => 'Test Category 1',
     337            'slug' => 'test_category_1',
     338        ) );
     339
     340        $c2 = $this->factory->category->create( array(
     341            'name' => 'Test Category 2',
     342            'slug' => 'test_category_2',
     343        ) );
     344
     345        $found = wp_dropdown_categories( array(
     346            'echo' => 0,
     347            'hide_empty' => 0,
     348            'value_field' => 'slug',
     349            'selected' => 'test_category_2',
     350        ) );
     351
     352        $this->assertContains( "value=\"test_category_2\" selected=\"selected\"", $found );
     353    }
    330354}
Note: See TracChangeset for help on using the changeset viewer.