diff --git a/DataStorage/Database/Query/Builder.php b/DataStorage/Database/Query/Builder.php index aa54ce5eb..18b56c81d 100644 --- a/DataStorage/Database/Query/Builder.php +++ b/DataStorage/Database/Query/Builder.php @@ -43,6 +43,14 @@ class Builder extends BuilderAbstract */ public array $selects = []; + /** + * Columns. + * + * @var array + * @since 1.0.0 + */ + public array $random; + /** * Columns. * @@ -311,7 +319,8 @@ class Builder extends BuilderAbstract { $this->select(...$columns); - $this->type = QueryType::RANDOM; + $this->type = QueryType::RANDOM; + $this->random = &$this->selects; return $this; } diff --git a/DataStorage/Database/Query/Grammar/Grammar.php b/DataStorage/Database/Query/Grammar/Grammar.php index 649572d92..9054ab0ad 100644 --- a/DataStorage/Database/Query/Grammar/Grammar.php +++ b/DataStorage/Database/Query/Grammar/Grammar.php @@ -112,7 +112,7 @@ class Grammar extends GrammarAbstract case QueryType::DELETE: return $this->deleteComponents; case QueryType::RANDOM: - return $this->selectComponents; + return $this->randomComponents; default: throw new \InvalidArgumentException('Unknown query type.'); } diff --git a/DataStorage/Database/Query/Grammar/MysqlGrammar.php b/DataStorage/Database/Query/Grammar/MysqlGrammar.php index c3f42d913..e5daf1363 100644 --- a/DataStorage/Database/Query/Grammar/MysqlGrammar.php +++ b/DataStorage/Database/Query/Grammar/MysqlGrammar.php @@ -53,6 +53,6 @@ class MysqlGrammar extends Grammar $expression = '*'; } - return 'SELECT ' . $expression . ' ' . $this->compileFrom($query, $query->from) . ' ORDER BY \rand() ' . $this->compileLimit($query, $query->limit ?? 1); + return 'SELECT ' . $expression . ' ' . $this->compileFrom($query, $query->from) . ' ' . $this->compileWheres($query, $query->wheres) . ' ORDER BY \rand() ' . $this->compileLimit($query, $query->limit ?? 1); } } diff --git a/DataStorage/Database/SchemaMapper.php b/DataStorage/Database/SchemaMapper.php index 4894a72aa..b8f7537c0 100644 --- a/DataStorage/Database/SchemaMapper.php +++ b/DataStorage/Database/SchemaMapper.php @@ -59,11 +59,13 @@ class SchemaMapper public function getTables() : array { $builder = new Builder($this->db); - $tNames = $builder->selectTables()->execute(); + + /** @var array $tNames */ + $tNames = $builder->selectTables()->execute()->fetchAll(\PDO::FETCH_ASSOC); $tables = []; foreach ($tNames as $name) { - $tables[] = $this->getTable($name); + $tables[] = \array_values($name)[0]; } return $tables; @@ -97,11 +99,11 @@ class SchemaMapper public function getFields(string $table) : array { $builder = new Builder($this->db); - $tNames = $builder->selectFields($table)->execute(); + $tNames = $builder->selectFields($table)->execute()->fetchAll(\PDO::FETCH_ASSOC); $fields = []; foreach ($tNames as $name) { - $fields[] = $this->getField($table, $name); + $fields[] = \array_values($name); } return $fields; diff --git a/Math/Matrix/QRDecomposition.php b/Math/Matrix/QRDecomposition.php index 338031c02..1c1f8e346 100644 --- a/Math/Matrix/QRDecomposition.php +++ b/Math/Matrix/QRDecomposition.php @@ -131,33 +131,6 @@ final class QRDecomposition return true; } - /** - * Get H matrix - * - * @return Matrix - * - * @since 1.0.0 - */ - public function getH() : Matrix - { - $H = [[]]; - - for ($i = 0; $i < $this->m; ++$i) { - for ($j = 0; $j < $this->n; ++$j) { - if ($i >= $j) { - $H[$i][$j] = $this->QR[$i][$j]; - } else { - $H[$i][$j] = 0.0; - } - } - } - - $matrix = new Matrix(); - $matrix->setMatrix($H); - - return $matrix; - } - /** * Get R matrix * diff --git a/Math/Matrix/Vector.php b/Math/Matrix/Vector.php index 9a14dc2bc..b0e5d29d2 100644 --- a/Math/Matrix/Vector.php +++ b/Math/Matrix/Vector.php @@ -24,18 +24,6 @@ namespace phpOMS\Math\Matrix; */ final class Vector extends Matrix { - /** - * Create vector - * - * @param int $m Vector length - * - * @since 1.0.0 - */ - public function __cosntruct(int $m = 1) - { - parent::__construct($m, 1); - } - /** * Set vector value * diff --git a/Stdlib/Base/Heap.php b/Stdlib/Base/Heap.php index 04ca9ac00..9cc2522c3 100644 --- a/Stdlib/Base/Heap.php +++ b/Stdlib/Base/Heap.php @@ -144,10 +144,8 @@ class Heap if ($node === $item) { return true; } - } else { - if ($item->isEqual($node)) { - return true; - } + } elseif ($item->isEqual($node)) { + return true; } } @@ -231,11 +229,9 @@ class Heap $pos = $key; break; } - } else { - if ($item->isEqual($node)) { - $pos = $key; - break; - } + } elseif ($item->isEqual($node)) { + $pos = $key; + break; } } diff --git a/Stdlib/Base/SmartDateTime.php b/Stdlib/Base/SmartDateTime.php index 3846d3477..80efba60c 100644 --- a/Stdlib/Base/SmartDateTime.php +++ b/Stdlib/Base/SmartDateTime.php @@ -156,6 +156,20 @@ class SmartDateTime extends \DateTime return new self(\date('Y-m-d', $w)); } + /** + * Get end of the week + * + * @return SmartDateTime + * + * @since 1.0.0 + */ + public function getEndOfWeek() : self + { + $w = \strtotime('+' . (6 - \date('w', $this->getTimestamp())) .' days', $this->getTimestamp()); + + return new self(\date('Y-m-d', $w)); + } + /** * Get days of current month * @@ -205,15 +219,15 @@ class SmartDateTime extends \DateTime { $isLeap = false; - if ($year % 4 == 0) { + if ($year % 4 === 0) { $isLeap = true; } - if ($year % 100 == 0) { + if ($year % 100 === 0) { $isLeap = false; } - if ($year % 400 == 0) { + if ($year % 400 === 0) { $isLeap = true; } diff --git a/System/File/Ftp/FtpStorage.php b/System/File/Ftp/FtpStorage.php index 561688b57..6533ccd3c 100644 --- a/System/File/Ftp/FtpStorage.php +++ b/System/File/Ftp/FtpStorage.php @@ -30,30 +30,6 @@ use phpOMS\System\File\StorageAbstract; */ class FtpStorage extends StorageAbstract { - /** - * Storage instance. - * - * @var FtpStorage - * @since 1.0.0 - */ - private static ?self $instance = null; - - /** - * Get instance. - * - * @return FtpStorage - * - * @since 1.0.0 - */ - public static function getInstance() : StorageAbstract - { - if (self::$instance === null) { - self::$instance = new self(); - } - - return self::$instance; - } - /** * {@inheritdoc} */ diff --git a/System/File/Local/LocalStorage.php b/System/File/Local/LocalStorage.php index 44654eab9..fcd05d228 100644 --- a/System/File/Local/LocalStorage.php +++ b/System/File/Local/LocalStorage.php @@ -29,30 +29,6 @@ use phpOMS\System\File\StorageAbstract; */ class LocalStorage extends StorageAbstract { - /** - * Storage instance. - * - * @var LocalStorage - * @since 1.0.0 - */ - private static ?self $instance = null; - - /** - * Get instance. - * - * @return StorageAbstract - * - * @since 1.0.0 - */ - public static function getInstance() : StorageAbstract - { - if (self::$instance === null) { - self::$instance = new self(); - } - - return self::$instance; - } - /** * {@inheritdoc} */ diff --git a/System/File/Storage.php b/System/File/Storage.php index b4f36ce7b..07dd9c0fc 100644 --- a/System/File/Storage.php +++ b/System/File/Storage.php @@ -60,9 +60,10 @@ final class Storage { if (isset(self::$registered[$env])) { if (\is_string(self::$registered[$env])) { - $env = self::$registered[$env]::getInstance(); + $instance = new self::$registered[$env]; + self::$registered[$env] = $instance; } elseif (self::$registered[$env] instanceof StorageAbstract || self::$registered[$env] instanceof ContainerInterface) { - $env = self::$registered[$env]; + $instance = self::$registered[$env]; } else { throw new \Exception('Invalid type'); } @@ -73,15 +74,15 @@ final class Storage try { /** @var StorageAbstract $env */ - $env = $env::getInstance(); + $instance = new $env(); - self::$registered[$stg] = $env; + self::$registered[$stg] = $instance; } catch (\Throwable $e) { throw new \Exception(); } } - return $env; + return $instance; } /** diff --git a/System/File/StorageAbstract.php b/System/File/StorageAbstract.php index 7a6f34d80..f14b1473a 100644 --- a/System/File/StorageAbstract.php +++ b/System/File/StorageAbstract.php @@ -26,15 +26,6 @@ namespace phpOMS\System\File; */ abstract class StorageAbstract { - /** - * Get instance. - * - * @return StorageAbstract storage instance - * - * @since 1.0.0 - */ - abstract public static function getInstance() : self; - /** * Get the internal class type (directory or file) based on path. * diff --git a/tests/Algorithm/PathFinding/HeuristicTest.php b/tests/Algorithm/PathFinding/HeuristicTest.php new file mode 100644 index 000000000..262d28d98 --- /dev/null +++ b/tests/Algorithm/PathFinding/HeuristicTest.php @@ -0,0 +1,76 @@ + 0, 'y' => 3], ['x' => 7, 'y' => 6], HeuristicType::MANHATTAN) + ); + + self::assertEqualsWithDelta( + 7.615773, + Heuristic::metric(['x' => 0, 'y' => 3], ['x' => 7, 'y' => 6], HeuristicType::EUCLIDEAN), + 0.1 + ); + + self::assertEquals( + 7.0, + Heuristic::metric(['x' => 0, 'y' => 3], ['x' => 7, 'y' => 6], HeuristicType::CHEBYSHEV) + ); + + self::assertEqualsWithDelta( + 10.0, + Heuristic::metric(['x' => 0, 'y' => 3], ['x' => 7, 'y' => 6], HeuristicType::MINKOWSKI), + 0.1 + ); + + self::assertEqualsWithDelta( + 1.333, + Heuristic::metric(['x' => 0, 'y' => 3], ['x' => 7, 'y' => 6], HeuristicType::CANBERRA), + 0.1 + ); + + self::assertEqualsWithDelta( + 0.625, + Heuristic::metric(['x' => 0, 'y' => 3], ['x' => 7, 'y' => 6], HeuristicType::BRAY_CURTIS), + 0.1 + ); + + self::assertEqualsWithDelta( + 8.24264, + Heuristic::metric(['x' => 0, 'y' => 3], ['x' => 7, 'y' => 6], HeuristicType::OCTILE), + 0.1 + ); + } +} diff --git a/tests/DataStorage/Cache/Connection/FileCacheTest.php b/tests/DataStorage/Cache/Connection/FileCacheTest.php index bd1e99dac..42f93a3ca 100644 --- a/tests/DataStorage/Cache/Connection/FileCacheTest.php +++ b/tests/DataStorage/Cache/Connection/FileCacheTest.php @@ -48,7 +48,7 @@ class FileCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox The file cache connection has the expected default values after initialization - * @covers phpOMS\DataStorage\Cache\Connection\FileCache + * @covers phpOMS\DataStorage\Cache\Connection\FileCache * @group framework */ public function testDefault() : void @@ -71,7 +71,7 @@ class FileCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox The connection to a dedicated cache directory can be established (none-exising directories get created) - * @covers phpOMS\DataStorage\Cache\Connection\FileCache + * @covers phpOMS\DataStorage\Cache\Connection\FileCache * @group framework */ public function testConnect() : void @@ -81,7 +81,7 @@ class FileCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox Different cache data (types) can be set and returned - * @covers phpOMS\DataStorage\Cache\Connection\FileCache + * @covers phpOMS\DataStorage\Cache\Connection\FileCache * @group framework */ public function testSetInputOutput() : void @@ -113,7 +113,7 @@ class FileCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox Cache data can bet added and returned - * @covers phpOMS\DataStorage\Cache\Connection\FileCache + * @covers phpOMS\DataStorage\Cache\Connection\FileCache * @group framework */ public function testAddInputOutput() : void @@ -124,7 +124,7 @@ class FileCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox Cache data cannot be added if it already exists - * @covers phpOMS\DataStorage\Cache\Connection\FileCache + * @covers phpOMS\DataStorage\Cache\Connection\FileCache * @group framework */ public function testInvalidOverwrite() : void @@ -136,7 +136,7 @@ class FileCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox Existing cache data can be replaced - * @covers phpOMS\DataStorage\Cache\Connection\FileCache + * @covers phpOMS\DataStorage\Cache\Connection\FileCache * @group framework */ public function testReplace() : void @@ -150,7 +150,7 @@ class FileCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox None-existing cache data cannot be replaced - * @covers phpOMS\DataStorage\Cache\Connection\FileCache + * @covers phpOMS\DataStorage\Cache\Connection\FileCache * @group framework */ public function testInvalidReplace() : void @@ -160,7 +160,7 @@ class FileCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox Existing cache data can be deleted - * @covers phpOMS\DataStorage\Cache\Connection\FileCache + * @covers phpOMS\DataStorage\Cache\Connection\FileCache * @group framework */ public function testDelete() : void @@ -174,7 +174,7 @@ class FileCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox The cache correctly handles general cache information - * @covers phpOMS\DataStorage\Cache\Connection\FileCache + * @covers phpOMS\DataStorage\Cache\Connection\FileCache * @group framework */ public function testStats() : void @@ -197,7 +197,7 @@ class FileCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox The cache can be flushed - * @covers phpOMS\DataStorage\Cache\Connection\FileCache + * @covers phpOMS\DataStorage\Cache\Connection\FileCache * @group framework */ public function testFlush() : void @@ -223,7 +223,7 @@ class FileCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox Cache data can be set and returned with expiration limits - * @covers phpOMS\DataStorage\Cache\Connection\FileCache + * @covers phpOMS\DataStorage\Cache\Connection\FileCache * @group framework */ public function testUnexpiredInputOutput() : void @@ -234,7 +234,7 @@ class FileCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox Expired cache data cannot be returned - * @covers phpOMS\DataStorage\Cache\Connection\FileCache + * @covers phpOMS\DataStorage\Cache\Connection\FileCache * @group framework */ public function testExpiredInputOutput() : void @@ -248,7 +248,7 @@ class FileCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox Expired cache data can be forced to return - * @covers phpOMS\DataStorage\Cache\Connection\FileCache + * @covers phpOMS\DataStorage\Cache\Connection\FileCache * @group framework */ public function testForceExpiredInputOutput() : void @@ -260,7 +260,7 @@ class FileCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox Unexpired cache data connot be delete if lower expiration is defined - * @covers phpOMS\DataStorage\Cache\Connection\FileCache + * @covers phpOMS\DataStorage\Cache\Connection\FileCache * @group framework */ public function testInvalidDeleteUnexpired() : void @@ -271,7 +271,7 @@ class FileCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox Expired cache data can be deleted if equal expiration is defined - * @covers phpOMS\DataStorage\Cache\Connection\FileCache + * @covers phpOMS\DataStorage\Cache\Connection\FileCache * @group framework */ public function testDeleteExpired() : void @@ -283,7 +283,7 @@ class FileCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox Unexpired data can be force deleted with lower expiration date - * @covers phpOMS\DataStorage\Cache\Connection\FileCache + * @covers phpOMS\DataStorage\Cache\Connection\FileCache * @group framework */ public function testForceDeleteUnexpired() : void @@ -296,7 +296,7 @@ class FileCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox Cach data can be flushed by expiration date - * @covers phpOMS\DataStorage\Cache\Connection\FileCache + * @covers phpOMS\DataStorage\Cache\Connection\FileCache * @group framework */ public function testFlushExpired() : void @@ -310,7 +310,7 @@ class FileCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox A bad cache status will prevent all cache actions - * @covers phpOMS\DataStorage\Cache\Connection\FileCache + * @covers phpOMS\DataStorage\Cache\Connection\FileCache * @group framework */ public function testBadCacheStatus() : void @@ -329,7 +329,7 @@ class FileCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox A invalid cache connection will throw an InvalidConnectionConfigException - * @covers phpOMS\DataStorage\Cache\Connection\FileCache + * @covers phpOMS\DataStorage\Cache\Connection\FileCache * @group framework */ public function testInvalidCachePath() : void @@ -341,7 +341,7 @@ class FileCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox A invalid data type will throw an InvalidArgumentException - * @covers phpOMS\DataStorage\Cache\Connection\FileCache + * @covers phpOMS\DataStorage\Cache\Connection\FileCache * @group framework */ public function testInvalidDataType() : void diff --git a/tests/DataStorage/Cache/Connection/MemCachedTest.php b/tests/DataStorage/Cache/Connection/MemCachedTest.php index 97b7d09f1..de5369a84 100644 --- a/tests/DataStorage/Cache/Connection/MemCachedTest.php +++ b/tests/DataStorage/Cache/Connection/MemCachedTest.php @@ -41,7 +41,7 @@ class MemCachedTest extends \PHPUnit\Framework\TestCase /** * @testdox The memcached connection has the expected default values after initialization - * @covers phpOMS\DataStorage\Cache\Connection\MemCached + * @covers phpOMS\DataStorage\Cache\Connection\MemCached * @group framework */ public function testDefault() : void @@ -64,7 +64,7 @@ class MemCachedTest extends \PHPUnit\Framework\TestCase /** * @testdox The connection to a cache can be established (none-exising directories get created) - * @covers phpOMS\DataStorage\Cache\Connection\MemCached + * @covers phpOMS\DataStorage\Cache\Connection\MemCached * @group framework */ public function testConnect() : void @@ -78,7 +78,7 @@ class MemCachedTest extends \PHPUnit\Framework\TestCase /** * @testdox Different cache data (types) can be set and returned - * @covers phpOMS\DataStorage\Cache\Connection\MemCached + * @covers phpOMS\DataStorage\Cache\Connection\MemCached * @group framework */ public function testSetInputOutput() : void @@ -110,7 +110,7 @@ class MemCachedTest extends \PHPUnit\Framework\TestCase /** * @testdox Cache data can bet added and returned - * @covers phpOMS\DataStorage\Cache\Connection\MemCached + * @covers phpOMS\DataStorage\Cache\Connection\MemCached * @group framework */ public function testAddInputOutput() : void @@ -121,7 +121,7 @@ class MemCachedTest extends \PHPUnit\Framework\TestCase /** * @testdox Cache data cannot be added if it already exists - * @covers phpOMS\DataStorage\Cache\Connection\MemCached + * @covers phpOMS\DataStorage\Cache\Connection\MemCached * @group framework */ public function testInvalidOverwrite() : void @@ -133,7 +133,7 @@ class MemCachedTest extends \PHPUnit\Framework\TestCase /** * @testdox Existing cache data can be replaced - * @covers phpOMS\DataStorage\Cache\Connection\MemCached + * @covers phpOMS\DataStorage\Cache\Connection\MemCached * @group framework */ public function testReplace() : void @@ -147,7 +147,7 @@ class MemCachedTest extends \PHPUnit\Framework\TestCase /** * @testdox None-existing cache data cannot be replaced - * @covers phpOMS\DataStorage\Cache\Connection\MemCached + * @covers phpOMS\DataStorage\Cache\Connection\MemCached * @group framework */ public function testInvalidReplace() : void @@ -157,7 +157,7 @@ class MemCachedTest extends \PHPUnit\Framework\TestCase /** * @testdox Existing cache data can be deleted - * @covers phpOMS\DataStorage\Cache\Connection\MemCached + * @covers phpOMS\DataStorage\Cache\Connection\MemCached * @group framework */ public function testDelete() : void @@ -171,7 +171,7 @@ class MemCachedTest extends \PHPUnit\Framework\TestCase /** * @testdox The cache correctly handles general cache information - * @covers phpOMS\DataStorage\Cache\Connection\MemCached + * @covers phpOMS\DataStorage\Cache\Connection\MemCached * @group framework */ public function testStats() : void @@ -194,7 +194,7 @@ class MemCachedTest extends \PHPUnit\Framework\TestCase /** * @testdox The cache can be flushed - * @covers phpOMS\DataStorage\Cache\Connection\MemCached + * @covers phpOMS\DataStorage\Cache\Connection\MemCached * @group framework */ public function testFlush() : void @@ -220,7 +220,7 @@ class MemCachedTest extends \PHPUnit\Framework\TestCase /** * @testdox Cache data can be set and returned with expiration limits - * @covers phpOMS\DataStorage\Cache\Connection\MemCached + * @covers phpOMS\DataStorage\Cache\Connection\MemCached * @group framework */ public function testUnexpiredInputOutput() : void @@ -231,7 +231,7 @@ class MemCachedTest extends \PHPUnit\Framework\TestCase /** * @testdox Expired cache data cannot be returned - * @covers phpOMS\DataStorage\Cache\Connection\MemCached + * @covers phpOMS\DataStorage\Cache\Connection\MemCached * @group framework */ public function testExpiredInputOutput() : void @@ -245,7 +245,7 @@ class MemCachedTest extends \PHPUnit\Framework\TestCase /** * @testdox Expired cache data can be forced to return - * @covers phpOMS\DataStorage\Cache\Connection\MemCached + * @covers phpOMS\DataStorage\Cache\Connection\MemCached * @group framework */ public function testForceExpiredInputOutput() : void @@ -257,7 +257,7 @@ class MemCachedTest extends \PHPUnit\Framework\TestCase /** * @testdox Unexpired cache data connot be delete if lower expiration is defined - * @covers phpOMS\DataStorage\Cache\Connection\MemCached + * @covers phpOMS\DataStorage\Cache\Connection\MemCached * @group framework */ public function testInvalidDeleteUnexpired() : void @@ -268,7 +268,7 @@ class MemCachedTest extends \PHPUnit\Framework\TestCase /** * @testdox Expired cache data can be deleted if equal expiration is defined - * @covers phpOMS\DataStorage\Cache\Connection\MemCached + * @covers phpOMS\DataStorage\Cache\Connection\MemCached * @group framework */ public function testDeleteExpired() : void @@ -280,7 +280,7 @@ class MemCachedTest extends \PHPUnit\Framework\TestCase /** * @testdox Unexpired data can be force deleted with lower expiration date - * @covers phpOMS\DataStorage\Cache\Connection\MemCached + * @covers phpOMS\DataStorage\Cache\Connection\MemCached * @group framework */ public function testForceDeleteUnexpired() : void @@ -293,7 +293,7 @@ class MemCachedTest extends \PHPUnit\Framework\TestCase /** * @testdox Cach data can be flushed by expiration date - * @covers phpOMS\DataStorage\Cache\Connection\MemCached + * @covers phpOMS\DataStorage\Cache\Connection\MemCached * @group framework */ public function testFlushExpired() : void @@ -307,7 +307,7 @@ class MemCachedTest extends \PHPUnit\Framework\TestCase /** * @testdox A bad cache status will prevent all cache actions - * @covers phpOMS\DataStorage\Cache\Connection\MemCached + * @covers phpOMS\DataStorage\Cache\Connection\MemCached * @group framework */ public function testBadCacheStatus() : void @@ -326,7 +326,7 @@ class MemCachedTest extends \PHPUnit\Framework\TestCase /** * @testdox A invalid data type will throw an InvalidArgumentException - * @covers phpOMS\DataStorage\Cache\Connection\MemCached + * @covers phpOMS\DataStorage\Cache\Connection\MemCached * @group framework */ public function testInvalidDataType() : void @@ -338,7 +338,7 @@ class MemCachedTest extends \PHPUnit\Framework\TestCase /** * @testdox A invalid host throws a InvalidConnectionConfigException - * @covers phpOMS\DataStorage\Cache\Connection\MemCached + * @covers phpOMS\DataStorage\Cache\Connection\MemCached * @group framework */ public function testInvalidCacheHost() : void @@ -353,7 +353,7 @@ class MemCachedTest extends \PHPUnit\Framework\TestCase /** * @testdox A invalid port throws a InvalidConnectionConfigException - * @covers phpOMS\DataStorage\Cache\Connection\MemCached + * @covers phpOMS\DataStorage\Cache\Connection\MemCached * @group framework */ public function testInvalidCachePort() : void diff --git a/tests/DataStorage/Cache/Connection/NullCacheTest.php b/tests/DataStorage/Cache/Connection/NullCacheTest.php index 037c032aa..41167b1f2 100644 --- a/tests/DataStorage/Cache/Connection/NullCacheTest.php +++ b/tests/DataStorage/Cache/Connection/NullCacheTest.php @@ -26,7 +26,7 @@ class NullCacheTest extends \PHPUnit\Framework\TestCase { /** * @testdox The default cache has the expected default values after initialization - * @covers phpOMS\DataStorage\Cache\Connection\NullCache + * @covers phpOMS\DataStorage\Cache\Connection\NullCache * @group framework */ public function testCache() : void diff --git a/tests/DataStorage/Cache/Connection/RedisCacheTest.php b/tests/DataStorage/Cache/Connection/RedisCacheTest.php index cf3d58627..104f263a0 100644 --- a/tests/DataStorage/Cache/Connection/RedisCacheTest.php +++ b/tests/DataStorage/Cache/Connection/RedisCacheTest.php @@ -41,7 +41,7 @@ class RedisCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox The redis cache connection has the expected default values after initialization - * @covers phpOMS\DataStorage\Cache\Connection\RedisCache + * @covers phpOMS\DataStorage\Cache\Connection\RedisCache * @group framework */ public function testDefault() : void @@ -64,7 +64,7 @@ class RedisCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox The connection to a cache can be established (none-exising directories get created) - * @covers phpOMS\DataStorage\Cache\Connection\RedisCache + * @covers phpOMS\DataStorage\Cache\Connection\RedisCache * @group framework */ public function testConnect() : void @@ -79,7 +79,7 @@ class RedisCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox Different cache data (types) can be set and returned - * @covers phpOMS\DataStorage\Cache\Connection\RedisCache + * @covers phpOMS\DataStorage\Cache\Connection\RedisCache * @group framework */ public function testSetInputOutput() : void @@ -111,7 +111,7 @@ class RedisCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox Cache data can bet added and returned - * @covers phpOMS\DataStorage\Cache\Connection\RedisCache + * @covers phpOMS\DataStorage\Cache\Connection\RedisCache * @group framework */ public function testAddInputOutput() : void @@ -122,7 +122,7 @@ class RedisCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox Cache data cannot be added if it already exists - * @covers phpOMS\DataStorage\Cache\Connection\RedisCache + * @covers phpOMS\DataStorage\Cache\Connection\RedisCache * @group framework */ public function testInvalidOverwrite() : void @@ -134,7 +134,7 @@ class RedisCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox Existing cache data can be replaced - * @covers phpOMS\DataStorage\Cache\Connection\RedisCache + * @covers phpOMS\DataStorage\Cache\Connection\RedisCache * @group framework */ public function testReplace() : void @@ -148,7 +148,7 @@ class RedisCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox None-existing cache data cannot be replaced - * @covers phpOMS\DataStorage\Cache\Connection\RedisCache + * @covers phpOMS\DataStorage\Cache\Connection\RedisCache * @group framework */ public function testInvalidReplace() : void @@ -158,7 +158,7 @@ class RedisCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox Existing cache data can be deleted - * @covers phpOMS\DataStorage\Cache\Connection\RedisCache + * @covers phpOMS\DataStorage\Cache\Connection\RedisCache * @group framework */ public function testDelete() : void @@ -172,7 +172,7 @@ class RedisCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox The cache correctly handles general cache information - * @covers phpOMS\DataStorage\Cache\Connection\RedisCache + * @covers phpOMS\DataStorage\Cache\Connection\RedisCache * @group framework */ public function testStats() : void @@ -195,7 +195,7 @@ class RedisCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox The cache can be flushed - * @covers phpOMS\DataStorage\Cache\Connection\RedisCache + * @covers phpOMS\DataStorage\Cache\Connection\RedisCache * @group framework */ public function testFlush() : void @@ -221,7 +221,7 @@ class RedisCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox Cache data can be set and returned with expiration limits - * @covers phpOMS\DataStorage\Cache\Connection\RedisCache + * @covers phpOMS\DataStorage\Cache\Connection\RedisCache * @group framework */ public function testUnexpiredInputOutput() : void @@ -232,7 +232,7 @@ class RedisCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox Expired cache data cannot be returned - * @covers phpOMS\DataStorage\Cache\Connection\RedisCache + * @covers phpOMS\DataStorage\Cache\Connection\RedisCache * @group framework */ public function testExpiredInputOutput() : void @@ -246,7 +246,7 @@ class RedisCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox Expired cache data can be forced to return - * @covers phpOMS\DataStorage\Cache\Connection\RedisCache + * @covers phpOMS\DataStorage\Cache\Connection\RedisCache * @group framework */ public function testForceExpiredInputOutput() : void @@ -258,7 +258,7 @@ class RedisCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox Unexpired cache data connot be delete if lower expiration is defined - * @covers phpOMS\DataStorage\Cache\Connection\RedisCache + * @covers phpOMS\DataStorage\Cache\Connection\RedisCache * @group framework */ public function testInvalidDeleteUnexpired() : void @@ -269,7 +269,7 @@ class RedisCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox Expired cache data can be deleted if equal expiration is defined - * @covers phpOMS\DataStorage\Cache\Connection\RedisCache + * @covers phpOMS\DataStorage\Cache\Connection\RedisCache * @group framework */ public function testDeleteExpired() : void @@ -281,7 +281,7 @@ class RedisCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox Unexpired data can be force deleted with lower expiration date - * @covers phpOMS\DataStorage\Cache\Connection\RedisCache + * @covers phpOMS\DataStorage\Cache\Connection\RedisCache * @group framework */ public function testForceDeleteUnexpired() : void @@ -294,7 +294,7 @@ class RedisCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox Cach data can be flushed by expiration date - * @covers phpOMS\DataStorage\Cache\Connection\RedisCache + * @covers phpOMS\DataStorage\Cache\Connection\RedisCache * @group framework */ public function testFlushExpired() : void @@ -308,7 +308,7 @@ class RedisCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox A bad cache status will prevent all cache actions - * @covers phpOMS\DataStorage\Cache\Connection\RedisCache + * @covers phpOMS\DataStorage\Cache\Connection\RedisCache * @group framework */ public function testBadCacheStatus() : void @@ -328,7 +328,7 @@ class RedisCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox A invalid host throws a InvalidConnectionConfigException - * @covers phpOMS\DataStorage\Cache\Connection\RedisCache + * @covers phpOMS\DataStorage\Cache\Connection\RedisCache * @group framework */ public function testInvalidCacheHost() : void @@ -343,7 +343,7 @@ class RedisCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox A invalid port throws a InvalidConnectionConfigException - * @covers phpOMS\DataStorage\Cache\Connection\RedisCache + * @covers phpOMS\DataStorage\Cache\Connection\RedisCache * @group framework */ public function testInvalidCachePort() : void @@ -358,7 +358,7 @@ class RedisCacheTest extends \PHPUnit\Framework\TestCase /** * @testdox A invalid database throws a InvalidConnectionConfigException - * @covers phpOMS\DataStorage\Cache\Connection\RedisCache + * @covers phpOMS\DataStorage\Cache\Connection\RedisCache * @group framework */ public function testInvalidCacheDatabase() : void diff --git a/tests/DataStorage/Database/Query/BuilderTest.php b/tests/DataStorage/Database/Query/BuilderTest.php index 8b4756dc9..7a0afe640 100644 --- a/tests/DataStorage/Database/Query/BuilderTest.php +++ b/tests/DataStorage/Database/Query/BuilderTest.php @@ -88,6 +88,10 @@ class BuilderTest extends \PHPUnit\Framework\TestCase ); self::assertEquals($query->toSql(), $query->__toString()); + + $query = new Builder($this->con); + $sql = 'SELECT `a`.`test` FROM `a` as b WHERE `a`.`test` = 1 ORDER BY \rand() LIMIT 1;'; + self::assertEquals($sql, $query->random('a.test')->fromAs('a', 'b')->where('a.test', '=', 1)->toSql()); } /** diff --git a/tests/DataStorage/Database/SchemaMapperTest.php b/tests/DataStorage/Database/SchemaMapperTest.php new file mode 100644 index 000000000..79b669401 --- /dev/null +++ b/tests/DataStorage/Database/SchemaMapperTest.php @@ -0,0 +1,87 @@ +get()->con->prepare( + 'CREATE TABLE `oms_test_base` ( + `test_base_id` int(11) NOT NULL AUTO_INCREMENT, + `test_base_string` varchar(254) NOT NULL, + `test_base_int` int(11) NOT NULL, + `test_base_bool` tinyint(1) DEFAULT NULL, + `test_base_null` int(11) DEFAULT NULL, + `test_base_float` decimal(5, 4) DEFAULT NULL, + `test_base_belongs_to_one` int(11) DEFAULT NULL, + `test_base_owns_one_self` int(11) DEFAULT NULL, + `test_base_json` varchar(254) DEFAULT NULL, + `test_base_json_serializable` varchar(254) DEFAULT NULL, + `test_base_datetime` datetime DEFAULT NULL, + `test_base_datetime_null` datetime DEFAULT NULL, /* There was a bug where it returned the current date because new \DateTime(null) === current date which is wrong, we want null as value! */ + PRIMARY KEY (`test_base_id`) + )ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1;' + )->execute(); + + $GLOBALS['dbpool']->get()->con->prepare( + 'CREATE TABLE `oms_test_belongs_to_one` ( + `test_belongs_to_one_id` int(11) NOT NULL AUTO_INCREMENT, + `test_belongs_to_one_string` varchar(254) NOT NULL, + PRIMARY KEY (`test_belongs_to_one_id`) + )ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1;' + )->execute(); + } + + protected function tearDown() : void + { + $GLOBALS['dbpool']->get()->con->prepare('DROP TABLE oms_test_base')->execute(); + $GLOBALS['dbpool']->get()->con->prepare('DROP TABLE oms_test_belongs_to_one')->execute(); + } + + /** + * @testdox The tables can be returned + * @covers phpOMS\DataStorage\Database\SchemaMapper + * @group framework + */ + public function testTables() : void + { + $schema = new SchemaMapper($GLOBALS['dbpool']->get()); + + self::assertTrue(\in_array('oms_test_base', $schema->getTables())); + self::assertTrue(\in_array('oms_test_belongs_to_one', $schema->getTables())); + } + + /** + * @testdox The fields of a table can be returned + * @covers phpOMS\DataStorage\Database\SchemaMapper + * @group framework + */ + public function testFields() : void + { + $schema = new SchemaMapper($GLOBALS['dbpool']->get()); + + self::assertEquals( + 12, + \count($schema->getFields('oms_test_base')) + ); + } +} diff --git a/tests/Math/Matrix/MatrixTest.php b/tests/Math/Matrix/MatrixTest.php index b0a7af212..5b923cc77 100644 --- a/tests/Math/Matrix/MatrixTest.php +++ b/tests/Math/Matrix/MatrixTest.php @@ -277,9 +277,18 @@ class MatrixTest extends \PHPUnit\Framework\TestCase ], $A->inverse()->toArray(), '', 0.2);*/ } - public function testReduce() : void + /** + * @testdox The upper triangular matrix can be calculated + * @covers phpOMS\Math\Matrix\Matrix + * @group framework + */ + public function testUpperTriangular() : void { self::assertEquals([[-6, -7], [0, -5]], $this->C->upperTriangular()->getMatrix()); + } + + public function testLowerTriangular() : void + { self::markTestIncomplete(); //self::assertEquals([], $this->C->lowerTriangular()->getMatrix()); //self::assertEquals([], $this->C->diagonalize()->getMatrix()); diff --git a/tests/Math/Topology/Metrics2DTest.php b/tests/Math/Topology/Metrics2DTest.php index 32cb69be8..59303a872 100644 --- a/tests/Math/Topology/Metrics2DTest.php +++ b/tests/Math/Topology/Metrics2DTest.php @@ -63,6 +63,20 @@ class Metrics2DTest extends \PHPUnit\Framework\TestCase ); } + /** + * @testdox The octile distance can be calculated + * @covers phpOMS\Math\Topology\Metrics2D + * @group framework + */ + public function testOctile() : void + { + self::assertEqualsWithDelta( + 8.24264, + Metrics2D::octile(['x' => 0, 'y' => 3], ['x' => 7, 'y' => 6]), + 0.1 + ); + } + /** * @testdox The minkowski distance can be calculated * @covers phpOMS\Math\Topology\Metrics2D diff --git a/tests/Message/Http/ResponseTest.php b/tests/Message/Http/ResponseTest.php index 7ab6d5139..f96d891e7 100644 --- a/tests/Message/Http/ResponseTest.php +++ b/tests/Message/Http/ResponseTest.php @@ -160,13 +160,25 @@ class ResponseTest extends \PHPUnit\Framework\TestCase } /** - * @testdox A response can be forced to minimize the content by removing newlines and whitespaces + * @testdox Json data can be decoded from the response data + * @covers phpOMS\Message\Http\Response + * @group framework + */ + public function testJsonDataDecode() : void + { + $array = [1, 'abc' => 'def']; + $this->response->set('json', \json_encode($array)); + + self::assertEquals($array, $this->response->getJsonData()); + } + + /** + * @testdox A html response can be forced to minimize the content by removing newlines and whitespaces * @covers phpOMS\Message\Http\Response * @group framework */ public function testMinimizedRender() : void { - $this->response->set('view', new class() extends \phpOMS\Views\View { public function render(...$data) : string { @@ -178,6 +190,24 @@ class ResponseTest extends \PHPUnit\Framework\TestCase self::assertEquals('view_string with
text
that has whitespaces and new lines', $this->response->render(true)); } + /** + * @testdox None-html responses cannot be forced to minimize the content by removing newlines and whitespaces + * @covers phpOMS\Message\Http\Response + * @group framework + */ + public function testInvalidMinimizedRender() : void + { + $this->response->set('view', new class() extends \phpOMS\Views\View { + public function render(...$data) : string + { + return " view_string with
text
that has \n whitespaces and \n\nnew lines\n "; + } + }); + + $this->response->getHeader()->set('Content-Type', MimeType::M_TEXT . '; charset=utf-8', true); + self::assertEquals(" view_string with
text
that has \n whitespaces and \n\nnew lines\n ", $this->response->render(true)); + } + /** * @testdox Invalid response data results in an empty array * @covers phpOMS\Message\Http\Response diff --git a/tests/Module/ModuleManagerTest.php b/tests/Module/ModuleManagerTest.php index 27d8e6a3e..bb917992d 100644 --- a/tests/Module/ModuleManagerTest.php +++ b/tests/Module/ModuleManagerTest.php @@ -146,6 +146,8 @@ class ModuleManagerTest extends \PHPUnit\Framework\TestCase /** * @testdox A module can be installed and its status can be changed * @covers phpOMS\Module\ModuleManager + * @covers phpOMS\Module\StatusAbstract + * @covers phpOMS\Module\InstallerAbstract * @group framework */ public function testStatus() : void @@ -225,6 +227,7 @@ class ModuleManagerTest extends \PHPUnit\Framework\TestCase /** * @testdox A module can be uninstalled * @covers phpOMS\Module\ModuleManager + * @covers phpOMS\Module\UninstallerAbstract * @group framework */ public function testUninstall() : void diff --git a/tests/Stdlib/Base/EnumArrayTest.php b/tests/Stdlib/Base/EnumArrayTest.php index 447d0978e..101627913 100644 --- a/tests/Stdlib/Base/EnumArrayTest.php +++ b/tests/Stdlib/Base/EnumArrayTest.php @@ -112,6 +112,6 @@ class EnumArrayTest extends \PHPUnit\Framework\TestCase */ public function testRandomValue() : void { - self::assertTrue(EnumDemo::isValidValue(EnumDemo::getRandom())); + self::assertTrue(EnumArrayDemo::isValidValue(EnumArrayDemo::getRandom())); } } diff --git a/tests/Stdlib/Base/HeapTest.php b/tests/Stdlib/Base/HeapTest.php index 131ff7968..a126d9d45 100644 --- a/tests/Stdlib/Base/HeapTest.php +++ b/tests/Stdlib/Base/HeapTest.php @@ -23,12 +23,30 @@ use phpOMS\Stdlib\Base\Heap; */ class HeapTest extends \PHPUnit\Framework\TestCase { + /** + * @testdox A list of elements can be turned into a heap + * @covers phpOMS\Stdlib\Base\Heap + * @group framework + */ + public function testHeapify() : void + { + $heap = new Heap(); + $heap->heapify([3, 2, 6, 1, 5, 4]); + + self::assertEquals(1, $heap->pop()); + self::assertEquals(2, $heap->pop()); + self::assertEquals(3, $heap->pop()); + self::assertEquals(4, $heap->pop()); + self::assertEquals(5, $heap->pop()); + self::assertEquals(6, $heap->pop()); + } + /** * @testdox Elements get correctly pushed to the heap * @covers phpOMS\Stdlib\Base\Heap * @group framework */ - public function testSize(): void + public function testSize() : void { $heap = new Heap(); for ($i = 1; $i < 6; ++$i) { diff --git a/tests/Stdlib/Base/SmartDateTimeTest.php b/tests/Stdlib/Base/SmartDateTimeTest.php index 6ef8a83bc..2e8e5d6f6 100644 --- a/tests/Stdlib/Base/SmartDateTimeTest.php +++ b/tests/Stdlib/Base/SmartDateTimeTest.php @@ -128,6 +128,32 @@ class SmartDateTimeTest extends \PHPUnit\Framework\TestCase self::assertEquals(\date("Y-m-01", \strtotime($expected->format('Y-m-d'))), $obj->getStartOfMonth()->format('Y-m-d')); } + /** + * @testdox A smart datetime can be returned of the last day of the week + * @covers phpOMS\Stdlib\Base\SmartDateTime + * @group framework + */ + public function testEndOfWeek() : void + { + $expected = new \DateTime('2019-11-23'); + $obj = new SmartDateTime('2019-11-21'); + + self::assertEquals($expected->format('Y-m-d'), $obj->getEndOfWeek()->format('Y-m-d')); + } + + /** + * @testdox A smart datetime can be returned of the fist day of the week + * @covers phpOMS\Stdlib\Base\SmartDateTime + * @group framework + */ + public function testStartOfWeek() : void + { + $expected = new \DateTime('2019-11-17'); + $obj = new SmartDateTime('2019-11-21'); + + self::assertEquals($expected->format('Y-m-d'), $obj->getStartOfWeek()->format('Y-m-d')); + } + /** * @testdox A date or year can be checked if it is a leap year * @covers phpOMS\Stdlib\Base\SmartDateTime @@ -139,6 +165,8 @@ class SmartDateTimeTest extends \PHPUnit\Framework\TestCase self::assertTrue((new SmartDateTime('2104-07-20'))->isLeapYear()); self::assertFalse(SmartDateTime::leapYear(2103)); self::assertTrue(SmartDateTime::leapYear(2104)); + self::assertFalse(SmartDateTime::leapYear(1900)); + self::assertTrue(SmartDateTime::leapYear(1600)); } /** @@ -155,6 +183,16 @@ class SmartDateTimeTest extends \PHPUnit\Framework\TestCase self::assertEquals(\date('w', $expected->getTimestamp()), $obj->getDayOfWeek()); } + /** + * @testdox A invalid day of the week returns a negative week index + * @covers phpOMS\Stdlib\Base\SmartDateTime + * @group framework + */ + public function testInvalidDayOfWeek() : void + { + self::assertEquals(-1, SmartDateTime::dayOfWeek(-2, 0, 99)); + } + /** * @testdox A calendar sheet is retunred containing all days of the month and some days of the previous and next month * @covers phpOMS\Stdlib\Base\SmartDateTime diff --git a/tests/Stdlib/Queue/PriorityQueueTest.php b/tests/Stdlib/Queue/PriorityQueueTest.php index 95a9bdfbf..7365453f2 100644 --- a/tests/Stdlib/Queue/PriorityQueueTest.php +++ b/tests/Stdlib/Queue/PriorityQueueTest.php @@ -163,9 +163,12 @@ class PriorityQueueTest extends \PHPUnit\Framework\TestCase public function testPriorityChange() : void { $queue = new PriorityQueue(); - $id1 = $queue->insert('a'); + $queue->setPriority($id1, 3); + self::assertEquals(3, $queue->get($id1)['priority']); + $queue = new PriorityQueue(PriorityMode::HIGHEST); + $id1 = $queue->insert('a'); $queue->setPriority($id1, 3); self::assertEquals(3, $queue->get($id1)['priority']); } diff --git a/tests/System/File/Local/LocalStorageTest.php b/tests/System/File/Local/LocalStorageTest.php index e9d020430..d1a791c5a 100644 --- a/tests/System/File/Local/LocalStorageTest.php +++ b/tests/System/File/Local/LocalStorageTest.php @@ -26,7 +26,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase { /** * @testdox A directory can be created - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticCreateDirectory() : void @@ -40,7 +40,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox A directory can be checked for existence - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticExistsDirectory() : void @@ -51,7 +51,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox An existing directory cannot be overwritten - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testInvalidStaticOverwriteDirectory() : void @@ -65,7 +65,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox A directory can be forced to be created recursively - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticSubdirDirectory() : void @@ -81,7 +81,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox The name of a directory is just its name without its path - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticNameDirectory() : void @@ -93,7 +93,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox The basename is the same as the name of the directory - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticBasenameDirectory() : void @@ -105,7 +105,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox The dirname is the same as the name of the directory - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticDirnameDirectory() : void @@ -117,7 +117,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox The parent of a directory can be returned - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticParentDirectory() : void @@ -129,7 +129,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox The full absolute path of a directory can be returned - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticDirectoryPathDirectory() : void @@ -141,7 +141,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox The directories creation date can be returned - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticCreatedAtDirectory() : void @@ -158,7 +158,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox The directories last change date can be returned - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticChangedAtDirectory() : void @@ -175,7 +175,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox A directory can be deleted - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticDeleteDirectory() : void @@ -189,7 +189,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox A none-existing directory cannot be deleted - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testInvalidStaticDeleteDirectory() : void @@ -201,7 +201,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox The size of a directory can be returned - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticSizeRecursiveDirectory() : void @@ -212,7 +212,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox The size of a none-existing directory is negative - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testInvalidStaticSizeRecursiveDirectory() : void @@ -223,7 +223,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox The recursive size of a directory is equals or greater than the size of the same directory none-recursive - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticSizeDirectory() : void @@ -234,7 +234,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox The permission of a directory can be returned - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticPermissionDirectory() : void @@ -245,7 +245,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox The permission of a none-existing directory is negative - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testInvalidStaticPermissionDirectory() : void @@ -256,7 +256,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox A directory can be copied recursively - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticCopyDirectory() : void @@ -270,7 +270,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox A directory can be moved/renamed to a different path - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticMoveDirectory() : void @@ -285,7 +285,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox The amount of files in a directory can be returned recursively - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticCountRecursiveDirectory() : void @@ -296,7 +296,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox The amount of files in a directory can be returned none-recursively - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticCountDirectory() : void @@ -307,7 +307,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox The amount of files of a none-existing directory is negative - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testInvalidStaticCountDirectory() : void @@ -318,7 +318,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox All files and sub-directories of a directory can be listed - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticListFilesDirectory() : void @@ -329,7 +329,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox A none-existing directory returns a empty list of files and sub-directories - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testInvalidListPathDirectory() : void @@ -339,7 +339,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox A invalid directory cannot be copied to a new destination - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testInvalidCopyPathDirectory() : void @@ -349,7 +349,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox A invalid directory cannot be moved to a new destination - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testInvalidMovePathDirectory() : void @@ -359,7 +359,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox Reading the creation date of a none-existing directory throws a PathException - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testInvalidCreatedPathDirectory() : void @@ -371,7 +371,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox Reading the last change date of a none-existing directory throws a PathException - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testInvalidChangedPathDirectory() : void @@ -383,7 +383,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox Reading the owner of a none-existing directory throws a PathException - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testInvalidOwnerPathDirectory() : void @@ -395,7 +395,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox A file without content can be created - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticCreateFile() : void @@ -410,7 +410,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox A file cannot be created if it already exists - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testInvalidStaticCreateFile() : void @@ -425,7 +425,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox A file with content can be created - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticPutFile() : void @@ -440,7 +440,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox A file cannot be replaced if it doesn't exists - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testInvalidStaticCreateReplaceFile() : void @@ -452,7 +452,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox A file cannot be appended if it doesn't exists - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testInvalidStaticCreateAppendFile() : void @@ -464,7 +464,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox A file cannot be prepended if it doesn't exists - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testInvalidStaticCreatePrependFile() : void @@ -476,7 +476,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox A file can be checked for existence - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticExistsFile() : void @@ -487,7 +487,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox A file can be replaced with a new one - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticReplaceFile() : void @@ -503,7 +503,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox The set alias works like the replace flag - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticSetAliasFile() : void @@ -520,7 +520,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox A file can be appended with additional content - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticAppendFile() : void @@ -536,7 +536,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox The append alias works like the append flag - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticAppendAliasFile() : void @@ -552,7 +552,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox A file can be prepended with additional content - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticPrependFile() : void @@ -568,7 +568,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox The prepend alias works like the prepend flag - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticPrependAliasFile() : void @@ -584,7 +584,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox The content of a file can be read - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticGetFile() : void @@ -598,7 +598,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox The parent directory of a file can be returned - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticParentFile() : void @@ -610,7 +610,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox The extension of a file can be returned - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticExtensionFile() : void @@ -622,7 +622,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox The name of a file can be returned - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticNameFile() : void @@ -634,7 +634,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox The basename of a file can be returned - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticBaseNameFile() : void @@ -646,7 +646,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox The file name of a file can be returned - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticDirnameFile() : void @@ -658,7 +658,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox The file path of a file can be returned - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticDirectoryPathFile() : void @@ -670,7 +670,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox The count of a file is always 1 - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticCountFile() : void @@ -682,7 +682,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox The directories creation date can be returned - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticCreatedAtFile() : void @@ -698,7 +698,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox The directories last change date can be returned - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticChangedAtFile() : void @@ -714,7 +714,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox A file can be deleted - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticDeleteFile() : void @@ -728,7 +728,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox A none-existing file cannot be deleted - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testInvalidStaticDeleteFile() : void @@ -740,7 +740,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox The size of a file can be returned - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticSizeFile() : void @@ -755,7 +755,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox The permission of a file can be returned - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticPermissionFile() : void @@ -770,7 +770,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox The permission of a none-existing file is negative - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testInvalidStaticPermissionFile() : void @@ -781,7 +781,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox A file can be copied to a different location - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticCopyFile() : void @@ -804,7 +804,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox A file cannot be copied to a different location if the destination already exists - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testInvalidStaticCopyFile() : void @@ -824,7 +824,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox A file can be forced to be copied to a different location even if the destination already exists - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticCopyOverwriteFile() : void @@ -844,7 +844,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox A file can be moved to a different location - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticMoveFile() : void @@ -866,7 +866,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox A file cannot be moved to a different location if the destination already exists - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testInvalidStaticMoveFile() : void @@ -887,7 +887,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox A file can be forced to be moved to a different location even if the destination already exists - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testStaticMoveOverwriteFile() : void @@ -907,7 +907,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox The size of a none-existing file is negative - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testInvalidSizePathFile() : void @@ -917,7 +917,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox A none-existing file cannot be copied - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testInvalidCopyPathFile() : void @@ -927,7 +927,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox A none-existing file cannot be moved - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testInvalidMovePathFile() : void @@ -937,7 +937,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox Reading the content of a none-existing file throws a PathException - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testInvalidGetPathFile() : void @@ -949,7 +949,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox Reading the created date of a none-existing file throws a PathException - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testInvalidCreatedPathFile() : void @@ -961,7 +961,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox Reading the last change date of a none-existing file throws a PathException - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testInvalidChangedPathFile() : void @@ -973,7 +973,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox Reading the owner of a none-existing file throws a PathException - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testInvalidOwnerPathFile() : void @@ -985,7 +985,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox Writing data to a destination which looks like a directory throws a PathException - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testInvalidPutPath() : void @@ -997,7 +997,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox Reading data from a directory throws a PathException - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testInvalidGetPath() : void @@ -1009,7 +1009,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox Trying to run list on a file throws a PathException - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testInvalidListPath() : void @@ -1021,7 +1021,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox Setting data to a destination which looks like a directory throws a PathException - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testInvalidSetPath() : void @@ -1033,7 +1033,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox Appending data to a destination which looks like a directory throws a PathException - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testInvalidAppendPath() : void @@ -1045,7 +1045,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox Prepending data to a destination which looks like a directory throws a PathException - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testInvalidPrependPath() : void @@ -1057,7 +1057,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase /** * @testdox Reading the extension of a destination which looks like a directory throws a PathException - * @covers phpOMS\System\File\Local\LocalStorage + * @covers phpOMS\System\File\Local\LocalStorage * @group framework */ public function testInvalidExtensionPath() : void diff --git a/tests/System/File/StorageTest.php b/tests/System/File/StorageTest.php index fb2c8a9ab..7840e5b45 100644 --- a/tests/System/File/StorageTest.php +++ b/tests/System/File/StorageTest.php @@ -53,7 +53,7 @@ class StorageTest extends \PHPUnit\Framework\TestCase public function testInputOutput() : void { self::assertTrue(Storage::register('ftps', '\phpOMS\System\File\Ftp\FtpStorage')); - self::assertTrue(Storage::register('test', LocalStorage::getInstance())); + self::assertTrue(Storage::register('test', new LocalStorage())); self::assertInstanceOf('\phpOMS\System\File\Ftp\FtpStorage', Storage::env('ftps')); self::assertInstanceOf('\phpOMS\System\File\Local\LocalStorage', Storage::env('test')); } @@ -65,8 +65,8 @@ class StorageTest extends \PHPUnit\Framework\TestCase */ public function testInvalidRegister() : void { - self::assertTrue(Storage::register('test2', LocalStorage::getInstance())); - self::assertFalse(Storage::register('test2', LocalStorage::getInstance())); + self::assertTrue(Storage::register('test2', new LocalStorage())); + self::assertFalse(Storage::register('test2', new LocalStorage())); } /** diff --git a/tests/UnhandledHandlerTest.php b/tests/UnhandledHandlerTest.php index 44edc20cf..4be710f5d 100644 --- a/tests/UnhandledHandlerTest.php +++ b/tests/UnhandledHandlerTest.php @@ -21,6 +21,9 @@ use phpOMS\UnhandledHandler; */ class UnhandledHandlerTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\UnhandledHandler + */ public function testErrorHandling() : void { \set_exception_handler(['\phpOMS\UnhandledHandler', 'exceptionHandler']); diff --git a/tests/Uri/HttpTest.php b/tests/Uri/HttpTest.php index b82369369..3bfc845c3 100644 --- a/tests/Uri/HttpTest.php +++ b/tests/Uri/HttpTest.php @@ -241,4 +241,21 @@ class HttpTest extends \PHPUnit\Framework\TestCase $obj = new Http('https://www.google.com/test/path.php?para1=abc¶2=2#frag'); self::assertEquals('/test/path?para1=abc¶2=2', $obj->getRoute()); } + + /** + * @testdox A invalid uri cannot get parsed + * @covers phpOMS\Uri\Http + * @group framework + */ + public function testInvalidUri() : void + { + $obj = new Http('http:///03*l.2/test?abc=d'); + + self::assertEquals('', $obj->getPath()); + self::assertEquals('', $obj->getPass()); + self::assertEquals('', $obj->getUser()); + self::assertEquals(80, $obj->getPort()); + self::assertEquals('', $obj->getUserInfo()); + self::assertEquals('', $obj->getRootPath()); + } }