/** @test */ public function it_should_get_all_threads_for_a_user() { $userId = 1; $participant_1 = $this->faktory->create('participant', ['user_id' => $userId]); $thread = $this->faktory->create('thread'); $thread->participants()->saveMany([$participant_1]); $thread2 = $this->faktory->create('thread', ['subject' => 'Second Thread']); $participant_2 = $this->faktory->create('participant', ['user_id' => $userId, 'thread_id' => $thread2->id]); $thread2->participants()->saveMany([$participant_2]); $threads = Thread::forUser($userId)->get(); $this->assertCount(2, $threads); }