|
@@ 862-878 (lines=17) @@
|
| 859 |
|
/** |
| 860 |
|
* @ticket 32250 |
| 861 |
|
*/ |
| 862 |
|
public function test_has_published_posts_should_obey_post_types() |
| 863 |
|
{ |
| 864 |
|
register_post_type('wptests_pt_public', array( 'public' => true )); |
| 865 |
|
register_post_type('wptests_pt_private', array( 'public' => false )); |
| 866 |
|
|
| 867 |
|
self::factory()->post->create(array( 'post_author' => self::$author_ids[0], 'post_status' => 'publish', 'post_type' => 'wptests_pt_public' )); |
| 868 |
|
self::factory()->post->create(array( 'post_author' => self::$author_ids[1], 'post_status' => 'publish', 'post_type' => 'wptests_pt_private' )); |
| 869 |
|
self::factory()->post->create(array( 'post_author' => self::$author_ids[2], 'post_status' => 'publish', 'post_type' => 'post' )); |
| 870 |
|
|
| 871 |
|
$q = new WP_User_Query( |
| 872 |
|
array( |
| 873 |
|
'has_published_posts' => array( 'wptests_pt_private', 'post' ), |
| 874 |
|
) |
| 875 |
|
); |
| 876 |
|
|
| 877 |
|
$found = wp_list_pluck($q->get_results(), 'ID'); |
| 878 |
|
$expected = array( self::$author_ids[1], self::$author_ids[2] ); |
| 879 |
|
|
| 880 |
|
$this->assertEqualSets($expected, $found); |
| 881 |
|
} |
|
@@ 886-902 (lines=17) @@
|
| 883 |
|
/** |
| 884 |
|
* @ticket 32250 |
| 885 |
|
*/ |
| 886 |
|
public function test_has_published_posts_should_ignore_non_published_posts() |
| 887 |
|
{ |
| 888 |
|
register_post_type('wptests_pt_public', array( 'public' => true )); |
| 889 |
|
register_post_type('wptests_pt_private', array( 'public' => false )); |
| 890 |
|
|
| 891 |
|
self::factory()->post->create(array( 'post_author' => self::$author_ids[0], 'post_status' => 'draft', 'post_type' => 'wptests_pt_public' )); |
| 892 |
|
self::factory()->post->create(array( 'post_author' => self::$author_ids[1], 'post_status' => 'inherit', 'post_type' => 'wptests_pt_private' )); |
| 893 |
|
self::factory()->post->create(array( 'post_author' => self::$author_ids[2], 'post_status' => 'publish', 'post_type' => 'post' )); |
| 894 |
|
|
| 895 |
|
$q = new WP_User_Query( |
| 896 |
|
array( |
| 897 |
|
'has_published_posts' => array( 'wptests_pt_public', 'wptests_pt_private', 'post' ), |
| 898 |
|
) |
| 899 |
|
); |
| 900 |
|
|
| 901 |
|
$found = wp_list_pluck($q->get_results(), 'ID'); |
| 902 |
|
$expected = array( self::$author_ids[2] ); |
| 903 |
|
|
| 904 |
|
$this->assertEqualSets($expected, $found); |
| 905 |
|
} |