Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/03/2017 07:44:10 PM (7 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/messages/class.bp-messages-thread.php

    r11044 r11737  
    1111     */
    1212    public function test_construct_cache() {
    13         $u1 = $this->factory->user->create();
    14         $u2 = $this->factory->user->create();
    15 
    16         $message = $this->factory->message->create_and_get( array(
     13        $u1 = self::factory()->user->create();
     14        $u2 = self::factory()->user->create();
     15
     16        $message = self::factory()->message->create_and_get( array(
    1717            'sender_id' => $u1,
    1818            'recipients' => array( $u2 ),
     
    3535     */
    3636    public function test_construct_order_desc() {
    37         $u1 = $this->factory->user->create();
    38         $u2 = $this->factory->user->create();
     37        $u1 = self::factory()->user->create();
     38        $u2 = self::factory()->user->create();
    3939
    4040        // create thread
    41         $message_1 = $this->factory->message->create_and_get( array(
     41        $message_1 = self::factory()->message->create_and_get( array(
    4242            'sender_id' => $u1,
    4343            'recipients' => array( $u2 ),
     
    4747
    4848        // create reply
    49         $message_2 = $this->factory->message->create_and_get( array(
     49        $message_2 = self::factory()->message->create_and_get( array(
    5050            'thread_id' => $message_1->thread_id,
    5151            'sender_id' => $u1,
     
    6969     */
    7070    public function test_get_current_threads_for_user_with_search_terms_inbox() {
    71         $u1 = $this->factory->user->create();
    72         $u2 = $this->factory->user->create();
    73 
    74         $message_1 = $this->factory->message->create_and_get( array(
    75             'sender_id' => $u1,
    76             'recipients' => array( $u2 ),
    77             'subject' => 'Foo',
    78         ) );
    79 
    80         $message_2 = $this->factory->message->create_and_get( array(
     71        $u1 = self::factory()->user->create();
     72        $u2 = self::factory()->user->create();
     73
     74        $message_1 = self::factory()->message->create_and_get( array(
     75            'sender_id' => $u1,
     76            'recipients' => array( $u2 ),
     77            'subject' => 'Foo',
     78        ) );
     79
     80        $message_2 = self::factory()->message->create_and_get( array(
    8181            'sender_id' => $u1,
    8282            'recipients' => array( $u2 ),
     
    9999     */
    100100    public function test_get_current_threads_for_user_with_search_terms_sentbox() {
    101         $u1 = $this->factory->user->create();
    102         $u2 = $this->factory->user->create();
    103 
    104         $message_1 = $this->factory->message->create_and_get( array(
    105             'sender_id' => $u1,
    106             'recipients' => array( $u2 ),
    107             'subject' => 'Foo',
    108         ) );
    109 
    110         $message_2 = $this->factory->message->create_and_get( array(
     101        $u1 = self::factory()->user->create();
     102        $u2 = self::factory()->user->create();
     103
     104        $message_1 = self::factory()->message->create_and_get( array(
     105            'sender_id' => $u1,
     106            'recipients' => array( $u2 ),
     107            'subject' => 'Foo',
     108        ) );
     109
     110        $message_2 = self::factory()->message->create_and_get( array(
    111111            'sender_id' => $u1,
    112112            'recipients' => array( $u2 ),
     
    131131     */
    132132    public function test_get_current_threads_for_user_with_old_args() {
    133         $u1 = $this->factory->user->create();
    134         $u2 = $this->factory->user->create();
    135 
    136         $message_1 = $this->factory->message->create_and_get( array(
    137             'sender_id' => $u1,
    138             'recipients' => array( $u2 ),
    139             'subject' => 'Foo',
    140         ) );
    141 
    142         $message_2 = $this->factory->message->create_and_get( array(
     133        $u1 = self::factory()->user->create();
     134        $u2 = self::factory()->user->create();
     135
     136        $message_1 = self::factory()->message->create_and_get( array(
     137            'sender_id' => $u1,
     138            'recipients' => array( $u2 ),
     139            'subject' => 'Foo',
     140        ) );
     141
     142        $message_2 = self::factory()->message->create_and_get( array(
    143143            'sender_id' => $u1,
    144144            'recipients' => array( $u2 ),
     
    161161        global $wpdb;
    162162
    163         $u1 = $this->factory->user->create();
    164         $u2 = $this->factory->user->create();
    165 
    166         $message = $this->factory->message->create_and_get( array(
     163        $u1 = self::factory()->user->create();
     164        $u2 = self::factory()->user->create();
     165
     166        $message = self::factory()->message->create_and_get( array(
    167167            'sender_id' => $u1,
    168168            'recipients' => array( $u2 ),
     
    187187        global $wpdb;
    188188
    189         $u1 = $this->factory->user->create();
    190         $u2 = $this->factory->user->create();
    191 
    192         $message = $this->factory->message->create_and_get( array(
     189        $u1 = self::factory()->user->create();
     190        $u2 = self::factory()->user->create();
     191
     192        $message = self::factory()->message->create_and_get( array(
    193193            'sender_id' => $u1,
    194194            'recipients' => array( $u2 ),
     
    225225        global $wpdb;
    226226
    227         $u1 = $this->factory->user->create();
    228         $u2 = $this->factory->user->create();
    229 
    230         $message = $this->factory->message->create_and_get( array(
     227        $u1 = self::factory()->user->create();
     228        $u2 = self::factory()->user->create();
     229
     230        $message = self::factory()->message->create_and_get( array(
    231231            'sender_id' => $u1,
    232232            'recipients' => array( $u2 ),
     
    257257        global $wpdb;
    258258
    259         $u1 = $this->factory->user->create();
    260         $u2 = $this->factory->user->create();
    261 
    262         $message = $this->factory->message->create_and_get( array(
     259        $u1 = self::factory()->user->create();
     260        $u2 = self::factory()->user->create();
     261
     262        $message = self::factory()->message->create_and_get( array(
    263263            'sender_id' => $u1,
    264264            'recipients' => array( $u2 ),
     
    289289        global $wpdb;
    290290
    291         $u1 = $this->factory->user->create();
    292         $u2 = $this->factory->user->create();
    293 
    294         $message = $this->factory->message->create_and_get( array(
     291        $u1 = self::factory()->user->create();
     292        $u2 = self::factory()->user->create();
     293
     294        $message = self::factory()->message->create_and_get( array(
    295295            'sender_id' => $u1,
    296296            'recipients' => array( $u2 ),
     
    326326        global $wpdb;
    327327
    328         $u1 = $this->factory->user->create();
    329         $u2 = $this->factory->user->create();
    330 
    331         $message = $this->factory->message->create_and_get( array(
     328        $u1 = self::factory()->user->create();
     329        $u2 = self::factory()->user->create();
     330
     331        $message = self::factory()->message->create_and_get( array(
    332332            'sender_id' => $u1,
    333333            'recipients' => array( $u2 ),
     
    360360     */
    361361    public function test_check_access_valid_thread() {
    362         $u1 = $this->factory->user->create();
    363         $u2 = $this->factory->user->create();
    364 
    365         $message = $this->factory->message->create_and_get( array(
     362        $u1 = self::factory()->user->create();
     363        $u2 = self::factory()->user->create();
     364
     365        $message = self::factory()->message->create_and_get( array(
    366366            'sender_id' => $u1,
    367367            'recipients' => array( $u2 ),
     
    390390     */
    391391    public function test_is_valid_valid_thread() {
    392         $u1 = $this->factory->user->create();
    393         $u2 = $this->factory->user->create();
    394 
    395         $message = $this->factory->message->create_and_get( array(
     392        $u1 = self::factory()->user->create();
     393        $u2 = self::factory()->user->create();
     394
     395        $message = self::factory()->message->create_and_get( array(
    396396            'sender_id' => $u1,
    397397            'recipients' => array( $u2 ),
     
    415415     */
    416416    public function test_last_message_populated() {
    417         $u1 = $this->factory->user->create();
    418         $u2 = $this->factory->user->create();
     417        $u1 = self::factory()->user->create();
     418        $u2 = self::factory()->user->create();
    419419
    420420        $date = bp_core_current_time();
    421421
    422         $message = $this->factory->message->create_and_get( array(
     422        $message = self::factory()->message->create_and_get( array(
    423423            'sender_id' => $u1,
    424424            'recipients' => array( $u2 ),
Note: See TracChangeset for help on using the changeset viewer.