Make WordPress Core

Ticket #35619: 35619.2.patch

File 35619.2.patch, 1.5 KB (added by Chouby, 9 years ago)
  • src/wp-includes/query.php

     
    28572857                                                } else {
    28582858                                                        $q['term_id'] = $queried_items['terms'][0];
    28592859                                                }
     2860                                                break; // we got one, break the loop
    28602861                                        }
    28612862                                }
    28622863                        }
  • tests/phpunit/tests/query.php

     
    522522
    523523                $this->assertSame( array( $p2 ), $q->posts );
    524524        }
     525
     526        /**
     527         * @ticket 35619
     528         */
     529        public function test_query_two_custom_taxonomies() {
     530                register_taxonomy( 'tax1', 'post' );
     531                register_taxonomy( 'tax2', 'post' );
     532
     533                $term1 = $this->factory->term->create( array( 'taxonomy' => 'tax1', 'name' => 'term1' ) );
     534                $term2 = $this->factory->term->create( array( 'taxonomy' => 'tax2', 'name' => 'term2' ) );
     535                $post_id = $this->factory->post->create();
     536                wp_set_object_terms( $post_id, 'term1', 'tax1' );
     537                wp_set_object_terms( $post_id, 'term2', 'tax2' );
     538
     539                $this->assertTrue( is_object_in_term( $post_id, 'tax1' , $term1 ) );
     540                $this->assertTrue( is_object_in_term( $post_id, 'tax2' , $term2 ) );
     541
     542                $this->go_to( home_url('?tax1=term1&tax2=term2') );
     543                $queried_object = get_queried_object();
     544
     545                $this->assertEquals( get_query_var('taxonomy'), $queried_object->taxonomy );
     546                $this->assertEquals( get_query_var('term'), $queried_object->slug );
     547        }
    525548}