Make WordPress Core

Ticket #35368: 35368.2.diff

File 35368.2.diff, 1.6 KB (added by swissspidy, 10 years ago)
  • src/wp-includes/post.php

    diff --git src/wp-includes/post.php src/wp-includes/post.php
    index cc8e843..72ef164 100644
    function _page_traverse_name( $page_id, &$children, &$result ){ 
    42914291 * @return string|false Page URI, false on error.
    42924292 */
    42934293function get_page_uri( $page ) {
    4294         $page = get_post( $page );
     4294        if ( ! $page instanceof WP_Post ) {
     4295                $page = get_post( $page );
     4296        }
    42954297
    42964298        if ( ! $page )
    42974299                return false;
  • tests/phpunit/tests/admin/includesPost.php

    diff --git tests/phpunit/tests/admin/includesPost.php tests/phpunit/tests/admin/includesPost.php
    index c9e92f0..89803cc 100644
    class Tests_Admin_Includes_Post extends WP_UnitTestCase { 
    454454                $this->assertEquals( '30', $found[1] );
    455455        }
    456456
     457        /**
     458         * @ticket 35368
     459         */
     460        public function test_get_sample_permalink_should_respect_hierarchy_of_draft_pages() {
     461                $this->set_permalink_structure( '/%postname%/' );
     462
     463                $parent = self::factory()->post->create( array(
     464                        'post_type'  => 'page',
     465                        'post_title' => 'Parent Page',
     466                ) );
     467
     468                $child = self::factory()->post->create( array(
     469                        'post_type'   => 'page',
     470                        'post_title'  => 'Child Page',
     471                        'post_parent' => $parent,
     472                        'post_status' => 'draft',
     473                ) );
     474
     475                $actual = get_sample_permalink( $child );
     476                $this->assertSame( home_url() . '/parent-page/%pagename%/', $actual[0] );
     477                $this->assertSame( 'child-page', $actual[1] );
     478        }
     479
    457480        public function test_post_exists_should_match_title() {
    458481                $p = self::factory()->post->create( array(
    459482                        'post_title' => 'Foo Bar',