diff --git a/classes/PlaylistArchiveStream.php b/classes/PlaylistArchiveStream.php index 8ee5d14..b050c61 100644 --- a/classes/PlaylistArchiveStream.php +++ b/classes/PlaylistArchiveStream.php @@ -208,4 +208,16 @@ class PlaylistArchiveStream extends TarArchive return fread($this->buffer, $count); } + + /** + * Called when fclose() is used on the stream. + * + * @return void + */ + public function stream_close() + { + if (is_resource($this->buffer)) { + fclose($this->buffer); + } + } } diff --git a/tests/PlaylistArchiveStreamTest.php b/tests/PlaylistArchiveStreamTest.php index fde76c6..36a49d3 100644 --- a/tests/PlaylistArchiveStreamTest.php +++ b/tests/PlaylistArchiveStreamTest.php @@ -34,6 +34,16 @@ class PlaylistArchiveStreamTest extends TestCase $this->stream = new PlaylistArchiveStream(Config::getInstance('config/'.$configFile)); } + /** + * Clean variables used in tests. + * + * @return void + */ + protected function tearDown() + { + $this->stream->stream_close(); + } + /** * Test the stream_open() function. *