Make WordPress Core

Changeset 32918


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

Location:
trunk/tests/phpunit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/testcase-canonical.php

    r30278 r32918  
    8181                ) );
    8282
     83                self::$post_ids[] = $parent_id = $factory->post->create( array(
     84                        'post_name' => 'parent',
     85                        'post_type' => 'page',
     86                ) );
     87                self::$post_ids[] = $child_id_1 = $factory->post->create( array(
     88                        'post_name'   => 'child1',
     89                        'post_type'   => 'page',
     90                        'post_parent' => $parent_id,
     91                ) );
     92                self::$post_ids[] = $child_id_2 = $factory->post->create( array(
     93                        'post_name'   => 'child2',
     94                        'post_type'   => 'page',
     95                        'post_parent' => $parent_id,
     96                ) );
     97                self::$post_ids[] = $grandchild_id_1 = $factory->post->create( array(
     98                        'post_name'   => 'grandchild',
     99                        'post_type'   => 'page',
     100                        'post_parent' => $child_id_1,
     101                ) );
     102                self::$post_ids[] = $grandchild_id_2 = $factory->post->create( array(
     103                        'post_name'   => 'grandchild',
     104                        'post_type'   => 'page',
     105                        'post_parent' => $child_id_2,
     106                ) );
     107
    83108                $cat1 = $factory->term->create( array( 'taxonomy' => 'category', 'name' => 'parent' ) );
    84109                self::$terms['/category/parent/'] = $cat1;
  • trunk/tests/phpunit/tests/canonical.php

    r31622 r32918  
    8080                        array( '/?page_id=144', '/parent-page/child-page-1/'),
    8181                        array( '/abo', '/about/' ),
     82                        array( '/parent/child1/grandchild/', '/parent/child1/grandchild/' ),
     83                        array( '/parent/child2/grandchild/', '/parent/child2/grandchild/' ),
    8284
    8385                        // Posts
  • 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.