- Timestamp:
- 05/19/2016 02:38:33 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/category/wpDropdownCategories.php
r37464 r37465 154 154 } 155 155 } 156 157 /** 158 * @ticket 31909 159 */ 160 public function test_required_true_should_add_required_attribute() { 161 // Create a test category. 162 $cat_id = self::factory()->category->create( array( 163 'name' => 'Test Category', 164 'slug' => 'test_category', 165 ) ); 166 167 $args = array( 168 'show_option_none' => __( 'Select one', 'text-domain' ), 169 'option_none_value' => "", 170 'required' => true, 171 'hide_empty' => 0, 172 'echo' => 0, 173 ); 174 $dropdown_categories = wp_dropdown_categories( $args ); 175 176 // Test to see if it contains the "required" attribute. 177 $this->assertRegExp( '/<select[^>]+required/', $dropdown_categories ); 178 } 179 180 /** 181 * @ticket 31909 182 */ 183 public function test_required_false_should_omit_required_attribute() { 184 // Create a test category. 185 $cat_id = self::factory()->category->create( array( 186 'name' => 'Test Category', 187 'slug' => 'test_category', 188 ) ); 189 190 $args = array( 191 'show_option_none' => __( 'Select one', 'text-domain' ), 192 'option_none_value' => "", 193 'required' => false, 194 'hide_empty' => 0, 195 'echo' => 0, 196 ); 197 $dropdown_categories = wp_dropdown_categories( $args ); 198 199 // Test to see if it contains the "required" attribute. 200 $this->assertNotRegExp( '/<select[^>]+required/', $dropdown_categories ); 201 } 202 203 /** 204 * @ticket 31909 205 */ 206 public function test_required_should_default_to_false() { 207 // Create a test category. 208 $cat_id = self::factory()->category->create( array( 209 'name' => 'Test Category', 210 'slug' => 'test_category', 211 ) ); 212 213 $args = array( 214 'show_option_none' => __( 'Select one', 'text-domain' ), 215 'option_none_value' => "", 216 'hide_empty' => 0, 217 'echo' => 0, 218 ); 219 $dropdown_categories = wp_dropdown_categories( $args ); 220 221 // Test to see if it contains the "required" attribute. 222 $this->assertNotRegExp( '/<select[^>]+required/', $dropdown_categories ); 223 } 156 224 }
Note: See TracChangeset
for help on using the changeset viewer.