You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
688 B

2 years ago
  1. <?php
  2. namespace Tests\Base;
  3. use Illuminate\Support\Facades\Http;
  4. trait MockMethodsTrait
  5. {
  6. protected function mockHttp(array $urls, $allowStrayRequest = false)
  7. {
  8. return $allowStrayRequest ?
  9. Http::fake($urls) :
  10. Http::preventStrayRequests()->fake($urls);
  11. }
  12. protected function mockHttpResponse($body = null, $status = 200, $headers = [])
  13. {
  14. return Http::response($body, $status, $headers);
  15. }
  16. protected function mockModel($model): \Mockery\MockInterface|array|\Mockery\LegacyMockInterface
  17. {
  18. app()->instance($model, $mockUserDocument = \Mockery::mock($model));
  19. return $mockUserDocument;
  20. }
  21. }