Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/30/2016 05:29:28 PM (5 years ago)
Author:
boonebgorges
Message:

Update Messages tests to work after the changes in [11042].

See #7234.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/messages/template.php

    r9948 r11044  
    1414
    1515        // create initial thread
    16         $t1 = $this->factory->message->create( array(
     16        $message_1 = $this->factory->message->create_and_get( array(
    1717            'sender_id'  => $u1,
    1818            'recipients' => array( $u2 ),
     
    2020
    2121        // create some replies to thread
    22         $this->factory->message->create( array(
    23             'thread_id' => $t1,
     22        $message_2 = $this->factory->message->create_and_get( array(
     23            'thread_id' => $message_1->thread_id,
    2424            'sender_id' => $u2,
    2525            'recipients' => array( $u1 ),
    2626        ) );
    27         $this->factory->message->create( array(
    28             'thread_id' => $t1,
     27        $message_3 = $this->factory->message->create_and_get( array(
     28            'thread_id' => $message_1->thread_id,
    2929            'sender_id' => $u2,
    3030            'recipients' => array( $u1 ),
     
    3434
    3535        $this->assertEquals( 1, $messages_template->thread_count );
    36         $this->assertSame( array( $t1 ), wp_list_pluck( $messages_template->threads, 'thread_id' ) );
     36        $this->assertSame( array( $message_1->thread_id ), wp_list_pluck( $messages_template->threads, 'thread_id' ) );
    3737    }
    3838
     
    4747
    4848        // create initial thread
    49         $t1 = $this->factory->message->create( array(
     49        $message_1 = $this->factory->message->create_and_get( array(
    5050            'sender_id'  => $u1,
    5151            'recipients' => array( $u2 ),
     
    5353
    5454        // create some replies to thread
    55         $this->factory->message->create( array(
    56             'thread_id' => $t1,
     55        $message_2 = $this->factory->message->create_and_get( array(
     56            'thread_id' => $message_1->thread_id,
    5757            'sender_id' => $u2,
    5858            'recipients' => array( $u1 ),
    5959        ) );
    60         $this->factory->message->create( array(
    61             'thread_id' => $t1,
     60        $message_3 = $this->factory->message->create_and_get( array(
     61            'thread_id' => $message_1->thread_id,
    6262            'sender_id' => $u2,
    6363            'recipients' => array( $u1 ),
     
    6767
    6868        $this->assertEquals( 1, $messages_template->thread_count );
    69         $this->assertSame( array( $t1 ), wp_list_pluck( $messages_template->threads, 'thread_id' ) );
     69        $this->assertSame( array( $message_1->thread_id ), wp_list_pluck( $messages_template->threads, 'thread_id' ) );
    7070    }
    7171
     
    7979
    8080        // create some threads
    81         $t1 = $this->factory->message->create( array(
     81        $message_1 = $this->factory->message->create_and_get( array(
    8282            'sender_id'  => $u1,
    8383            'recipients' => array( $u2 ),
    8484            'subject'    => 'This is a knive',
    8585        ) );
    86         $t2 = $this->factory->message->create( array(
     86        $message_2 = $this->factory->message->create_and_get( array(
    8787            'sender_id'  => $u1,
    8888            'recipients' => array( $u2 ),
     
    9696        ) );
    9797
     98        $t1 = $message_1->thread_id;
     99        $t2 = $message_2->thread_id;
     100
    98101        // create some replies for thread 1
    99         $this->factory->message->create( array(
     102        $message_3 = $this->factory->message->create_and_get( array(
    100103            'thread_id'  => $t1,
    101104            'sender_id'  => $u2,
     
    103106            'content'    => "That's a spoon",
    104107        ) );
    105         $this->factory->message->create( array(
     108        $message_4 = $this->factory->message->create_and_get( array(
    106109            'thread_id'  => $t1,
    107110            'sender_id'  => $u1,
     
    109112            'content'    => "I see you've played knivey-spooney before.",
    110113        ) );
    111         $this->factory->message->create( array(
     114        $message_5 = $this->factory->message->create_and_get( array(
    112115            'thread_id'  => $t1,
    113116            'sender_id'  => $u2,
     
    117120
    118121        // create some replies for thread 2
    119         $this->factory->message->create( array(
     122        $message_6 = $this->factory->message->create_and_get( array(
    120123            'thread_id'  => $t2,
    121124            'sender_id'  => $u2,
     
    124127        ) );
    125128
    126         // grab the message ids as individual variables for thread 1
    127         $thread = new BP_Messages_Thread( $t1 );
    128         $mids = wp_list_pluck( $thread->messages, 'id' );
    129         list( $m1, $m2, $m3, $m4 ) = $mids;
    130 
    131         // grab the message ids as individual variables for thread 2
    132         $thread = new BP_Messages_Thread( $t2 );
    133         $mids = wp_list_pluck( $thread->messages, 'id' );
    134         list( $m5, $m6 ) = $mids;
     129        // belong to $t1
     130        $m1 = $message_1->id;
     131        $m3 = $message_3->id;
     132        $m4 = $message_4->id;
     133        $m5 = $message_5->id;
     134
     135        // belong to $t2
     136        $m2 = $message_2->id;
     137        $m6 = $message_6->id;
    135138
    136139        // add meta for some of the messages
     
    145148        bp_messages_update_meta( $m3, "starred_by_user_{$u2}", true );
    146149
    147         bp_messages_update_meta( $m5, "starred_by_user_{$u2}", true );
     150        bp_messages_update_meta( $m6, "starred_by_user_{$u2}", true );
    148151
    149152        // now, do the message thread loop query
     
    171174
    172175        // create some threads
    173         $t1 = $this->factory->message->create( array(
     176        $message_1 = $this->factory->message->create_and_get( array(
    174177            'sender_id'  => $u1,
    175178            'recipients' => array( $u2 ),
    176179            'subject'    => 'This is a knive',
    177180        ) );
    178         $t2 = $this->factory->message->create( array(
     181        $message_2 = $this->factory->message->create_and_get( array(
    179182            'sender_id'  => $u1,
    180183            'recipients' => array( $u2 ),
     
    188191        ) );
    189192
     193        $t1 = $message_1->thread_id;
     194        $t2 = $message_2->thread_id;
     195
    190196        // create some replies for thread 1
    191         $this->factory->message->create( array(
     197        $message_3 = $this->factory->message->create_and_get( array(
    192198            'thread_id'  => $t1,
    193199            'sender_id'  => $u2,
     
    195201            'content'    => "That's a spoon",
    196202        ) );
    197         $this->factory->message->create( array(
     203        $message_4 = $this->factory->message->create_and_get( array(
    198204            'thread_id'  => $t1,
    199205            'sender_id'  => $u1,
     
    201207            'content'    => "I see you've played knivey-spooney before.",
    202208        ) );
    203         $this->factory->message->create( array(
     209        $message_5 = $this->factory->message->create_and_get( array(
    204210            'thread_id'  => $t1,
    205211            'sender_id'  => $u2,
     
    209215
    210216        // create some replies for thread 2
    211         $this->factory->message->create( array(
     217        $message_6 = $this->factory->message->create_and_get( array(
    212218            'thread_id'  => $t2,
    213219            'sender_id'  => $u2,
     
    216222        ) );
    217223
    218         // grab the message ids as individual variables for thread 1
    219         $thread = new BP_Messages_Thread( $t1 );
    220         $mids = wp_list_pluck( $thread->messages, 'id' );
    221         list( $m1, $m2, $m3, $m4 ) = $mids;
    222 
    223         // grab the message ids as individual variables for thread 2
    224         $thread = new BP_Messages_Thread( $t2 );
    225         $mids = wp_list_pluck( $thread->messages, 'id' );
    226         list( $m5, $m6 ) = $mids;
     224        // belong to $t1
     225        $m1 = $message_1->id;
     226        $m3 = $message_3->id;
     227        $m4 = $message_4->id;
     228        $m5 = $message_5->id;
     229
     230        // belong to $t2
     231        $m2 = $message_2->id;
     232        $m6 = $message_6->id;
    227233
    228234        // add meta for some of the messages
     
    237243        bp_messages_update_meta( $m3, "starred_by_user_{$u2}", true );
    238244
    239         bp_messages_update_meta( $m5, "starred_by_user_{$u2}", true );
     245        bp_messages_update_meta( $m6, "starred_by_user_{$u2}", true );
    240246
    241247        // now, do the message thread loop query
Note: See TracChangeset for help on using the changeset viewer.