Make WordPress Core

Ticket #33728: 33728.tests.patch

File 33728.tests.patch, 1.2 KB (added by johnbillion, 9 years ago)
  • tests/phpunit/tests/rewrite/addRewriteEndpoint.php

     
    112112                $this->assertSame( '', get_query_var( 'page_endpoint' ) );
    113113        }
    114114
     115        /**
     116         * @ticket 33728
     117         */
     118        public function test_taxonomy_endpoint_only_applies_on_taxonomy_archive() {
     119                $tax = register_taxonomy( 'foo', 'post', array(
     120                        'public' => true,
     121                ) );
     122                $test_term_id = self::factory()->term->create( array(
     123                        'taxonomy' => 'foo',
     124                ) );
     125
     126                add_rewrite_endpoint( 'taxonomy_endpoint', EP_TAXONOMIES );
     127                flush_rewrite_rules();
     128
     129                $this->go_to( get_term_link( $test_term_id ) . 'taxonomy_endpoint/foo/' );
     130
     131                $this->assertTrue( is_tax( 'foo', $test_term_id ) );
     132                $this->assertSame( 'foo', get_query_var( 'taxonomy_endpoint' ) );
     133
     134                // $this->go_to( home_url( 'taxonomy_endpoint/foo/' ) );
     135                $this->go_to( get_permalink( self::$test_post_id ) . 'taxonomy_endpoint/foo/' );
     136
     137                $this->assertTrue( is_404() );
     138                $this->assertSame( '', get_query_var( 'taxonomy_endpoint' ) );
     139        }
    115140}