From c6ff4c551ef6fb7dbfa7f13b5f7628ae2f5adf02 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Sat, 29 Apr 2023 20:20:56 +0200 Subject: [PATCH] MDL-78002 phpunit: Ensure that all uses of psr streams are closed While the uses here were not causing too much problem with PHPUnit execution in any OS, better have them explicitly closed to better serve as reference for other, future uses anywhere in codebase. Always that a stream is used, better we close it as soon as possible, not relying on destructors, gc and friends. --- lib/filestorage/tests/file_system_test.php | 1 + lib/filestorage/tests/stored_file_test.php | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/filestorage/tests/file_system_test.php b/lib/filestorage/tests/file_system_test.php index bf01aa41423..9a854308ed9 100644 --- a/lib/filestorage/tests/file_system_test.php +++ b/lib/filestorage/tests/file_system_test.php @@ -1093,6 +1093,7 @@ class file_system_test extends \advanced_testcase { $this->assertInstanceOf(\Psr\Http\Message\StreamInterface::class, $stream); $this->assertEquals(file_get_contents(__FILE__), $stream->getContents()); $this->assertFalse($stream->isWritable()); + $stream->close(); } /** diff --git a/lib/filestorage/tests/stored_file_test.php b/lib/filestorage/tests/stored_file_test.php index 1f6d02a54c9..bc66972ccbc 100644 --- a/lib/filestorage/tests/stored_file_test.php +++ b/lib/filestorage/tests/stored_file_test.php @@ -118,6 +118,7 @@ class stored_file_test extends advanced_testcase { $this->assertInstanceOf(\Psr\Http\Message\StreamInterface::class, $stream); $this->assertEquals(file_get_contents($filepath), $stream->getContents()); $this->assertFalse($stream->isWritable()); + $stream->close(); } }