Make WordPress Core


Ignore:
Timestamp:
03/24/2014 09:29:14 PM (13 years ago)
Author:
nacin
Message:

Use the current post's post type when determining post adjacency.

props ethitter.
fixes #26937.

File:
1 edited

Legend:

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

    r27635 r27692  
    176176                $post_one = $this->factory->post->create_and_get( array(
    177177                        'post_title' => 'First',
    178                         'post_date' => '2012-01-01 12:00:00'
     178                        'post_date'  => '2012-01-01 12:00:00',
    179179                ) );
    180180
    181181                $post_two = $this->factory->post->create_and_get( array(
    182182                        'post_title' => 'Second',
    183                         'post_date' => '2012-02-01 12:00:00'
     183                        'post_date'  => '2012-02-01 12:00:00',
    184184                ) );
    185185
    186186                $post_three = $this->factory->post->create_and_get( array(
    187187                        'post_title' => 'Third',
    188                         'post_date' => '2012-03-01 12:00:00'
     188                        'post_date'  => '2012-03-01 12:00:00',
    189189                ) );
    190190
    191191                $post_four = $this->factory->post->create_and_get( array(
    192192                        'post_title' => 'Fourth',
    193                         'post_date' => '2012-04-01 12:00:00'
     193                        'post_date'  => '2012-04-01 12:00:00',
     194                ) );
     195
     196                // Use pages to test post-type adjacency
     197                $page_one = $this->factory->post->create_and_get( array(
     198                        'post_title' => 'First Page',
     199                        'post_date'  => '2013-01-01 12:00:00',
     200                        'post_type'  => 'page',
     201                ) );
     202
     203                $page_two = $this->factory->post->create_and_get( array(
     204                        'post_title' => 'Second Page',
     205                        'post_date'  => '2013-02-01 12:00:00',
     206                        'post_type'  => 'page',
    194207                ) );
    195208
    … …  
    234247                $this->assertEquals( $post_three, get_adjacent_post( false, null, false ) );
    235248                remove_filter( 'get_next_post_sort', array( $this, 'filter_next_post_sort_limit' ) );
     249
     250                // Test post-type specificity
     251                $this->go_to( get_permalink( $page_one ) );
     252                $this->assertEquals( $page_two, get_adjacent_post( false, null, false ) );
     253
     254                $this->go_to( get_permalink( $page_two ) );
     255                $this->assertEquals( $page_one, get_adjacent_post( false, null, true ) );
    236256        }
    237257
Note: See TracChangeset for help on using the changeset viewer.