Add POST file path upload test

This commit is contained in:
php-curl-class
2013-08-21 12:46:30 -07:00
parent 52ff874771
commit eaf8b14e16
3 changed files with 27 additions and 0 deletions
+9
View File
@@ -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;
}
+14
View File
@@ -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(
+4
View File
@@ -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');