Make WordPress Core

Ticket #39297: class-wp-user-query-#39297-svn-test.diff

File class-wp-user-query-#39297-svn-test.diff, 1.2 KB (added by runciters, 10 years ago)

New patch with test

  • src/wp-includes/class-wp-user-query.php

     
    612612                 * @param string $sql The SELECT FOUND_ROWS() query for the current WP_User_Query.
    613613                 */
    614614                if ( isset( $qv['count_total'] ) && $qv['count_total'] )
    615                         $this->total_users = $wpdb->get_var( apply_filters( 'found_users_query', 'SELECT FOUND_ROWS()' ) );
     615                        $this->total_users = (int) $wpdb->get_var( apply_filters( 'found_users_query', 'SELECT FOUND_ROWS()' ) );
    616616
    617617                if ( !$this->results )
    618618                        return;
  • tests/phpunit/tests/user/query.php

     
    124124                }
    125125        }
    126126
     127        public function test_get_total() {
     128                $users = new WP_User_Query( array( 'blog_id' => get_current_blog_id() ) );
     129                $total_users = $users->get_total();
     130
     131                $this->assertSame( 13, $total_users );
     132        }
     133
    127134        /**
    128135         * @dataProvider orderby_should_convert_non_prefixed_keys_data
    129136         */