Make WordPress Core

Ticket #43689: 43689.test.diff

File 43689.test.diff, 1.7 KB (added by soulseekah, 8 years ago)

test scenario

  • tests/phpunit/tests/link/getAdjacentPostLink.php

    diff --git tests/phpunit/tests/link/getAdjacentPostLink.php tests/phpunit/tests/link/getAdjacentPostLink.php
    index acaec39..e69ee9e 100644
    class Tests_Link_GetAdjacentPostLink extends WP_UnitTestCase {  
    9494                $expected = '&laquo; <a href="' . home_url( '?p=' . $this->post_ids[3] ) . '" rel="prev">' . $title . '</a>';
    9595                $this->assertSame( $expected, $actual );
    9696        }
     97
     98        /**
     99         * @ticket 43689
     100         */
     101        public function test_get_next_post_link_same_term_custom_taxonomy_cpt() {
     102                register_post_type( 'wp_tests_cpt_same_ct', array() );
     103                register_taxonomy( 'wp_tests_ct', array( 'wp_tests_cpt_same_ct' ) );
     104
     105                $p1 = $this->factory->post->create( array(
     106                        'post_type'   => 'wp_tests_cpt_same_ct',
     107                        'post_date'   => '2018-04-08 01:00:00',
     108                        'post_status' => 'publish',
     109                ) );
     110
     111                $p2 = $this->factory->post->create( array(
     112                        'post_type'   => 'wp_tests_cpt_same_ct',
     113                        'post_date'   => '2018-04-08 02:00:00',
     114                        'post_status' => 'publish',
     115                ) );
     116
     117                $p3 = $this->factory->post->create( array(
     118                        'post_type'   => 'wp_tests_cpt_same_ct',
     119                        'post_date'   => '2018-04-08 03:00:00',
     120                        'post_status' => 'publish',
     121                ) );
     122
     123                wp_set_object_terms( $p1, array( 'developer' ), 'wp_tests_ct' );
     124                wp_set_object_terms( $p2, array( 'designer' ), 'wp_tests_ct' );
     125                wp_set_object_terms( $p3, array( 'developer' ), 'wp_tests_ct' );
     126
     127                $GLOBALS['post'] = get_post( $p1 );
     128
     129                $actual = get_next_post_link( '&laquo; %link', '%title', true, array(), 'wp_tests_ct' );
     130
     131                $title    = get_post( $p3 )->post_title;
     132                $expected = '&laquo; <a href="' . get_permalink( $p3 ) . '" rel="next">' . $title . '</a>';
     133                $this->assertSame( $expected, $actual );
     134        }
    97135}