Skip to content

Commit

Permalink
Add tests for read-filehandle in-memory- and file-streams
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan Wentz committed Feb 29, 2024
1 parent 944b67f commit 7448cb5
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
2 changes: 2 additions & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ This extension requires ImageMagick version 6.5.3-10+ and PHP 5.4.0+.
<file name="011_polygon.phpt" role="test" />
<file name="012-clone-separation.phpt" role="test" />
<file name="013-read-filehandle.phpt" role="test" />
<file name="013-read-filehandle-memory-stream.phpt" role="test" />
<file name="013-read-filehandle-file-stream.phpt" role="test" />
<file name="014-setresourcelimit.phpt" role="test" />
<file name="015-imagickdrawsetresolution.phpt" role="test" />
<file name="016-static-methods.phpt" role="test" />
Expand Down
34 changes: 34 additions & 0 deletions tests/013-read-filehandle-file-stream.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
--TEST--
Imagick::readImageFile, file stream test
--SKIPIF--
<?php
require_once(dirname(__FILE__) . '/skipif.inc');
checkFormatPresent('jpg');
?>
--FILE--
<?php

$file = dirname(__FILE__) . '/__tmp_rose.jpg';
$handle = fopen($file, 'w+');

$imagick = new Imagick('magick:rose');
$imagick->setImageFormat('jpg');
$imagick->writeImageFile($handle);

$imagick->clear();

rewind($handle);

$imagick->readImageFile($handle);

unlink($file);

echo 'success';

?>
--CLEAN--
<?php
@unlink(dirname(__FILE__) . '/__tmp_rose.jpg');
?>
--EXPECT--
success
29 changes: 29 additions & 0 deletions tests/013-read-filehandle-memory-stream.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
--TEST--
Imagick::readImageFile, in-memory stream test
--SKIPIF--
<?php
require_once(dirname(__FILE__) . '/skipif.inc');
checkFormatPresent('jpg');
?>
--FILE--
<?php

$handle = fopen('php://memory', 'w+');

$imagick = new Imagick('magick:rose');
$imagick->setImageFormat('jpg');
$imagick->writeImageFile($handle);

$imagick->clear();

rewind($handle);

$imagick->readImageFile($handle);

unlink($file);

echo 'success';

?>
--EXPECT--
success

0 comments on commit 7448cb5

Please sign in to comment.