WordPress.org

Make WordPress Core

Ticket #26284: 26284.2.diff

File 26284.2.diff, 1.4 KB (added by ericlewis, 5 years ago)
  • src/wp-includes/post.php

     
    44284428 * Sub pages will be in the "directory" under the parent page post name.
    44294429 *
    44304430 * @since 1.5.0
     4431 * @since 4.6.0 The $page parameter is optional.
    44314432 *
    4432  * @param WP_Post|object|int $page Page object or page ID.
     4433 * @param WP_Post|object|int $page Optional. Page ID or WP_Post object. Default is global $post.
    44334434 * @return string|false Page URI, false on error.
    44344435 */
    4435 function get_page_uri( $page ) {
     4436function get_page_uri( $page = 0 ) {
    44364437        if ( ! $page instanceof WP_Post ) {
    44374438                $page = get_post( $page );
    44384439        }
  • tests/phpunit/tests/post/getPageUri.php

     
     1<?php
     2
     3/**
     4 * @group post
     5 */
     6class Tests_Post_getPageUri extends WP_UnitTestCase {
     7
     8        function test_get_page_uri_without_argument() {
     9                $post_id = self::factory()->post->create(array(
     10                        'post_title' => 'Blood Orange announces summer tour dates',
     11                        'post_name' => 'blood-orange-announces-summer-tour-dates',
     12                ));
     13                $post = get_post( $post_id );
     14                $this->go_to( get_permalink( $post_id ) );
     15                $this->assertEquals( 'blood-orange-announces-summer-tour-dates', get_page_uri() );
     16        }
     17}