Fix "Operation not permitted" (PHP 5.3) and "Permission denied" (HHVM) errors

This commit is contained in:
Zach Borboa
2014-12-11 21:50:25 -08:00
parent 001cfd646b
commit 2fb88ffde0
2 changed files with 14 additions and 4 deletions
+6 -3
View File
@@ -338,9 +338,8 @@ class CurlTest extends PHPUnit_Framework_TestCase
$upload_test->server('upload_response', 'POST', array(
'image' => '@' . $upload_file_path,
));
$uploaded_file_path = $upload_test->curl->response;
$uploaded_file_path = $upload_test->curl->response->file_path;
$this->assertNotEquals($upload_file_path, $uploaded_file_path);
$this->assertEquals(md5_file($upload_file_path), md5_file($uploaded_file_path));
$this->assertEquals(md5_file($upload_file_path), $upload_test->curl->response_headers['ETag']);
// Download the file.
@@ -363,8 +362,12 @@ class CurlTest extends PHPUnit_Framework_TestCase
$this->assertFalse(is_bool($download_test->curl->response));
$this->assertFalse(is_bool($download_test->curl->raw_response));
// Remove server file.
$this->assertEquals('true', $download_test->server('upload_cleanup', 'POST', array(
'file_path' => $uploaded_file_path,
)));
unlink($upload_file_path);
unlink($uploaded_file_path);
unlink($downloaded_file_path);
$this->assertFalse(file_exists($upload_file_path));
$this->assertFalse(file_exists($uploaded_file_path));
+8 -1
View File
@@ -124,8 +124,15 @@ if ($test == 'http_basic_auth') {
} elseif ($test === 'upload_response') {
$tmp_filename = tempnam('/tmp', 'php-curl-class.');
move_uploaded_file($_FILES['image']['tmp_name'], $tmp_filename);
header('Content-Type: application/json');
header('ETag: ' . md5_file($tmp_filename));
echo $tmp_filename;
echo json_encode(array(
'file_path' => $tmp_filename,
));
exit;
} elseif ($test === 'upload_cleanup') {
$unsafe_file_path = $_POST['file_path'];
echo var_export(unlink($unsafe_file_path), true);
exit;
} elseif ($test === 'download_response') {
$unsafe_file_path = $_GET['file_path'];