Ticket #57342: 57342.diff
File 57342.diff, 2.7 KB (added by , 2 years ago) |
---|
-
tests/phpunit/tests/query/taxQuery.php
1628 1628 * @covers WP_Tax_Query::transform_query 1629 1629 */ 1630 1630 public function test_tax_terms_should_limit_query() { 1631 $filter = new MockAction();1632 add_filter( 'terms_pre_query', array( $filter, 'filter' ), 10, 2 );1633 1631 register_taxonomy( 'wptests_tax', 'post' ); 1634 1632 $name = 'foobar'; 1635 1633 $t = self::factory()->term->create( … … 1642 1640 $p = self::factory()->post->create(); 1643 1641 wp_set_object_terms( $p, array( $t ), 'wptests_tax' ); 1644 1642 1643 $filter = new MockAction(); 1644 add_filter( 'terms_pre_query', array( $filter, 'filter' ), 10, 2 ); 1645 1645 1646 $q = new WP_Query( 1646 1647 array( 1647 1648 'fields' => 'ids', … … 1656 1657 ); 1657 1658 1658 1659 $filter_args = $filter->get_args(); 1659 $query = $filter_args[ 1][1]->request;1660 $query = $filter_args[0][1]->request; 1660 1661 1661 1662 $this->assertSameSets( array( $p ), $q->posts ); 1662 1663 $this->assertStringContainsString( 'LIMIT 1', $query ); … … 1668 1669 * @covers WP_Tax_Query::transform_query 1669 1670 */ 1670 1671 public function test_tax_terms_should_limit_query_to_one() { 1671 $filter = new MockAction();1672 add_filter( 'terms_pre_query', array( $filter, 'filter' ), 10, 2 );1673 1672 register_taxonomy( 'wptests_tax', 'post' ); 1674 1673 $name = 'foobar'; 1675 1674 $t = self::factory()->term->create( … … 1682 1681 $p = self::factory()->post->create(); 1683 1682 wp_set_object_terms( $p, array( $t ), 'wptests_tax' ); 1684 1683 1684 $filter = new MockAction(); 1685 add_filter( 'terms_pre_query', array( $filter, 'filter' ), 10, 2 ); 1686 1685 1687 $q = new WP_Query( 1686 1688 array( 1687 1689 'fields' => 'ids', … … 1696 1698 ); 1697 1699 1698 1700 $filter_args = $filter->get_args(); 1699 $query = $filter_args[ 1][1]->request;1701 $query = $filter_args[0][1]->request; 1700 1702 1701 1703 $this->assertSameSets( array( $p ), $q->posts ); 1702 1704 $this->assertStringContainsString( 'LIMIT 1', $query ); … … 1708 1710 * @covers WP_Tax_Query::transform_query 1709 1711 */ 1710 1712 public function test_hierarchical_taxonomies_do_not_limit_query() { 1711 $filter = new MockAction();1712 add_filter( 'terms_pre_query', array( $filter, 'filter' ), 10, 2 );1713 1713 register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) ); 1714 1714 $name = 'foobar'; 1715 1715 $t = self::factory()->term->create( … … 1722 1722 $p = self::factory()->post->create(); 1723 1723 wp_set_object_terms( $p, array( $t ), 'wptests_tax' ); 1724 1724 1725 $filter = new MockAction(); 1726 add_filter( 'terms_pre_query', array( $filter, 'filter' ), 10, 2 ); 1727 1725 1728 $q = new WP_Query( 1726 1729 array( 1727 1730 'fields' => 'ids',