mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-09-19 06:46:45 +00:00
Add POST file path upload test
This commit is contained in:
@@ -14,3 +14,12 @@ class Test {
|
||||
return $this->curl->response;
|
||||
}
|
||||
}
|
||||
|
||||
function get_raw_image() {
|
||||
// PNG image data, 1 x 1, 1-bit colormap, non-interlaced
|
||||
ob_start();
|
||||
imagepng(imagecreatefromstring(base64_decode('R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7')));
|
||||
$raw_image = ob_get_contents();
|
||||
ob_end_clean();
|
||||
return $raw_image;
|
||||
}
|
||||
|
||||
@@ -43,6 +43,20 @@ class CurlTest extends PHPUnit_Framework_TestCase {
|
||||
)) === 'post');
|
||||
}
|
||||
|
||||
public function testPostFilePathUpload() {
|
||||
$tmp_filename = tempnam('/tmp', 'php-curl-class.');
|
||||
file_put_contents($tmp_filename, get_raw_image());
|
||||
|
||||
$test = new Test();
|
||||
$this->assertTrue($test->server('POST', array(
|
||||
'test' => 'post_file_path_upload',
|
||||
'key' => 'image',
|
||||
'image' => '@' . $tmp_filename,
|
||||
)) === 'image/png');
|
||||
|
||||
unlink($tmp_filename);
|
||||
}
|
||||
|
||||
public function testPut() {
|
||||
$test = new Test();
|
||||
$this->assertTrue($test->server('PUT', array(
|
||||
|
||||
@@ -19,6 +19,10 @@ if ($test == 'http_basic_auth') {
|
||||
));
|
||||
exit;
|
||||
}
|
||||
else if ($test === 'post_file_path_upload') {
|
||||
echo mime_content_type($_FILES[$key]['tmp_name']);
|
||||
exit;
|
||||
}
|
||||
|
||||
header('Content-Type: text/plain');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user