Add test demonstrating that `wp_insert_term()` will suffix a slug if the new term's auto-generated slug matches that of an existing term.
See #37009. git-svn-id: https://develop.svn.wordpress.org/trunk@37641 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
885d38edc8
commit
b189d26960
|
@ -642,6 +642,26 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 37009
|
||||
*/
|
||||
public function test_term_whose_slug_matches_existing_term_but_name_does_not_should_get_suffixed_slug() {
|
||||
register_taxonomy( 'wptests_tax', 'post' );
|
||||
|
||||
$t1 = self::factory()->term->create( array(
|
||||
'name' => 'Foo#bar',
|
||||
'taxonomy' => 'wptests_tax',
|
||||
) );
|
||||
|
||||
$created = wp_insert_term( 'Foo$bar', 'wptests_tax' );
|
||||
|
||||
$this->assertArrayHasKey( 'term_id', $created );
|
||||
|
||||
$created_term = get_term( $created['term_id'] );
|
||||
$this->assertSame( 'Foo$bar', $created_term->name );
|
||||
$this->assertSame( 'foobar-2', $created_term->slug );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 35321
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue