WordPress.org

Make WordPress Core

Changeset 37641


Ignore:
Timestamp:
06/06/2016 09:03:34 PM (4 years ago)
Author:
boonebgorges
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/term/wpInsertTerm.php

    r36214 r37641  
    644644
    645645    /**
     646     * @ticket 37009
     647     */
     648    public function test_term_whose_slug_matches_existing_term_but_name_does_not_should_get_suffixed_slug() {
     649        register_taxonomy( 'wptests_tax', 'post' );
     650
     651        $t1 = self::factory()->term->create( array(
     652            'name' => 'Foo#bar',
     653            'taxonomy' => 'wptests_tax',
     654        ) );
     655
     656        $created = wp_insert_term( 'Foo$bar', 'wptests_tax' );
     657
     658        $this->assertArrayHasKey( 'term_id', $created );
     659
     660        $created_term = get_term( $created['term_id'] );
     661        $this->assertSame( 'Foo$bar', $created_term->name );
     662        $this->assertSame( 'foobar-2', $created_term->slug );
     663    }
     664
     665    /**
    646666     * @ticket 35321
    647667     */
Note: See TracChangeset for help on using the changeset viewer.