Changeset 54726
- Timestamp:
- 10/31/2022 12:55:20 PM (2 years ago)
- Location:
- trunk/tests/phpunit/tests/multisite
- Files:
-
- 1 copied
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/multisite/wpCountSites.php
r54721 r54726 4 4 5 5 /** 6 * A set of unit tests for WordPress Multisite 7 * 6 * @group ms-site 8 7 * @group multisite 9 8 */ 10 class Tests_Multisite extends WP_UnitTestCase { 11 12 public function test_wpmu_log_new_registrations() { 13 global $wpdb; 14 15 $user = new WP_User( 1 ); 16 $ip = preg_replace( '/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR'] ); 17 18 wpmu_log_new_registrations( 1, 1 ); 19 20 // Currently there is no wrapper function for the registration_log. 21 $reg_blog = $wpdb->get_col( $wpdb->prepare( "SELECT email FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.blog_id = 1 AND IP LIKE %s", $ip ) ); 22 $this->assertSame( $user->user_email, $reg_blog[ count( $reg_blog ) - 1 ] ); 23 } 9 class Tests_Multisite_wpCountSites extends WP_UnitTestCase { 24 10 25 11 /** -
trunk/tests/phpunit/tests/multisite/wpmuLogNewRegistrations.php
r54721 r54726 4 4 5 5 /** 6 * A set of unit tests for WordPress Multisite7 *8 6 * @group multisite 9 7 */ 10 class Tests_Multisite extends WP_UnitTestCase {8 class Tests_Multisite_wpmuLogNewRegistrations extends WP_UnitTestCase { 11 9 12 10 public function test_wpmu_log_new_registrations() { … … 22 20 $this->assertSame( $user->user_email, $reg_blog[ count( $reg_blog ) - 1 ] ); 23 21 } 24 25 /**26 * @ticket 3739227 */28 public function test_wp_count_sites() {29 // Create a random number of sites with each status.30 $site_ids = array(31 'public' => self::factory()->blog->create_many(32 random_int( 0, 5 ),33 array(34 'public' => 1,35 )36 ),37 'archived' => self::factory()->blog->create_many(38 random_int( 0, 5 ),39 array(40 'public' => 0,41 'archived' => 1,42 )43 ),44 'mature' => self::factory()->blog->create_many(45 random_int( 0, 5 ),46 array(47 'public' => 0,48 'mature' => 1,49 )50 ),51 'spam' => self::factory()->blog->create_many(52 random_int( 0, 5 ),53 array(54 'public' => 0,55 'spam' => 1,56 )57 ),58 'deleted' => self::factory()->blog->create_many(59 random_int( 0, 5 ),60 array(61 'public' => 0,62 'deleted' => 1,63 )64 ),65 );66 67 $counts = wp_count_sites();68 69 $counts_by_status = array_map( 'count', $site_ids );70 $expected = array_merge(71 array( 'all' => array_sum( $counts_by_status ) ),72 $counts_by_status73 );74 // Add 1 to all & public for the main site.75 $expected['all'] += 1;76 $expected['public'] += 1;77 78 $this->assertSame( $expected, $counts );79 }80 22 } 81 23
Note: See TracChangeset
for help on using the changeset viewer.