From eddc7bff0377b40d49f07e07435c2764816a2dec Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Thu, 21 Sep 2023 15:54:06 +0000 Subject: [PATCH] fix tests --- DataStorage/Cache/Connection/FileCache.php | 7 ++----- Math/Matrix/LUDecomposition.php | 3 +-- Message/Cli/CliHeader.php | 16 +--------------- .../SpreadsheetDatabaseMapperTest.php | 3 +++ 4 files changed, 7 insertions(+), 22 deletions(-) diff --git a/DataStorage/Cache/Connection/FileCache.php b/DataStorage/Cache/Connection/FileCache.php index c8cd5ecb5..18309d8dd 100755 --- a/DataStorage/Cache/Connection/FileCache.php +++ b/DataStorage/Cache/Connection/FileCache.php @@ -301,7 +301,7 @@ final class FileCache extends ConnectionAbstract $cacheExpire = \substr($raw, $expireStart + 1, $expireEnd - ($expireStart + 1)); $cacheExpire = ($cacheExpire === -1) ? $created : (int) $cacheExpire; - if ($cacheExpire >= 0 && $created + $cacheExpire + ($expire > 0 ? $expire : 0) < $now) { + if ($cacheExpire >= 0 && $created + $cacheExpire + \max(0, $expire) < $now) { $this->delete($key); return null; @@ -435,7 +435,6 @@ final class FileCache extends ConnectionAbstract return false; // @codeCoverageIgnore } - $type = (int) $raw[0]; $expireStart = (int) \strpos($raw, self::DELIM); $expireEnd = (int) \strpos($raw, self::DELIM, $expireStart + 1); @@ -446,7 +445,7 @@ final class FileCache extends ConnectionAbstract $cacheExpire = \substr($raw, $expireStart + 1, $expireEnd - ($expireStart + 1)); $cacheExpire = ($cacheExpire === -1) ? $created : (int) $cacheExpire; - if ($cacheExpire >= 0 && $created + $cacheExpire + ($expire > 0 ? $expire : 0) < $now) { + if ($cacheExpire >= 0 && $created + $cacheExpire + \max(0, $expire) < $now) { File::delete($path); return false; @@ -470,7 +469,6 @@ final class FileCache extends ConnectionAbstract } $created = File::created($path)->getTimestamp(); - $now = \time(); $raw = \file_get_contents($path); if ($raw === false) { @@ -509,7 +507,6 @@ final class FileCache extends ConnectionAbstract } $created = File::created($path)->getTimestamp(); - $now = \time(); $raw = \file_get_contents($path); if ($raw === false) { diff --git a/Math/Matrix/LUDecomposition.php b/Math/Matrix/LUDecomposition.php index 42681b7ce..568b7a4e6 100755 --- a/Math/Matrix/LUDecomposition.php +++ b/Math/Matrix/LUDecomposition.php @@ -86,8 +86,7 @@ final class LUDecomposition $this->piv[$i] = $i; } - $this->pivSign = 1; - $LUrowi = $LUcolj = []; + $LUrowi = $LUcolj = []; for ($j = 0; $j < $this->n; ++$j) { for ($i = 0; $i < $this->m; ++$i) { diff --git a/Message/Cli/CliHeader.php b/Message/Cli/CliHeader.php index ccd91f595..0a7f4e280 100755 --- a/Message/Cli/CliHeader.php +++ b/Message/Cli/CliHeader.php @@ -153,10 +153,7 @@ final class CliHeader extends HeaderAbstract */ public function generate(int $code) : void { - switch ($code) { - default: - $this->generate500(); - } + exit($code); } /** @@ -166,15 +163,4 @@ final class CliHeader extends HeaderAbstract { return $this->timestamp; } - - /** - * Generate predefined header. - * - * @return void - * - * @since 1.0.0 - */ - private function generate500() : void - { - } } diff --git a/tests/Utils/IO/Spreadsheet/SpreadsheetDatabaseMapperTest.php b/tests/Utils/IO/Spreadsheet/SpreadsheetDatabaseMapperTest.php index e27334df7..7147c17c9 100755 --- a/tests/Utils/IO/Spreadsheet/SpreadsheetDatabaseMapperTest.php +++ b/tests/Utils/IO/Spreadsheet/SpreadsheetDatabaseMapperTest.php @@ -55,6 +55,7 @@ final class SpreadsheetDatabaseMapperTest extends \PHPUnit\Framework\TestCase \copy(__DIR__ . '/backup.db', __DIR__ . '/spreadsheet.db'); $this->sqlite = new SQLiteConnection(['db' => 'sqlite', 'database' => __DIR__ . '/spreadsheet.db']); + $this->sqlite->connect(); } protected function tearDown() : void @@ -62,6 +63,8 @@ final class SpreadsheetDatabaseMapperTest extends \PHPUnit\Framework\TestCase if (\is_file(__DIR__ . '/spreadsheet.db')) { \unlink(__DIR__ . '/spreadsheet.db'); } + + $this->sqlite->close(); } /**