diff --git a/tests/helper.inc.php b/tests/helper.inc.php index eebdf23..5075c67 100644 --- a/tests/helper.inc.php +++ b/tests/helper.inc.php @@ -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; +} diff --git a/tests/run.php b/tests/run.php index 1223fa4..35b7ea4 100644 --- a/tests/run.php +++ b/tests/run.php @@ -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() {