/** @test */
 public function it_saves_a_status_for_a_specific_user()
 {
     // Given I have unsaved status
     $status = Factory::build(Status::class, ['user_id' => null, 'body' => 'My Status']);
     // And an existing user
     $user = Factory::create(User::class);
     // When I try to persist this status
     $savedStatus = $this->repo->save($status, $user);
     // Then it should be saved
     $this->tester->seeRecord('statuses', ['body' => 'My Status']);
     // And the status should have the correct user_id
     $this->assertEquals($user->id, $savedStatus->user_id);
 }
Beispiel #2
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle(StatusRepository $repository)
 {
     $status = Status::publish($this->body);
     $repository->save($status, $this->userId);
     event(new StatusWasPublished($status));
     return $status;
 }
 /**
  * Execute the job.
  *
  * @param Status $status
  * @param Dispatcher $event
  * @param StatusRepository $statusRepository
  */
 public function handle(Status $status, Dispatcher $event, StatusRepository $statusRepository)
 {
     $status = $status->publish($this->body, $event);
     $statusRepository->save($status, $this->user);
 }