improve tests

This commit is contained in:
Dennis Eichhorn 2019-12-07 18:38:17 +01:00
parent 7eaf29e912
commit 2350b6cf53
31 changed files with 498 additions and 270 deletions

View File

@ -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;
}

View File

@ -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.');
}

View File

@ -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);
}
}

View File

@ -59,11 +59,13 @@ class SchemaMapper
public function getTables() : array
{
$builder = new Builder($this->db);
$tNames = $builder->selectTables()->execute();
/** @var array<int, string[]> $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;

View File

@ -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
*

View File

@ -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
*

View File

@ -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;
}
}

View File

@ -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;
}

View File

@ -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}
*/

View File

@ -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}
*/

View File

@ -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;
}
/**

View File

@ -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.
*

View File

@ -0,0 +1,76 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace phpOMS\tests\Algorithm\PathFinding;
use phpOMS\Algorithm\PathFinding\Heuristic;
use phpOMS\Algorithm\PathFinding\HeuristicType;
require_once __DIR__ . '/../../Autoloader.php';
/**
* @testdox phpOMS\tests\Algorithm\PathFinding\HeuristicTest: Heuristic for path finding
*
* @internal
*/
class HeuristicTest extends \PHPUnit\Framework\TestCase
{
/**
* @testdox The heuristics return the corret metric results
* @covers phpOMS\Algorithm\PathFinding\Heuristic
* @group framework
*/
public function testHeuristics() : void
{
self::assertEquals(
10.0,
Heuristic::metric(['x' => 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
);
}
}

View File

@ -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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @group framework
*/
public function testInvalidDataType() : void

View File

@ -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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @group framework
*/
public function testInvalidCachePort() : void

View File

@ -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<extended>
* @group framework
*/
public function testCache() : void

View File

@ -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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @group framework
*/
public function testInvalidCacheDatabase() : void

View File

@ -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());
}
/**

View File

@ -0,0 +1,87 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace phpOMS\tests\DataStorage\Database;
use phpOMS\DataStorage\Database\SchemaMapper;
/**
* @testdox phpOMS\tests\DataStorage\Database\SchemaMapperTest: Mapper for the database schema
*
* @internal
*/
class SchemaMapperTest extends \PHPUnit\Framework\TestCase
{
protected function setUp() : void
{
$GLOBALS['dbpool']->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'))
);
}
}

View File

@ -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());

View File

@ -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

View File

@ -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<extended>
* @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<extended>
* @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 <div> text</div> 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<extended>
* @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 <div> text</div> 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 <div> text</div> 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<extended>

View File

@ -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

View File

@ -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()));
}
}

View File

@ -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) {

View File

@ -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

View File

@ -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']);
}

View File

@ -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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @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<extended>
* @group framework
*/
public function testInvalidExtensionPath() : void

View File

@ -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()));
}
/**

View File

@ -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']);

View File

@ -241,4 +241,21 @@ class HttpTest extends \PHPUnit\Framework\TestCase
$obj = new Http('https://www.google.com/test/path.php?para1=abc&para2=2#frag');
self::assertEquals('/test/path?para1=abc&para2=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());
}
}