Add PUT file handle test

This commit is contained in:
php-curl-class
2013-08-21 16:17:06 -07:00
parent ef3f5202c5
commit fdcb99c1e9
3 changed files with 31 additions and 0 deletions
+7
View File
@@ -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());
+17
View File
@@ -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(
+7
View File
@@ -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');