Make WordPress Core


Ignore:
Timestamp:
11/01/2014 08:36:23 PM (10 years ago)
Author:
wonderboymusic
Message:

All duplicate slugs across different post types.

Adds unit test.

Props mboynes, nacin.
Fixes #18962.

File:
1 edited

Legend:

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

    r29789 r30158  
    992992    }
    993993
     994    /**
     995     * @ticket 18962
     996     */
     997    function test_wp_unique_post_slug_with_multiple_hierarchies() {
     998        register_post_type( 'post-type-1', array( 'hierarchical' => true ) );
     999        register_post_type( 'post-type-2', array( 'hierarchical' => true ) );
     1000
     1001        $args = array(
     1002            'post_type' => 'post-type-1',
     1003            'post_name' => 'some-slug',
     1004            'post_status' => 'publish',
     1005        );
     1006        $one = $this->factory->post->create( $args );
     1007        $args['post_type'] = 'post-type-2';
     1008        $two = $this->factory->post->create( $args );
     1009
     1010        $this->assertEquals( 'some-slug', get_post( $one )->post_name );
     1011        $this->assertEquals( 'some-slug', get_post( $two )->post_name );
     1012
     1013        $this->assertEquals( 'some-other-slug', wp_unique_post_slug( 'some-other-slug', $one, 'publish', 'post-type-1', 0 ) );
     1014        $this->assertEquals( 'some-other-slug', wp_unique_post_slug( 'some-other-slug', $one, 'publish', 'post-type-2', 0 ) );
     1015
     1016        _unregister_post_type( 'post-type-1' );
     1017        _unregister_post_type( 'post-type-2' );
     1018    }
    9941019}
Note: See TracChangeset for help on using the changeset viewer.