diff --git a/lib/HttpClient/CurlClient.php b/lib/HttpClient/CurlClient.php index 2139999a9..213352200 100644 --- a/lib/HttpClient/CurlClient.php +++ b/lib/HttpClient/CurlClient.php @@ -390,8 +390,7 @@ public function executeStreamingRequestWithRetries($opts, $absUrl, $readBodyChun &$numRetries, &$rcode, &$lastRHeaders, - &$errno, - &$message + &$errno ) { $lastRHeaders = $rheaders; $errno = \curl_errno($this->curlHandle); diff --git a/tests/Stripe/HttpClient/CurlClientTest.php b/tests/Stripe/HttpClient/CurlClientTest.php index ea0079439..c097514af 100644 --- a/tests/Stripe/HttpClient/CurlClientTest.php +++ b/tests/Stripe/HttpClient/CurlClientTest.php @@ -374,44 +374,6 @@ public function tearDownTestServer() $this->stopTestServer(); } - // This is a pretty flaky/uncertain way to try and get an - // http server to deliver the body in separate "chunks". - // - // It seems to work but feel free to just skip or delete - // if this flakes. - public function testExecuteRequestWithRetriesCallsWriteFunctionWithChunks() - { - $chunk1 = 'First, bytes'; - $chunk2 = 'more bytes'; - $chunk3 = 'final bytes'; - $serverCode = <<startTestServer($serverCode); - $opts = []; - $opts[\CURLOPT_HTTPGET] = 1; - $opts[\CURLOPT_URL] = $absUrl; - $opts[\CURLOPT_HTTPHEADER] = ['Authorization: Basic c2tfdGVzdF94eXo6']; - $curl = new CurlClient(); - $receivedChunks = []; - $curl->executeStreamingRequestWithRetries($opts, $absUrl, function ($chunk) use (&$receivedChunks) { - $receivedChunks[] = $chunk; - }); - static::assertSame([$chunk1, $chunk2, $chunk3], $receivedChunks); - $this->stopTestServer(); - } - public function testExecuteStreamingRequestWithRetriesRetries() { $serverCode = <<<'EOF' @@ -492,7 +454,7 @@ public function testExecuteStreamingRequestWithRetriesPersistentConnection() $curl = new CurlClient(); $coupon = \Stripe\Coupon::retrieve('coupon_xyz'); - $absUrl = \Stripe\Stripe::$apiBase . "/v1/coupons/xyz"; + $absUrl = \Stripe\Stripe::$apiBase . '/v1/coupons/xyz'; $opts[\CURLOPT_HTTPGET] = 1; $opts[\CURLOPT_URL] = $absUrl; $opts[\CURLOPT_HTTPHEADER] = ['Authorization: Basic c2tfdGVzdF94eXo6']; diff --git a/tests/TestServer.php b/tests/TestServer.php index a653b9ae1..09e34eda6 100644 --- a/tests/TestServer.php +++ b/tests/TestServer.php @@ -24,17 +24,18 @@ trait TestServer // value to `stripe-mock`'s standard 12111. protected $serverPort = 12113; - private function lint($path) { - $output = ''; - $exitCode = null; - \exec("php -l {$path}", $output, $exitCode); - if (0 !== $exitCode) { - $text = \implode("\n", $output); - throw new \Exception("Error in test server code: {$text}"); - } + $output = ''; + $exitCode = null; + \exec("php -l {$path}", $output, $exitCode); + if (0 !== $exitCode) { + $text = \implode("\n", $output); + + throw new \Exception("Error in test server code: {$text}"); + } } + /** * Makes a directory in a temporary path containing only an `index.php` file with * the specified content ($code). @@ -59,6 +60,7 @@ private function makeTemporaryServerDirectory($code) \fclose($handle); $this->lint($indexPHP); + return $dir; } @@ -129,9 +131,6 @@ public function stopTestServer() foreach ($lines as $line) { if (self::isPHPTestServerRequestLogLine($line)) { ++$n; - } else { - \flush(); - \ob_flush(); } }