Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/03/2017 07:44:10 PM (4 years ago)
Author:
boonebgorges
Message:

Use static factory method throughout PHPUnit tests.

See #7620.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/core/class-bp-user-query.php

    r11366 r11737  
    1010     */
    1111    public function test_bp_user_query_friends() {
    12         $u1 = $this->factory->user->create();
    13         $u2 = $this->factory->user->create();
    14         $u3 = $this->factory->user->create();
     12        $u1 = self::factory()->user->create();
     13        $u2 = self::factory()->user->create();
     14        $u3 = self::factory()->user->create();
    1515        friends_add_friend( $u1, $u2, true );
    1616
     
    2828     */
    2929    public function test_bp_user_query_friends_with_include() {
    30         $u1 = $this->factory->user->create();
    31         $u2 = $this->factory->user->create();
    32         $u3 = $this->factory->user->create();
    33         $u4 = $this->factory->user->create();
     30        $u1 = self::factory()->user->create();
     31        $u2 = self::factory()->user->create();
     32        $u3 = self::factory()->user->create();
     33        $u4 = self::factory()->user->create();
    3434        friends_add_friend( $u1, $u2, true );
    3535        friends_add_friend( $u1, $u3, true );
     
    4949
    5050    public function test_bp_user_query_friends_with_include_but_zero_friends() {
    51         $u1 = $this->factory->user->create();
    52         $u2 = $this->factory->user->create();
    53         $u3 = $this->factory->user->create();
    54         $u4 = $this->factory->user->create();
     51        $u1 = self::factory()->user->create();
     52        $u2 = self::factory()->user->create();
     53        $u3 = self::factory()->user->create();
     54        $u4 = self::factory()->user->create();
    5555
    5656        $q = new BP_User_Query( array(
     
    9494    public function test_bp_user_query_user_ids_with_invalid_user_id() {
    9595        $now = time();
    96         $u1 = $this->factory->user->create();
    97         $u2 = $this->factory->user->create();
     96        $u1 = self::factory()->user->create();
     97        $u2 = self::factory()->user->create();
    9898
    9999        // invalid user ID
     
    116116
    117117    public function test_bp_user_query_sort_by_popular() {
    118         $u1 = $this->factory->user->create();
    119         $u2 = $this->factory->user->create();
    120         $u3 = $this->factory->user->create();
    121         $u4 = $this->factory->user->create();
     118        $u1 = self::factory()->user->create();
     119        $u2 = self::factory()->user->create();
     120        $u3 = self::factory()->user->create();
     121        $u4 = self::factory()->user->create();
    122122
    123123        bp_update_user_meta( $u1, bp_get_user_meta_key( 'total_friend_count' ), '5' );
     
    142142    public function test_bp_user_query_type_online() {
    143143        $now = time();
    144         $u1 = $this->factory->user->create( array(
     144        $u1 = self::factory()->user->create( array(
    145145            'last_activity' => date( 'Y-m-d H:i:s', $now ),
    146146        ) );
    147         $u2 = $this->factory->user->create( array(
     147        $u2 = self::factory()->user->create( array(
    148148            'last_activity' => date( 'Y-m-d H:i:s', $now - 60*13 ),
    149149        ) );
    150         $u3 = $this->factory->user->create( array(
     150        $u3 = self::factory()->user->create( array(
    151151            'last_activity' => date( 'Y-m-d H:i:s', $now - 60*16 ),
    152152        ) );
     
    166166    public function test_bp_user_query_type_online_five_minute_interval() {
    167167        $now = time();
    168         $u1 = $this->factory->user->create( array(
     168        $u1 = self::factory()->user->create( array(
    169169            'last_activity' => date( 'Y-m-d H:i:s', $now ),
    170170        ) );
    171         $u2 = $this->factory->user->create( array(
     171        $u2 = self::factory()->user->create( array(
    172172            'last_activity' => date( 'Y-m-d H:i:s', $now - 60*4 ),
    173173        ) );
    174         $u3 = $this->factory->user->create( array(
     174        $u3 = self::factory()->user->create( array(
    175175            'last_activity' => date( 'Y-m-d H:i:s', $now - 60*6 ),
    176176        ) );
     
    190190    public function test_bp_user_query_search_with_apostrophe() {
    191191        // Apostrophe. Search_terms must escaped to mimic POST payload
    192         $user_id = $this->factory->user->create();
     192        $user_id = self::factory()->user->create();
    193193        xprofile_set_field_data( 1, $user_id, "Foo'Bar" );
    194194        $q = new BP_User_Query( array( 'search_terms' => "oo\'Ba", ) );
     
    206206
    207207        // LIKE special character: %
    208         $user_id = $this->factory->user->create();
     208        $user_id = self::factory()->user->create();
    209209        xprofile_set_field_data( 1, $user_id, "Foo%Bar" );
    210210        $q = new BP_User_Query( array( 'search_terms' => "oo%Bar", ) );
     
    223223
    224224        // LIKE special character: _
    225         $user_id = $this->factory->user->create();
     225        $user_id = self::factory()->user->create();
    226226        xprofile_set_field_data( 1, $user_id, "Foo_Bar" );
    227227        $q = new BP_User_Query( array( 'search_terms' => "oo_Bar", ) );
     
    239239
    240240        // LIKE special character: &
    241         $user_id = $this->factory->user->create();
     241        $user_id = self::factory()->user->create();
    242242        xprofile_set_field_data( 1, $user_id, "a&mpersand" );
    243243        $q = new BP_User_Query( array( 'search_terms' => "a&m", ) );
     
    257257     */
    258258    public function test_bp_user_query_search_core_fields() {
    259         $user_id = $this->factory->user->create( array(
     259        $user_id = self::factory()->user->create( array(
    260260            'user_login' => 'foo',
    261261        ) );
     
    273273
    274274    public function test_bp_user_query_search_wildcards() {
    275         $u1 = $this->factory->user->create( array(
     275        $u1 = self::factory()->user->create( array(
    276276            'user_login' => 'xfoo',
    277277        ) );
     
    279279        $q1 = new BP_User_Query( array( 'search_terms' => 'foo', 'search_wildcard' => 'left' ) );
    280280
    281         $u2 = $this->factory->user->create( array(
     281        $u2 = self::factory()->user->create( array(
    282282            'user_login' => 'foox',
    283283        ) );
     
    285285        $q2 = new BP_User_Query( array( 'search_terms' => 'foo', 'search_wildcard' => 'right' ) );
    286286
    287         $u3 = $this->factory->user->create( array(
     287        $u3 = self::factory()->user->create( array(
    288288            'user_login' => 'xfoox',
    289289        ) );
     
    313313        $existing_users = $wpdb->get_col( "SELECT ID FROM {$wpdb->users}" );
    314314
    315         $u1 = $this->factory->user->create();
    316         $u2 = $this->factory->user->create();
     315        $u1 = self::factory()->user->create();
     316        $u2 = self::factory()->user->create();
    317317
    318318        $exclude = array_merge( array( $u1 ), $existing_users );
     
    341341        add_filter( 'bp_disable_profile_sync', '__return_false' );
    342342
    343         $u1 = $this->factory->user->create();
    344         $u2 = $this->factory->user->create();
     343        $u1 = self::factory()->user->create();
     344        $u2 = self::factory()->user->create();
    345345
    346346        global $wpdb;
     
    372372     */
    373373    public function test_bp_user_query_type_alphabetical_spam_xprofileoff() {
    374         $u1 = $this->factory->user->create();
    375         $u2 = $this->factory->user->create();
     374        $u1 = self::factory()->user->create();
     375        $u2 = self::factory()->user->create();
    376376
    377377        // Make sure xprofile and profile sync are off
     
    407407     */
    408408    public function test_bp_user_query_with_user_meta_argument() {
    409         $u1 = $this->factory->user->create();
    410         $u2 = $this->factory->user->create();
     409        $u1 = self::factory()->user->create();
     410        $u2 = self::factory()->user->create();
    411411
    412412        bp_update_user_meta( $u2, 'foo', 'bar' );
     
    429429     */
    430430    public function test_bp_user_query_with_user_meta_argument_no_user() {
    431         $u1 = $this->factory->user->create();
    432         $u2 = $this->factory->user->create();
     431        $u1 = self::factory()->user->create();
     432        $u2 = self::factory()->user->create();
    433433
    434434        $q = new BP_User_Query( array(
     
    448448        bp_register_member_type( 'foo' );
    449449        bp_register_member_type( 'bar' );
    450         $users = $this->factory->user->create_many( 3 );
     450        $users = self::factory()->user->create_many( 3 );
    451451        bp_set_member_type( $users[0], 'foo' );
    452452        bp_set_member_type( $users[1], 'bar' );
     
    466466        bp_register_member_type( 'foo' );
    467467        bp_register_member_type( 'bar' );
    468         $users = $this->factory->user->create_many( 3 );
     468        $users = self::factory()->user->create_many( 3 );
    469469        bp_set_member_type( $users[0], 'foo' );
    470470        bp_set_member_type( $users[1], 'bar' );
     
    484484        bp_register_member_type( 'foo' );
    485485        bp_register_member_type( 'bar' );
    486         $users = $this->factory->user->create_many( 3 );
     486        $users = self::factory()->user->create_many( 3 );
    487487        bp_set_member_type( $users[0], 'foo' );
    488488        bp_set_member_type( $users[1], 'bar' );
     
    502502        bp_register_member_type( 'foo' );
    503503        bp_register_member_type( 'bar' );
    504         $users = $this->factory->user->create_many( 3 );
     504        $users = self::factory()->user->create_many( 3 );
    505505        bp_set_member_type( $users[0], 'foo' );
    506506        bp_set_member_type( $users[1], 'bar' );
     
    520520        bp_register_member_type( 'foo' );
    521521        bp_register_member_type( 'bar' );
    522         $users = $this->factory->user->create_many( 3 );
     522        $users = self::factory()->user->create_many( 3 );
    523523        bp_set_member_type( $users[0], 'foo' );
    524524        bp_set_member_type( $users[1], 'bar' );
     
    538538    public function test_should_return_no_results_when_no_users_match_the_specified_member_type() {
    539539        bp_register_member_type( 'foo' );
    540         $users = $this->factory->user->create_many( 3 );
     540        $users = self::factory()->user->create_many( 3 );
    541541
    542542        $q = new BP_User_Query( array(
     
    553553        bp_register_member_type( 'foo' );
    554554        bp_register_member_type( 'bar' );
    555         $users = $this->factory->user->create_many( 3 );
     555        $users = self::factory()->user->create_many( 3 );
    556556        bp_set_member_type( $users[0], 'foo' );
    557557        bp_set_member_type( $users[1], 'bar' );
     
    571571        bp_register_member_type( 'foo' );
    572572        bp_register_member_type( 'bar' );
    573         $users = $this->factory->user->create_many( 3 );
     573        $users = self::factory()->user->create_many( 3 );
    574574        bp_set_member_type( $users[0], 'foo' );
    575575        bp_set_member_type( $users[1], 'bar' );
     
    589589        bp_register_member_type( 'foo' );
    590590        bp_register_member_type( 'bar' );
    591         $users = $this->factory->user->create_many( 3 );
     591        $users = self::factory()->user->create_many( 3 );
    592592        bp_set_member_type( $users[0], 'foo' );
    593593        bp_set_member_type( $users[1], 'bar' );
     
    607607        bp_register_member_type( 'foo' );
    608608        bp_register_member_type( 'bar' );
    609         $users = $this->factory->user->create_many( 3 );
     609        $users = self::factory()->user->create_many( 3 );
    610610        bp_set_member_type( $users[0], 'foo' );
    611611        bp_set_member_type( $users[1], 'bar' );
     
    625625        bp_register_member_type( 'foo' );
    626626        bp_register_member_type( 'bar' );
    627         $users = $this->factory->user->create_many( 3 );
     627        $users = self::factory()->user->create_many( 3 );
    628628        bp_set_member_type( $users[0], 'foo' );
    629629        bp_set_member_type( $users[1], 'bar' );
     
    642642    public function test_should_return_no_results_when_no_users_match_the_specified_member_type__in() {
    643643        bp_register_member_type( 'foo' );
    644         $users = $this->factory->user->create_many( 3 );
     644        $users = self::factory()->user->create_many( 3 );
    645645
    646646        $q = new BP_User_Query( array(
     
    657657        bp_register_member_type( 'foo' );
    658658        bp_register_member_type( 'bar' );
    659         $users = $this->factory->user->create_many( 3 );
     659        $users = self::factory()->user->create_many( 3 );
    660660        bp_set_member_type( $users[0], 'foo' );
    661661        bp_set_member_type( $users[1], 'bar' );
     
    676676        bp_register_member_type( 'foo' );
    677677        bp_register_member_type( 'bar' );
    678         $users = $this->factory->user->create_many( 3 );
     678        $users = self::factory()->user->create_many( 3 );
    679679        bp_set_member_type( $users[0], 'foo' );
    680680        bp_set_member_type( $users[1], 'bar' );
     
    693693    public function test_should_return_no_results_when_all_users_match_the_specified_member_type__not_in() {
    694694        bp_register_member_type( 'foo' );
    695         $users = $this->factory->user->create_many( 3 );
     695        $users = self::factory()->user->create_many( 3 );
    696696        bp_set_member_type( $users[0], 'foo' );
    697697        bp_set_member_type( $users[1], 'foo' );
     
    710710    public function test_member_type__not_in_takes_precedence_over_member_type() {
    711711        bp_register_member_type( 'foo' );
    712         $users = $this->factory->user->create_many( 3 );
     712        $users = self::factory()->user->create_many( 3 );
    713713        bp_set_member_type( $users[0], 'foo' );
    714714        bp_set_member_type( $users[1], 'foo' );
     
    728728    public function test_member_type__not_in_takes_precedence_over_member_type__in() {
    729729        bp_register_member_type( 'foo' );
    730         $users = $this->factory->user->create_many( 3 );
     730        $users = self::factory()->user->create_many( 3 );
    731731        bp_set_member_type( $users[0], 'foo' );
    732732        bp_set_member_type( $users[1], 'foo' );
     
    748748        bp_register_member_type( 'foo' );
    749749        bp_register_member_type( 'bar' );
    750         $users = $this->factory->user->create_many( 4 );
     750        $users = self::factory()->user->create_many( 4 );
    751751        bp_set_member_type( $users[0], 'foo' );
    752752        bp_set_member_type( $users[1], 'bar' );
Note: See TracChangeset for help on using the changeset viewer.