Make WordPress Core


Ignore:
Timestamp:
09/10/2015 04:53:52 PM (9 years ago)
Author:
wonderboymusic
Message:

In get_page_uri(), do not add parent slugs to orphaned pages.

Adds unit test.

Props filosofo, MikeHansenMe, MikeHansenMe, chriscct7.
Fixes #15963.

File:
1 edited

Legend:

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

    r33910 r34001  
    652652
    653653    /**
     654     * @ticket 15963
     655     */
     656    function test_get_post_uri_check_orphan() {
     657        $parent_id = $this->factory->post->create( array( 'post_name' => 'parent' ) );
     658        $child_id = $this->factory->post->create( array( 'post_name' => 'child', 'post_parent' => $parent_id ) );
     659
     660        // check the parent for good measure
     661        $this->assertEquals( 'parent', get_page_uri( $parent_id ) );
     662
     663        // try the child normally
     664        $this->assertEquals( 'parent/child', get_page_uri( $child_id ) );
     665
     666        // now delete the parent and check
     667        wp_delete_post( $parent_id );
     668        $this->assertEquals( 'child', get_page_uri( $child_id ) );
     669    }
     670
     671    /**
    654672     * @ticket 23708
    655673     */
Note: See TracChangeset for help on using the changeset viewer.