Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/23/2021 08:07:07 PM (5 years ago)
Author:
imath
Message:

BP Messages: introduce a functionality to exit a messages thread

Exiting a messages thread is removing the user from the list of the recipients of the thread. The thread can carry on between the other recipients.

Props Oelita, vapvarun

Fixes #7540

File:
1 edited

Legend:

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

    r13148 r13196  
    672672                $this->assertEquals( 'Bar and baz.', $thread->last_message_content );
    673673        }
     674
     675        /**
     676         * @group exit
     677         * @ticket BP7540
     678         */
     679        public function test_bp_messages_thread_exit() {
     680                $u1 = self::factory()->user->create();
     681                $u2 = self::factory()->user->create();
     682                $u3 = self::factory()->user->create();
     683
     684                $message = self::factory()->message->create_and_get( array(
     685                        'sender_id' => $u1,
     686                        'recipients' => array( $u2, $u3 ),
     687                        'subject' => 'Foo Bar',
     688                        'date_sent' => bp_core_current_time(),
     689                        'content' => 'Foo Bar is there.',
     690                ) );
     691
     692                $t1 = $message->thread_id;
     693
     694                $this->assertTrue( BP_Messages_Thread::exit_thread( $t1, $u3 ) );
     695        }
     696
     697        /**
     698         * @group exit
     699         * @ticket BP7540
     700         */
     701        public function test_bp_messages_thread_exit_not_enougth_recipients() {
     702                $u1 = self::factory()->user->create();
     703                $u2 = self::factory()->user->create();
     704
     705                $message = self::factory()->message->create_and_get( array(
     706                        'sender_id' => $u1,
     707                        'recipients' => array( $u2 ),
     708                        'subject' => 'Bar Foo',
     709                        'date_sent' => bp_core_current_time(),
     710                        'content' => 'Bar Foo is also there.',
     711                ) );
     712
     713                $t1 = $message->thread_id;
     714
     715                $this->assertFalse( BP_Messages_Thread::exit_thread( $t1, $u2 ) );
     716        }
     717
     718        /**
     719         * @group exit
     720         * @ticket BP7540
     721         */
     722        public function test_bp_messages_thread_exit_not_one_of_recipients() {
     723                $u1 = self::factory()->user->create();
     724                $u2 = self::factory()->user->create();
     725                $u3 = self::factory()->user->create();
     726                $u4 = self::factory()->user->create();
     727
     728                $message = self::factory()->message->create_and_get( array(
     729                        'sender_id' => $u1,
     730                        'recipients' => array( $u2, $u3 ),
     731                        'subject' => 'Taz',
     732                        'date_sent' => bp_core_current_time(),
     733                        'content' => 'Where is Taz?',
     734                ) );
     735
     736                $t1 = $message->thread_id;
     737
     738                $this->assertFalse( BP_Messages_Thread::exit_thread( $t1, $u4 ) );
     739        }
    674740}
Note: See TracChangeset for help on using the changeset viewer.