This commit is contained in:
Zach Borboa
2021-07-26 00:35:01 -04:00
parent 4353baa2f2
commit 6ceabf7293
9 changed files with 16 additions and 16 deletions
+2 -2
View File
@@ -9,12 +9,12 @@ $curl = new Curl('https://www.example.com/api/');
$response = $curl->get('test', [
'key' => 'value',
]);
assert('https://www.example.com/api/test?key=value' === $curl->url);
assert($curl->url === 'https://www.example.com/api/test?key=value');
assert($curl->url === $curl->effectiveUrl);
// https://www.example.com/root?key=value
$response = $curl->get('/root', [
'key' => 'value',
]);
assert('https://www.example.com/root?key=value' === $curl->url);
assert($curl->url === 'https://www.example.com/root?key=value');
assert($curl->url === $curl->effectiveUrl);
@@ -8,7 +8,7 @@ $max_retries = 3;
$curl = new Curl();
$curl->setRetry(function ($instance) use ($max_retries) {
// Retry when the result of curl_getinfo($instance->curl, CURLINFO_HTTP_CODE) is 500, 503.
return $instance->retries < $max_retries && in_array($instance->httpStatusCode, [500, 503]);
return $instance->retries < $max_retries && in_array($instance->httpStatusCode, [500, 503], true);
});
$curl->get('https://httpbin.org/status/503');
@@ -10,7 +10,7 @@ const CLIENT_ID = 'XXXXXXXXXXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.apps.googleuser
const CLIENT_SECRET = 'XXXXXXXXXXXXXXXXXXXXXXXX';
const REDIRECT_URI = 'https://www.example.com/oauth2callback';
if (php_sapi_name() !== 'cli') {
if (PHP_SAPI !== 'cli') {
throw new Exception('This application must be run on the command line.');
}
+2 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/php
<?php
require dirname(__FILE__) . '/../src/Curl/Curl.php';
require __DIR__ . '/../src/Curl/Curl.php';
$current_version = Curl\Curl::VERSION;
list($major, $_, $__) = explode('.', $current_version);
@@ -8,7 +8,7 @@ $new_version = implode('.', [(string)((int)$major += 1), '0', '0']);
foreach ([
[
dirname(__FILE__) . '/../src/Curl/Curl.php',
__DIR__ . '/../src/Curl/Curl.php',
'/const VERSION = \'(?:\d+.\d+.\d+)\';/',
'const VERSION = \'' . $new_version . '\';',
],
+2 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/php
<?php
require dirname(__FILE__) . '/../src/Curl/Curl.php';
require __DIR__ . '/../src/Curl/Curl.php';
$current_version = Curl\Curl::VERSION;
list($major, $minor, $_) = explode('.', $current_version);
@@ -8,7 +8,7 @@ $new_version = implode('.', [$major, (string)((int)$minor += 1), '0']);
foreach ([
[
dirname(__FILE__) . '/../src/Curl/Curl.php',
__DIR__ . '/../src/Curl/Curl.php',
'/const VERSION = \'(?:\d+.\d+.\d+)\';/',
'const VERSION = \'' . $new_version . '\';',
],
+2 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/php
<?php
require dirname(__FILE__) . '/../src/Curl/Curl.php';
require __DIR__ . '/../src/Curl/Curl.php';
$current_version = Curl\Curl::VERSION;
list($major, $minor, $patch) = explode('.', $current_version);
@@ -8,7 +8,7 @@ $new_version = implode('.', [$major, $minor, (string)((int)$patch += 1)]);
foreach ([
[
dirname(__FILE__) . '/../src/Curl/Curl.php',
__DIR__ . '/../src/Curl/Curl.php',
'/const VERSION = \'(?:\d+.\d+.\d+)\';/',
'const VERSION = \'' . $new_version . '\';',
],
+3 -3
View File
@@ -84,7 +84,7 @@ function create_png()
{
// PNG image data, 1 x 1, 1-bit colormap, non-interlaced
ob_start();
imagepng(imagecreatefromstring(base64_decode('R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7')));
imagepng(imagecreatefromstring(base64_decode('R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7', true)));
$raw_image = ob_get_contents();
ob_end_clean();
return $raw_image;
@@ -150,9 +150,9 @@ function remove_file_from_server($uploaded_file_path) {
$download_test = new Test();
// Ensure file successfully removed.
assert('true' === $download_test->server('upload_cleanup', 'POST', [
assert($download_test->server('upload_cleanup', 'POST', [
'file_path' => $uploaded_file_path,
]));
]) === 'true');
assert(file_exists($uploaded_file_path) === false);
}
+2 -2
View File
@@ -1054,7 +1054,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase
public function testCookieFile()
{
$cookie_file = dirname(__FILE__) . '/cookiefile.txt';
$cookie_file = __DIR__ . '/cookiefile.txt';
$cookie_data = implode("\t", [
'127.0.0.1', // domain
'FALSE', // tailmatch
@@ -1079,7 +1079,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase
public function testCookieJar()
{
$cookie_jar = dirname(__FILE__) . '/cookiejar.txt';
$cookie_jar = __DIR__ . '/cookiejar.txt';
$test = new Test();
$test->curl->setCookieJar($cookie_jar);
+1 -1
View File
@@ -8,7 +8,7 @@ class UrlTest extends \PHPUnit\Framework\TestCase
{
public function testUrlPaths()
{
$urls_file = gzopen(dirname(__FILE__) . '/urls.csv.gz', 'r');
$urls_file = gzopen(__DIR__ . '/urls.csv.gz', 'r');
fgetcsv($urls_file); // header
while (($test = fgetcsv($urls_file)) !== false) {
$url = new Url($test[0], $test[1]);