Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/07/2015 02:07:41 PM (11 years ago)
Author:
boonebgorges
Message:

BP_Messages_Thread objects should always have last_message_* properties set.

Previously, they were only set in the context of a template loop.

Props jdgrimes.
Fixes #6580.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/messages/class.bp-messages-thread.php

    r9819 r10038  
    403403                $this->assertEquals( null, BP_Messages_Thread::is_valid( 999 ) );
    404404        }
     405
     406        /**
     407         * @group last_message
     408         */
     409        public function test_last_message_populated() {
     410                $u1 = $this->factory->user->create();
     411                $u2 = $this->factory->user->create();
     412
     413                $date = bp_core_current_time();
     414
     415                $t1 = $this->factory->message->create( array(
     416                        'sender_id' => $u1,
     417                        'recipients' => array( $u2 ),
     418                        'subject' => 'Foo',
     419                        'date_sent' => $date,
     420                        'content' => 'Bar and baz.',
     421                ) );
     422
     423                $thread = new BP_Messages_Thread( $t1 );
     424
     425                $this->assertNotNull( $thread->last_message_id );
     426                $this->assertEquals( 'Foo', $thread->last_message_subject );
     427                $this->assertEquals( $u1, $thread->last_sender_id );
     428                $this->assertEquals( $date, $thread->last_message_date );
     429                $this->assertEquals( 'Bar and baz.', $thread->last_message_content );
     430        }
    405431}
Note: See TracChangeset for help on using the changeset viewer.