public function testItShould_notLoginUser_incorrectCredentials()
 {
     $email = $this->randomEmail();
     $password = $this->randomPassword();
     $this->userRepositoryMock->expects($this->once())->method('findByCredentials')->with($email, $password);
     $this->callApi('POST', '/login', ['email' => $email, 'password' => $password]);
     $this->assertResponseStatus(Response::HTTP_UNAUTHORIZED);
 }
 public function testItShould_notRegisterUser_invalidInput()
 {
     $referer = $this->randomUrl();
     $this->userRepositoryMock->expects($this->never())->method('create');
     $this->call('POST', '/register', $parameters = [], $cookies = [], $files = [], ['HTTP_REFERER' => $referer]);
     $this->assertNull(auth()->user());
     $this->assertRedirectedTo($referer);
     $this->assertSessionHasErrors();
 }
 public function testItShould_registerUser()
 {
     $email = $this->randomEmail();
     $password = $this->randomPassword();
     $user = $this->createUser();
     $this->userRepositoryMock->expects($this->once())->method('create')->with(['email' => $email, 'password' => $password])->willReturn($user);
     $this->callApi('POST', '/register', ['email' => $email, 'password' => $password]);
     $this->assertResponseStatus(Response::HTTP_OK);
     $this->seeJson($user->makeVisible('api_token')->toArray());
 }