FakeClient.php 854 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace Facade\Ignition\Tests\Mocks;
  3. use Facade\FlareClient\Http\Client;
  4. use Facade\FlareClient\Http\Response;
  5. use Illuminate\Support\Arr;
  6. use PHPUnit\Framework\Assert;
  7. class FakeClient extends Client
  8. {
  9. public $requests = [];
  10. public function __construct()
  11. {
  12. parent::__construct(uniqid(), null);
  13. }
  14. public function makeCurlRequest(string $verb, string $fullUrl, array $headers = [], array $arguments = []): Response
  15. {
  16. $this->requests[] = compact('verb', 'fullUrl', 'headers', 'arguments');
  17. return new Response(['http_code' => 200], 'my response', '');
  18. }
  19. public function assertRequestsSent(int $expectedCount)
  20. {
  21. Assert::assertCount($expectedCount, $this->requests);
  22. }
  23. public function getLastRequest(): array
  24. {
  25. return Arr::last($this->requests);
  26. }
  27. }