HttpTestCase.php 1010 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * This file is part of Hyperf.
  5. *
  6. * @link https://www.hyperf.io
  7. * @document https://hyperf.wiki
  8. * @contact group@hyperf.io
  9. * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
  10. */
  11. namespace HyperfTest;
  12. use Hyperf\Testing\Client;
  13. use PHPUnit\Framework\TestCase;
  14. /**
  15. * Class HttpTestCase.
  16. * @method get($uri, $data = [], $headers = [])
  17. * @method post($uri, $data = [], $headers = [])
  18. * @method json($uri, $data = [], $headers = [])
  19. * @method file($uri, $data = [], $headers = [])
  20. * @method request($method, $path, $options = [])
  21. */
  22. abstract class HttpTestCase extends TestCase
  23. {
  24. /**
  25. * @var Client
  26. */
  27. protected $client;
  28. public function __construct($name = null, array $data = [], $dataName = '')
  29. {
  30. parent::__construct($name, $data, $dataName);
  31. $this->client = make(Client::class);
  32. }
  33. public function __call($name, $arguments)
  34. {
  35. return $this->client->{$name}(...$arguments);
  36. }
  37. }