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
873 B

  1. <?php
  2. use Symfony\Component\HttpFoundation\Request;
  3. use Symfony\Component\HttpFoundation\Response;
  4. class FetchTest extends PHPUnit_Framework_TestCase {
  5. private $http;
  6. public function setUp() {
  7. $this->http = new p3k\HTTP();
  8. }
  9. public function testTimeout() {
  10. $url = 'https://nghttp2.org/httpbin/delay/2';
  11. $this->http->timeout = 1;
  12. $response = $this->http->get($url);
  13. $this->assertEquals('timeout', $response['error']);
  14. }
  15. public function testRedirectLimit() {
  16. $url = 'https://nghttp2.org/httpbin/redirect/3';
  17. $this->http->max_redirects = 1;
  18. $response = $this->http->get($url);
  19. $this->assertEquals('too_many_redirects', $response['error']);
  20. }
  21. public function testNoError() {
  22. $url = 'https://nghttp2.org/httpbin/ip';
  23. $response = $this->http->get($url);
  24. $this->assertEquals('', $response['error']);
  25. }
  26. }