| 989 | * @ticket 18962 |
| 990 | */ |
| 991 | function test_wp_unique_post_slug_with_hierarchy_and_attachments() { |
| 992 | register_post_type( 'post-type-1', array( 'hierarchical' => true ) ); |
| 993 | |
| 994 | $args = array( |
| 995 | 'post_type' => 'post-type-1', |
| 996 | 'post_name' => 'some-slug', |
| 997 | 'post_status' => 'publish', |
| 998 | ); |
| 999 | $one = $this->factory->post->create( $args ); |
| 1000 | |
| 1001 | $args = array( |
| 1002 | 'post_mime_type' => 'image/jpeg', |
| 1003 | 'post_type' => 'attachment', |
| 1004 | 'post_name' => 'image' |
| 1005 | ); |
| 1006 | $attachment = $this->factory->attachment->create_object( 'image.jpg', $one, $args ); |
| 1007 | |
| 1008 | $args = array( |
| 1009 | 'post_type' => 'post-type-1', |
| 1010 | 'post_name' => 'image', |
| 1011 | 'post_status' => 'publish', |
| 1012 | 'post_parent' => $one |
| 1013 | ); |
| 1014 | $two = $this->factory->post->create( $args ); |
| 1015 | |
| 1016 | $this->assertEquals( 'some-slug', get_post( $one )->post_name ); |
| 1017 | $this->assertEquals( 'image', get_post( $attachment )->post_name ); |
| 1018 | $this->assertEquals( 'image-2', get_post( $two )->post_name ); |
| 1019 | |
| 1020 | // 'image' can be a child of image-2 |
| 1021 | $this->assertEquals( 'image', wp_unique_post_slug( 'image', 0, 'publish', 'post-type-1', $two ) ); |
| 1022 | |
| 1023 | _unregister_post_type( 'post-type-1' ); |
| 1024 | } |
| 1025 | |
| 1026 | /** |