Make WordPress Core


Ignore:
Timestamp:
06/24/2015 12:40:45 AM (11 years ago)
Author:
johnbillion
Message:

Implement canonical and url_to_postid() tests for child pages which share a post name with other child pages.

See #32759

File:
1 edited

Legend:

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

    r32708 r32918  
    6262    }
    6363
     64    function test_url_to_postid_hierarchical_with_matching_leaves() {
     65
     66        $parent_id = $this->factory->post->create( array(
     67            'post_name' => 'parent',
     68            'post_type' => 'page',
     69        ) );
     70        $child_id_1 = $this->factory->post->create( array(
     71            'post_name'   => 'child1',
     72            'post_type'   => 'page',
     73            'post_parent' => $parent_id,
     74        ) );
     75        $child_id_2 = $this->factory->post->create( array(
     76            'post_name'   => 'child2',
     77            'post_type'   => 'page',
     78            'post_parent' => $parent_id,
     79        ) );
     80        $grandchild_id_1 = $this->factory->post->create( array(
     81            'post_name'   => 'grandchild',
     82            'post_type'   => 'page',
     83            'post_parent' => $child_id_1,
     84        ) );
     85        $grandchild_id_2 = $this->factory->post->create( array(
     86            'post_name'   => 'grandchild',
     87            'post_type'   => 'page',
     88            'post_parent' => $child_id_2,
     89        ) );
     90
     91        $this->assertEquals( home_url( 'parent/child1/grandchild/' ), get_permalink( $grandchild_id_1 ) );
     92        $this->assertEquals( home_url( 'parent/child2/grandchild/' ), get_permalink( $grandchild_id_2 ) );
     93        $this->assertEquals( $grandchild_id_1, url_to_postid( get_permalink( $grandchild_id_1 ) ) );
     94        $this->assertEquals( $grandchild_id_2, url_to_postid( get_permalink( $grandchild_id_2 ) ) );
     95    }
     96
    6497    function test_url_to_postid_home_has_path() {
    6598
Note: See TracChangeset for help on using the changeset viewer.