- Timestamp:
- 11/03/2024 05:55:47 PM (8 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/messages/test-controller.php
r14037 r14069 72 72 $this->assertCount( 1, $data[0]['messages'] ); 73 73 74 // Check the thread data for the requested user id => `$u1`.75 74 $this->check_thread_data( $this->endpoint->get_thread_object( $data[0]['id'], $u1 ), $data[0] ); 76 75 } … … 143 142 $this->assertCount( 1, $all_data[0]['recipients'] ); 144 143 $this->assertCount( 1, $all_data[1]['recipients'] ); 144 } 145 146 /** 147 * @BP9157 148 * @group get_items 149 */ 150 public function test_filter_threads_by_recipients() { 151 $u1 = static::factory()->user->create(); 152 $u2 = static::factory()->user->create(); 153 $u3 = static::factory()->user->create(); 154 155 $thread = $this->bp::factory()->message->create_and_get( 156 array( 157 'sender_id' => $u1, 158 'recipients' => array( $u2 ), 159 'subject' => 'First Thread', 160 ) 161 ); 162 163 $this->bp::factory()->message->create( 164 array( 165 'thread_id' => $thread->thread_id, 166 'sender_id' => $u2, 167 'recipients' => array( $u1 ), 168 ) 169 ); 170 171 $thread2 = $this->bp::factory()->message->create_and_get( 172 array( 173 'sender_id' => $u1, 174 'recipients' => array( $u3 ), 175 'subject' => 'Second Thread', 176 ) 177 ); 178 179 $this->bp::factory()->message->create( 180 array( 181 'thread_id' => $thread2->thread_id, 182 'sender_id' => $u3, 183 'recipients' => array( $u1 ), 184 ) 185 ); 186 187 $this->bp::set_current_user( $this->user ); 188 189 $request = new WP_REST_Request( 'GET', $this->endpoint_url ); 190 $request->set_param( 'context', 'view' ); 191 $request->set_param( 'user_id', $u1 ); 192 $request->set_param( 'includes', array( $u3 ) ); 193 $response = $this->server->dispatch( $request ); 194 195 $this->assertEquals( 200, $response->get_status() ); 196 197 $data = $response->get_data(); 198 199 $this->assertNotEmpty( $data ); 200 201 $a_ids = wp_list_pluck( $data, 'id' ); 202 203 $this->assertCount( 1, $a_ids ); 204 $this->assertSame( $thread2->thread_id, $a_ids[0] ); 145 205 } 146 206
Note: See TracChangeset
for help on using the changeset viewer.