WordPress.org

Make WordPress Core

Ticket #29785: 29785.diff

File 29785.diff, 796 bytes (added by boonebgorges, 4 years ago)
  • tests/phpunit/tests/user/countUsers.php

    diff --git tests/phpunit/tests/user/countUsers.php tests/phpunit/tests/user/countUsers.php
    index d3192bb..df13f79 100644
    class Tests_User_CountUsers extends WP_UnitTestCase { 
    186186                );
    187187        }
    188188
     189        /**
     190         * @ticket 29785
     191         */
     192        public function test_should_not_count_users_who_are_not_in_posts_table() {
     193                global $wpdb;
     194
     195                // Get a 'before' count for comparison.
     196                $count = count_users( 'memory' );
     197
     198                $u = self::factory()->user->create( array( 'role' => 'editor' ) );
     199
     200                // Manually delete the user, but leave the capabilities usermeta.
     201                $wpdb->delete( $wpdb->users, array( 'ID' => $u ) );
     202
     203                $count2 = count_users( 'memory' );
     204
     205                $this->assertEqualSets( $count, $count2 );
     206        }
    189207}