fix tests

This commit is contained in:
Dennis Eichhorn 2020-10-06 01:32:47 +02:00
parent 58c49080c8
commit 67ca803026
2 changed files with 14 additions and 3 deletions

View File

@ -34,7 +34,7 @@ class TarGz implements ArchiveInterface
public static function pack($source, string $destination, bool $overwrite = false) : bool public static function pack($source, string $destination, bool $overwrite = false) : bool
{ {
$destination = \str_replace('\\', '/', $destination); $destination = \str_replace('\\', '/', $destination);
if (!$overwrite && \file_exists($destination) || !\file_exists($source)) { if (!$overwrite && \file_exists($destination)) {
return false; return false;
} }
@ -43,7 +43,10 @@ class TarGz implements ArchiveInterface
} }
$pack = Gz::pack($destination . '.tmp', $destination, $overwrite); $pack = Gz::pack($destination . '.tmp', $destination, $overwrite);
\unlink($destination . '.tmp');
if ($pack) {
\unlink($destination . '.tmp');
}
return $pack; return $pack;
} }
@ -54,7 +57,7 @@ class TarGz implements ArchiveInterface
public static function unpack(string $source, string $destination) : bool public static function unpack(string $source, string $destination) : bool
{ {
$destination = \str_replace('\\', '/', $destination); $destination = \str_replace('\\', '/', $destination);
if (\file_exists($destination) || !\file_exists($source)) { if (!\file_exists($destination) || !\file_exists($source)) {
return false; return false;
} }

View File

@ -348,6 +348,8 @@ class FileTest extends \PHPUnit\Framework\TestCase
public function testStaticCreatedAt() : void public function testStaticCreatedAt() : void
{ {
$testFile = __DIR__ . '/test.txt'; $testFile = __DIR__ . '/test.txt';
File::delete(self::$con, $testFile);
self::assertTrue(File::create(self::$con, $testFile)); self::assertTrue(File::create(self::$con, $testFile));
$now = new \DateTime('now'); $now = new \DateTime('now');
@ -364,6 +366,8 @@ class FileTest extends \PHPUnit\Framework\TestCase
public function testStaticChangedAt() : void public function testStaticChangedAt() : void
{ {
$testFile = __DIR__ . '/test.txt'; $testFile = __DIR__ . '/test.txt';
File::delete(self::$con, $testFile);
self::assertTrue(File::create(self::$con, $testFile)); self::assertTrue(File::create(self::$con, $testFile));
$now = new \DateTime('now'); $now = new \DateTime('now');
@ -406,6 +410,8 @@ class FileTest extends \PHPUnit\Framework\TestCase
public function testStaticSize() : void public function testStaticSize() : void
{ {
$testFile = __DIR__ . '/test.txt'; $testFile = __DIR__ . '/test.txt';
File::delete(self::$con, $testFile);
File::put(self::$con, $testFile, 'test', ContentPutMode::CREATE); File::put(self::$con, $testFile, 'test', ContentPutMode::CREATE);
self::assertGreaterThan(0, File::size(self::$con, $testFile)); self::assertGreaterThan(0, File::size(self::$con, $testFile));
@ -421,6 +427,8 @@ class FileTest extends \PHPUnit\Framework\TestCase
public function testStaticPermission() : void public function testStaticPermission() : void
{ {
$testFile = __DIR__ . '/test.txt'; $testFile = __DIR__ . '/test.txt';
File::delete(self::$con, $testFile);
File::put(self::$con, $testFile, 'test', ContentPutMode::CREATE); File::put(self::$con, $testFile, 'test', ContentPutMode::CREATE);
self::assertGreaterThan(0, File::permission(self::$con, $testFile)); self::assertGreaterThan(0, File::permission(self::$con, $testFile));