From 102f96207a140aa811a1baa4b9c16e5d19954b09 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 18 Jul 2016 21:44:30 +0900 Subject: [PATCH] Add unit tests for writing empty files --- tests/unit/framework/StorageTest.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/unit/framework/StorageTest.php b/tests/unit/framework/StorageTest.php index d7dd46ddb..3634c7ce9 100644 --- a/tests/unit/framework/StorageTest.php +++ b/tests/unit/framework/StorageTest.php @@ -167,6 +167,20 @@ class StorageTest extends \Codeception\TestCase\Test $this->assertEquals('foobarbazzjazzrhymixfoobarbazzjazzrhymixrhymix', file_get_contents($copyfile)); fclose($stream); + // Empty file write test + $this->assertTrue(Rhymix\Framework\Storage::write($testfile . '1', '')); + $this->assertTrue(file_exists($testfile . '1')); + $this->assertEquals(0, filesize($testfile . '1')); + $this->assertEmpty(0, glob($testfile . '1.tmp.*')); + + // Empty stream copy test + $stream = fopen('php://temp', 'r'); + $this->assertTrue(Rhymix\Framework\Storage::write($testfile . '2', $stream)); + $this->assertTrue(file_exists($testfile . '2')); + $this->assertEquals(0, filesize($testfile . '2')); + $this->assertEmpty(0, glob($testfile . '2.tmp.*')); + fclose($stream); + // Umask test if (strncasecmp(\PHP_OS, 'Win', 3) !== 0) {