From 67ca8030269324bdd0f2f53527fe2e4556c32c51 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 6 Oct 2020 01:32:47 +0200 Subject: [PATCH] fix tests --- Utils/IO/Zip/TarGz.php | 9 ++++++--- tests/System/File/Ftp/FileTest.php | 8 ++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Utils/IO/Zip/TarGz.php b/Utils/IO/Zip/TarGz.php index fe0da5e4e..7a5496ff7 100644 --- a/Utils/IO/Zip/TarGz.php +++ b/Utils/IO/Zip/TarGz.php @@ -34,7 +34,7 @@ class TarGz implements ArchiveInterface public static function pack($source, string $destination, bool $overwrite = false) : bool { $destination = \str_replace('\\', '/', $destination); - if (!$overwrite && \file_exists($destination) || !\file_exists($source)) { + if (!$overwrite && \file_exists($destination)) { return false; } @@ -43,7 +43,10 @@ class TarGz implements ArchiveInterface } $pack = Gz::pack($destination . '.tmp', $destination, $overwrite); - \unlink($destination . '.tmp'); + + if ($pack) { + \unlink($destination . '.tmp'); + } return $pack; } @@ -54,7 +57,7 @@ class TarGz implements ArchiveInterface public static function unpack(string $source, string $destination) : bool { $destination = \str_replace('\\', '/', $destination); - if (\file_exists($destination) || !\file_exists($source)) { + if (!\file_exists($destination) || !\file_exists($source)) { return false; } diff --git a/tests/System/File/Ftp/FileTest.php b/tests/System/File/Ftp/FileTest.php index eedc27052..9ba918f5d 100644 --- a/tests/System/File/Ftp/FileTest.php +++ b/tests/System/File/Ftp/FileTest.php @@ -348,6 +348,8 @@ class FileTest extends \PHPUnit\Framework\TestCase public function testStaticCreatedAt() : void { $testFile = __DIR__ . '/test.txt'; + File::delete(self::$con, $testFile); + self::assertTrue(File::create(self::$con, $testFile)); $now = new \DateTime('now'); @@ -364,6 +366,8 @@ class FileTest extends \PHPUnit\Framework\TestCase public function testStaticChangedAt() : void { $testFile = __DIR__ . '/test.txt'; + File::delete(self::$con, $testFile); + self::assertTrue(File::create(self::$con, $testFile)); $now = new \DateTime('now'); @@ -406,6 +410,8 @@ class FileTest extends \PHPUnit\Framework\TestCase public function testStaticSize() : void { $testFile = __DIR__ . '/test.txt'; + File::delete(self::$con, $testFile); + File::put(self::$con, $testFile, 'test', ContentPutMode::CREATE); self::assertGreaterThan(0, File::size(self::$con, $testFile)); @@ -421,6 +427,8 @@ class FileTest extends \PHPUnit\Framework\TestCase public function testStaticPermission() : void { $testFile = __DIR__ . '/test.txt'; + File::delete(self::$con, $testFile); + File::put(self::$con, $testFile, 'test', ContentPutMode::CREATE); self::assertGreaterThan(0, File::permission(self::$con, $testFile));