Skip to content

Commit

Permalink
Fix test for php7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
richardm-stripe committed Jun 26, 2021
1 parent cf1993b commit 3c911af
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
3 changes: 1 addition & 2 deletions lib/HttpClient/CurlClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,7 @@ public function executeStreamingRequestWithRetries($opts, $absUrl, $readBodyChun
&$numRetries,
&$rcode,
&$lastRHeaders,
&$errno,
&$message
&$errno
) {
$lastRHeaders = $rheaders;
$errno = \curl_errno($this->curlHandle);
Expand Down
5 changes: 3 additions & 2 deletions tests/Stripe/HttpClient/CurlClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,11 @@ public function tearDownTestServer()
public function testExecuteRequestWithRetriesCallsWriteFunctionWithChunks()
{
$chunk1 = 'First, bytes';
$chunk2 = 'more bytes';
$chunk2 = 'then more bytes';
$chunk3 = 'final bytes';
$serverCode = <<<EOF
<?php
ob_end_flush();
echo "{$chunk1}";
ob_flush();
flush();
Expand Down Expand Up @@ -492,7 +493,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'];
Expand Down
21 changes: 10 additions & 11 deletions tests/TestServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -59,6 +60,7 @@ private function makeTemporaryServerDirectory($code)
\fclose($handle);

$this->lint($indexPHP);

return $dir;
}

Expand Down Expand Up @@ -129,9 +131,6 @@ public function stopTestServer()
foreach ($lines as $line) {
if (self::isPHPTestServerRequestLogLine($line)) {
++$n;
} else {
\flush();
\ob_flush();
}
}

Expand Down

0 comments on commit 3c911af

Please sign in to comment.