HttpTestCase.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. use function Hyperf\Support\make;
  15. /**
  16. * Class HttpTestCase.
  17. * @method get($uri, $data = [], $headers = [])
  18. * @method post($uri, $data = [], $headers = [])
  19. * @method json($uri, $data = [], $headers = [])
  20. * @method file($uri, $data = [], $headers = [])
  21. * @method request($method, $path, $options = [])
  22. */
  23. abstract class HttpTestCase extends TestCase
  24. {
  25. /**
  26. * @var Client
  27. */
  28. protected $client;
  29. public function __construct($name = null, array $data = [], $dataName = '')
  30. {
  31. parent::__construct($name, $data, $dataName);
  32. $this->client = make(Client::class);
  33. }
  34. public function __call($name, $arguments)
  35. {
  36. return $this->client->{$name}(...$arguments);
  37. }
  38. }