mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-08-30 20:20:53 +00:00
Add PUT file handle test
This commit is contained in:
@@ -24,6 +24,13 @@ function create_png() {
|
||||
return $raw_image;
|
||||
}
|
||||
|
||||
function create_tmp_file($data) {
|
||||
$tmp_file = tmpfile();
|
||||
fwrite($tmp_file, $data);
|
||||
rewind($tmp_file);
|
||||
return $tmp_file;
|
||||
}
|
||||
|
||||
function get_png() {
|
||||
$tmp_filename = tempnam('/tmp', 'php-curl-class.');
|
||||
file_put_contents($tmp_filename, create_png());
|
||||
|
||||
@@ -72,6 +72,23 @@ class CurlTest extends PHPUnit_Framework_TestCase {
|
||||
)) === 'put');
|
||||
}
|
||||
|
||||
public function testPutFileHandle() {
|
||||
$png = create_png();
|
||||
$tmp_file = create_tmp_file($png);
|
||||
|
||||
$test = new Test();
|
||||
$test->curl->setopt(CURLOPT_PUT, TRUE);
|
||||
$test->curl->setopt(CURLOPT_INFILE, $tmp_file);
|
||||
$test->curl->setopt(CURLOPT_INFILESIZE, strlen($png));
|
||||
$test->curl->put(Test::TEST_URL, array(
|
||||
'test' => 'put_file_handle',
|
||||
));
|
||||
|
||||
fclose($tmp_file);
|
||||
|
||||
$this->assertTrue($test->curl->response === 'image/png');
|
||||
}
|
||||
|
||||
public function testDelete() {
|
||||
$test = new Test();
|
||||
$this->assertTrue($test->server('DELETE', array(
|
||||
|
||||
@@ -23,6 +23,13 @@ else if ($test === 'post_file_path_upload') {
|
||||
echo mime_content_type($_FILES[$key]['tmp_name']);
|
||||
exit;
|
||||
}
|
||||
else if ($test === 'put_file_handle') {
|
||||
$tmp_filename = tempnam('/tmp', 'php-curl-class.');
|
||||
file_put_contents($tmp_filename, file_get_contents('php://input'));
|
||||
echo mime_content_type($tmp_filename);
|
||||
unlink($tmp_filename);
|
||||
exit;
|
||||
}
|
||||
|
||||
header('Content-Type: text/plain');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user