Ejemplo n.º 1
0
 public function test_it_can_send_message_to_thread()
 {
     $thread = new MessageThread();
     $thread->id = null;
     $thread->save();
     $sender = User::find(3);
     $thread->participants()->insert([['thread_id' => $thread->id, 'user_id' => 3], ['thread_id' => $thread->id, 'user_id' => 1], ['thread_id' => $thread->id, 'user_id' => 2]]);
     // Send message to user
     $messenger = new Messenger();
     $messenger->from($sender)->to($thread)->message('Hey!')->send();
     $recipientOne = User::find(1);
     $recipientTwo = User::find(2);
     $this->assertEquals(1, $recipientOne->threads->count());
     $this->assertEquals(1, $recipientTwo->threads->count());
     $this->assertEquals($sender, $recipientOne->threads->first()->creator);
     $this->assertEquals($sender, $recipientTwo->threads->first()->creator);
     $this->assertEquals(1, $recipientOne->unreadMessagesCount);
     $this->assertEquals(1, $recipientTwo->unreadMessagesCount);
     $this->assertTrue(is_string($recipientOne->threads()->first()->title));
     $this->assertTrue(is_string($recipientTwo->threads()->first()->title));
 }
Ejemplo n.º 2
0
 /**
  * Seed database.
  */
 protected function createUsers()
 {
     User::insert([['name' => 'David', 'email' => '*****@*****.**'], ['name' => 'Jane', 'email' => '*****@*****.**'], ['name' => 'Abigail', 'email' => '*****@*****.**']]);
 }