Clean up helper functions

This commit is contained in:
php-curl-class
2013-08-21 15:21:54 -07:00
parent 445f3d2e3a
commit ef3f5202c5
2 changed files with 10 additions and 5 deletions
+7 -1
View File
@@ -15,7 +15,7 @@ class Test {
}
}
function get_raw_image() {
function create_png() {
// PNG image data, 1 x 1, 1-bit colormap, non-interlaced
ob_start();
imagepng(imagecreatefromstring(base64_decode('R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7')));
@@ -23,3 +23,9 @@ function get_raw_image() {
ob_end_clean();
return $raw_image;
}
function get_png() {
$tmp_filename = tempnam('/tmp', 'php-curl-class.');
file_put_contents($tmp_filename, create_png());
return $tmp_filename;
}
+3 -4
View File
@@ -44,17 +44,16 @@ class CurlTest extends PHPUnit_Framework_TestCase {
}
public function testPostFilePathUpload() {
$tmp_filename = tempnam('/tmp', 'php-curl-class.');
file_put_contents($tmp_filename, get_raw_image());
$file_path = get_png();
$test = new Test();
$this->assertTrue($test->server('POST', array(
'test' => 'post_file_path_upload',
'key' => 'image',
'image' => '@' . $tmp_filename,
'image' => '@' . $file_path,
)) === 'image/png');
unlink($tmp_filename);
unlink($file_path);
}
public function testPutRequestMethod() {