| 685 | function test_attachment_and_child_page_name_conflict() { |
| 686 | // Bug - http://core.trac.wordpress.org/ticket/15665 |
| 687 | // Page name won't work if the parent page has an attachment with the same name |
| 688 | $this->_insert_quick_posts(1, 'page'); |
| 689 | $parent_page_id = $this->post_ids[-1]; |
| 690 | |
| 691 | // Give it an attachment |
| 692 | $shared_title = 'conflicted_name'; |
| 693 | |
| 694 | $attachment = array( |
| 695 | 'post_title' => $shared_title, |
| 696 | 'post_content' => '', |
| 697 | 'post_type' => 'attachment', |
| 698 | 'post_parent' => $parent_post_id, |
| 699 | 'post_mime_type' => 'text/plain', |
| 700 | ); |
| 701 | $attachment_id = wp_insert_attachment( $attachment, false, $parent_post_id ); |
| 702 | |
| 703 | // Create a child post with the same name |
| 704 | $child_page_id = $this->post_ids[] = wp_insert_post(array( |
| 705 | 'post_author' => $this->author->ID, |
| 706 | 'post_status' => 'publish', |
| 707 | 'post_title' => $shared_title, |
| 708 | 'post_content' => 'child page content', |
| 709 | 'post_excerpt' => 'child page excerpt', |
| 710 | 'post_type' => 'page' |
| 711 | )); |
| 712 | |
| 713 | // Check that the child page is accessible |
| 714 | $this->http(get_permalink($child_page_id)); |
| 715 | $this->assertTrue(is_page(), 'failed is_page'); |
| 716 | $this->assertTrue(have_posts(), 'no posts found querying child page id permalink'); |
| 717 | $this->assertNull(the_post(), 'error loading queried post'); |
| 718 | $this->assertEquals($child_page_id, get_the_ID(), 'child page id does not equal found post id'); |
| 719 | $this->assertEquals('child page excerpt', strip_tags(strip_ws(get_echo('the_excerpt'))), 'the child page excerpt and the queried page excerpt do not match'); |
| 720 | } |