Make WordPress Core

Ticket #15665: 15665-unit-2.patch

File 15665-unit-2.patch, 2.5 KB (added by devesine, 11 years ago)
  • wp-testcase/test_includes_post.php

     
    470470}
    471471
    472472class WPTestAttachments extends _WPEmptyBlog {
     473        function setUp() {
     474                parent::setUp();
     475                global $wp_rewrite;
     476                $wp_rewrite->set_permalink_structure('/%year%/%monthnum%/%day%/%postname%/');
     477                create_initial_taxonomies();
     478                $wp_rewrite->flush_rules();
     479 
    473480
     481        }
     482
    474483        function tearDown() {
     484                global $wp_rewrite;
     485                $wp_rewrite->set_permalink_structure('');
    475486                parent::tearDown();
    476487                // restore system defaults
    477488                update_option('medium_size_w', '');
     
    671682                $this->assertFalse( is_file($original) );
    672683        }
    673684
     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        }
    674721}
    675722
    676723class WPTestPostMeta extends WPTestCase {