Changeset 56708 for trunk/tests/phpunit/tests/sitemaps/wpSitemapsUsers.php
- Timestamp:
- 09/26/2023 12:40:36 PM (17 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/sitemaps/wpSitemapsUsers.php
r51492 r56708 3 3 /** 4 4 * @group sitemaps 5 * 6 * @coversDefaultClass WP_Sitemaps_Users 5 7 */ 6 8 class Tests_Sitemaps_wpSitemapsUsers extends WP_UnitTestCase { … … 11 13 * @var array 12 14 */ 13 p ublicstatic $users;15 private static $users; 14 16 15 17 /** … … 18 20 * @var int 19 21 */ 20 p ublicstatic $editor_id;22 private static $editor_id; 21 23 22 24 /** … … 33 35 * Test getting a URL list for a users sitemap page via 34 36 * WP_Sitemaps_Users::get_url_list(). 37 * 38 * @covers ::get_url_list 35 39 */ 36 40 public function test_get_url_list_users() { … … 41 45 $expected = array_map( 42 46 static function ( $user_id ) { 43 $post = self::factory()->post->create_and_get( array( 'post_author' => $user_id ) );47 self::factory()->post->create( array( 'post_author' => $user_id ) ); 44 48 45 49 return array( … … 56 60 $this->assertSameSets( $expected, $url_list ); 57 61 } 62 63 /** 64 * @covers ::get_url_list 65 * @covers ::get_users_query_args 66 */ 67 public function test_get_url_list_skips_users_with_only_attachments_and_pages() { 68 // Set up the user to an editor to assign posts to other users. 69 wp_set_current_user( self::$editor_id ); 70 71 foreach ( self::$users as $user_id ) { 72 self::factory()->post->create( 73 array( 74 'post_author' => $user_id, 75 'post_type' => 'attachment', 76 ) 77 ); 78 self::factory()->post->create( 79 array( 80 'post_author' => $user_id, 81 'post_type' => 'page', 82 ) 83 ); 84 } 85 86 $user_provider = new WP_Sitemaps_Users(); 87 88 $url_list = $user_provider->get_url_list( 1 ); 89 90 $this->assertEmpty( $url_list ); 91 } 58 92 }
Note: See TracChangeset
for help on using the changeset viewer.