Changeset 44373 for trunk/tests/phpunit/tests/user/query.php
- Timestamp:
- 12/29/2018 04:05:50 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/user/query.php
r43571 r44373 1691 1691 $this->assertEquals( array(), $ids ); 1692 1692 } 1693 1694 /** 1695 * @ticket 44169 1696 */ 1697 public function test_users_pre_query_filter_should_bypass_database_query() { 1698 global $wpdb; 1699 1700 add_filter( 'users_pre_query', array( __CLASS__, 'filter_users_pre_query' ), 10, 2 ); 1701 1702 $num_queries = $wpdb->num_queries; 1703 $q = new WP_User_Query( 1704 array( 1705 'fields' => 'ID', 1706 ) 1707 ); 1708 1709 remove_filter( 'users_pre_query', array( __CLASS__, 'filter_users_pre_query' ), 10, 2 ); 1710 1711 // Make sure no queries were executed. 1712 $this->assertSame( $num_queries, $wpdb->num_queries ); 1713 1714 // We manually inserted a non-existing user and overrode the results with it. 1715 $this->assertSame( array( 555 ), $q->results ); 1716 1717 // Make sure manually setting total_users doesn't get overwritten. 1718 $this->assertEquals( 1, $q->total_users ); 1719 } 1720 1721 public static function filter_users_pre_query( $posts, $query ) { 1722 $query->total_users = 1; 1723 1724 return array( 555 ); 1725 } 1693 1726 }
Note: See TracChangeset
for help on using the changeset viewer.