Changeset 29830 for trunk/tests/phpunit/tests/taxonomy.php
- Timestamp:
- 10/03/2014 01:30:22 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/taxonomy.php
r28926 r29830 235 235 $this->assertEquals( 0, wp_insert_category( $cat, false ) ); 236 236 } 237 238 /**239 * @ticket 17689240 */241 function test_duplicate_name() {242 $term = $this->factory->tag->create_and_get( array( 'name' => 'Bozo' ) );243 $this->assertFalse( is_wp_error( $term ) );244 $this->assertTrue( empty( $term->errors ) );245 246 // Test existing term name with unique slug247 $term1 = $this->factory->tag->create( array( 'name' => 'Bozo', 'slug' => 'bozo1' ) );248 $this->assertFalse( is_wp_error( $term1 ) );249 $this->assertTrue( empty($term1->errors ) );250 251 // Test an existing term name252 $term2 = $this->factory->tag->create( array( 'name' => 'Bozo' ) );253 $this->assertTrue( is_wp_error( $term2 ) );254 $this->assertNotEmpty( $term2->errors );255 256 // Test named terms ending in special characters257 $term3 = $this->factory->tag->create( array( 'name' => 'T$' ) );258 $term4 = $this->factory->tag->create( array( 'name' => 'T$$' ) );259 $term5 = $this->factory->tag->create( array( 'name' => 'T$$$' ) );260 $term6 = $this->factory->tag->create( array( 'name' => 'T$$$$' ) );261 $term7 = $this->factory->tag->create( array( 'name' => 'T$$$$' ) );262 $this->assertTrue( is_wp_error( $term7 ) );263 $this->assertNotEmpty( $term7->errors );264 $this->assertEquals( $term6, $term7->error_data['term_exists'] );265 266 $terms = array_map( 'get_tag', array( $term3, $term4, $term5, $term6 ) );267 $this->assertCount( 4, array_unique( wp_list_pluck( $terms, 'slug' ) ) );268 269 // Test named terms with only special characters270 $term8 = $this->factory->tag->create( array( 'name' => '$' ) );271 $term9 = $this->factory->tag->create( array( 'name' => '$$' ) );272 $term10 = $this->factory->tag->create( array( 'name' => '$$$' ) );273 $term11 = $this->factory->tag->create( array( 'name' => '$$$$' ) );274 $term12 = $this->factory->tag->create( array( 'name' => '$$$$' ) );275 $this->assertTrue( is_wp_error( $term12 ) );276 $this->assertNotEmpty( $term12->errors );277 $this->assertEquals( $term11, $term12->error_data['term_exists'] );278 279 $terms = array_map( 'get_tag', array( $term8, $term9, $term10, $term11 ) );280 $this->assertCount( 4, array_unique( wp_list_pluck( $terms, 'slug' ) ) );281 282 $term13 = $this->factory->tag->create( array( 'name' => 'A' ) );283 $this->assertFalse( is_wp_error( $term13 ) );284 $term14 = $this->factory->tag->create( array( 'name' => 'A' ) );285 $this->assertTrue( is_wp_error( $term14 ) );286 $term15 = $this->factory->tag->create( array( 'name' => 'A+', 'slug' => 'a' ) );287 $this->assertFalse( is_wp_error( $term15 ) );288 $term16 = $this->factory->tag->create( array( 'name' => 'A+' ) );289 $this->assertTrue( is_wp_error( $term16 ) );290 $term17 = $this->factory->tag->create( array( 'name' => 'A++' ) );291 $this->assertFalse( is_wp_error( $term17 ) );292 $term18 = $this->factory->tag->create( array( 'name' => 'A-', 'slug' => 'a' ) );293 $this->assertFalse( is_wp_error( $term18 ) );294 $term19 = $this->factory->tag->create( array( 'name' => 'A-' ) );295 $this->assertTrue( is_wp_error( $term19 ) );296 $term20 = $this->factory->tag->create( array( 'name' => 'A--' ) );297 $this->assertFalse( is_wp_error( $term20 ) );298 }299 237 }
Note: See TracChangeset
for help on using the changeset viewer.