From 5b2c9d499bfecd7cf12243b97afa605388a4c920 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 16 Apr 2023 01:55:36 +0200 Subject: [PATCH] fix demoSetup --- DataStorage/Database/BuilderAbstract.php | 17 ++ DataStorage/Database/GrammarAbstract.php | 108 +++++--- DataStorage/Database/Mapper/UpdateMapper.php | 90 +++---- DataStorage/Database/Mapper/WriteMapper.php | 138 +++++----- DataStorage/Database/Query/Builder.php | 24 +- .../Database/Query/Grammar/Grammar.php | 252 +++++++----------- DataStorage/Database/Schema/Builder.php | 55 +++- .../Database/Schema/Grammar/Grammar.php | 161 +++++------ .../Database/Schema/Grammar/MysqlGrammar.php | 70 ++++- Message/RequestAbstract.php | 7 +- Module/InstallerAbstract.php | 5 + Module/ModuleManager.php | 2 + tests/Account/AccountStatusTest.php | 4 + tests/Account/AccountTest.php | 2 +- tests/Account/AccountTypeTest.php | 4 + tests/Account/GroupStatusTest.php | 4 + tests/Account/NullAccountTest.php | 3 + tests/Account/NullGroupTest.php | 15 +- tests/Account/PermissionAbstractTest.php | 4 +- tests/Account/PermissionTypeTest.php | 4 + tests/Application/ApplicationInfoTest.php | 2 +- tests/Application/ApplicationManagerTest.php | 7 + tests/Application/InstallerAbstractTest.php | 3 +- tests/Application/StatusAbstractTest.php | 3 +- tests/Application/UninstallerAbstractTest.php | 3 +- tests/Asset/AssetTypeTest.php | 4 + tests/Auth/LoginReturnTypeTest.php | 4 + .../Business/Finance/FinanceFormulasTest.php | 2 +- .../Cache/Connection/RedisCacheTest.php | 2 +- tests/DataStorage/LockExceptionTest.php | 2 + tests/Dispatcher/DispatcherTest.php | 14 +- tests/Image/KernelTest.php | 8 +- tests/Image/SkewTest.php | 6 +- tests/Image/ThresholdingTest.php | 7 +- .../Localization/Defaults/CityMapperTest.php | 1 - .../Defaults/CountryMapperTest.php | 1 - .../Defaults/CurrencyMapperTest.php | 1 - .../Localization/Defaults/IbanMapperTest.php | 1 - .../Defaults/LanguageMapperTest.php | 1 - tests/Localization/ISO3166CharEnumTest.php | 13 +- tests/Localization/ISO3166NameEnumTest.php | 4 +- tests/Localization/ISO3166NumEnumTest.php | 13 +- tests/Localization/ISO3166TwoEnumTest.php | 13 +- tests/Localization/ISO4217CharEnumTest.php | 13 +- tests/Localization/ISO4217DecimalEnumTest.php | 2 + tests/Localization/ISO4217EnumTest.php | 4 +- tests/Localization/ISO4217NumEnumTest.php | 13 +- tests/Localization/ISO4217SubUnitEnumTest.php | 2 + tests/Localization/ISO4217SymbolEnumTest.php | 2 + tests/Localization/ISO639EnumTest.php | 4 +- tests/Localization/ISO639x1EnumTest.php | 13 +- tests/Localization/ISO639x2EnumTest.php | 13 +- tests/Localization/ISO8601EnumArrayTest.php | 12 + tests/Localization/L11nManagerTest.php | 3 +- tests/Localization/PhoneEnumTest.php | 2 + tests/Localization/TimeZoneEnumArrayTest.php | 4 +- tests/Log/LogLevelTest.php | 4 + tests/Module/InstallerAbstractTest.php | 3 +- tests/Module/ModuleAbstractTest.php | 7 +- tests/Module/ModuleManagerTest.php | 32 ++- tests/Module/NullModuleTest.php | 2 + tests/Module/StatusAbstractTest.php | 3 +- tests/Module/UninstallerAbstractTest.php | 3 +- tests/Router/RouteVerbTest.php | 5 +- tests/System/CharsetTypeTest.php | 4 + tests/System/MimeTypeTest.php | 6 +- tests/System/OperatingSystemTest.php | 2 + tests/System/SystemTypeTest.php | 4 + tests/Uri/ArgumentTest.php | 61 +---- tests/Uri/HttpUriTest.php | 5 +- tests/Uri/InvalidUriExceptionTest.php | 2 + tests/Uri/UriFactoryTest.php | 2 +- 72 files changed, 787 insertions(+), 529 deletions(-) diff --git a/DataStorage/Database/BuilderAbstract.php b/DataStorage/Database/BuilderAbstract.php index 250c6505b..f25d22209 100755 --- a/DataStorage/Database/BuilderAbstract.php +++ b/DataStorage/Database/BuilderAbstract.php @@ -27,6 +27,14 @@ use phpOMS\DataStorage\Database\Query\QueryType; */ abstract class BuilderAbstract { + /** + * Is read only. + * + * @var bool + * @since 1.0.0 + */ + protected bool $isReadOnly = false; + /** * Grammar. * @@ -105,4 +113,13 @@ abstract class BuilderAbstract * @since 1.0.0 */ abstract public function toSql() : string; + + /** + * Execute query. + * + * @return ?\PDOStatement + * + * @since 1.0.0 + */ + abstract public function execute() : ?\PDOStatement; } diff --git a/DataStorage/Database/GrammarAbstract.php b/DataStorage/Database/GrammarAbstract.php index 823599d38..3e2d050c3 100755 --- a/DataStorage/Database/GrammarAbstract.php +++ b/DataStorage/Database/GrammarAbstract.php @@ -14,6 +14,10 @@ declare(strict_types=1); namespace phpOMS\DataStorage\Database; +use phpOMS\Contract\SerializableInterface; +use phpOMS\DataStorage\Database\Query\Builder; +use phpOMS\DataStorage\Database\Query\Column; +use phpOMS\DataStorage\Database\Query\Parameter; use phpOMS\DataStorage\Database\Query\QueryType; /** @@ -135,6 +139,11 @@ abstract class GrammarAbstract return \substr($queryString, 0, -1) . ';'; } + public function compilePostQuerys(BuilderAbstract $query) : array + { + return []; + } + /** * Compile components. * @@ -146,37 +155,7 @@ abstract class GrammarAbstract * * @since 1.0.0 */ - protected function compileComponents(BuilderAbstract $query) : array - { - if ($query->getType() === QueryType::RAW) { - return [$query->raw]; - } - - $sql = []; - $components = $this->getComponents($query->getType()); - - /* Loop all possible query components and if they exist compile them. */ - foreach ($components as $component) { - if (isset($query->{$component}) && !empty($query->{$component})) { - $sql[$component] = $this->{'compile' . \ucfirst($component)}($query, $query->{$component}); - } - } - - return $sql; - } - - /** - * Get query components based on query type. - * - * @param int $type Query type - * - * @return array Array of components to build query - * - * @throws \InvalidArgumentException Throws this exception if the query type is undefined - * - * @since 1.0.0 - */ - abstract protected function getComponents(int $type) : array; + abstract protected function compileComponents(BuilderAbstract $query) : array; /** * Get date format. @@ -265,4 +244,71 @@ abstract class GrammarAbstract . $system . ($system !== '*' ? $identifierEnd : ''); } + + /** + * Compile value. + * + * @param BuilderAbstract $query Query builder + * @param mixed $value Value + * + * @return string returns a string representation of the value + * + * @throws \InvalidArgumentException throws this exception if the value to compile is not supported by this function + * + * @since 1.0.0 + */ + protected function compileValue(BuilderAbstract $query, mixed $value) : string + { + if (\is_string($value)) { + return $query->quote($value); + } elseif (\is_int($value)) { + return (string) $value; + } elseif (\is_array($value)) { + $value = \array_values($value); + $count = \count($value) - 1; + $values = '('; + + for ($i = 0; $i < $count; ++$i) { + $values .= $this->compileValue($query, $value[$i]) . ', '; + } + + return $values . $this->compileValue($query, $value[$count]) . ')'; + } elseif ($value instanceof \DateTime) { + return $query->quote($value->format($this->datetimeFormat)); + } elseif ($value === null) { + return 'NULL'; + } elseif (\is_bool($value)) { + return (string) ((int) $value); + } elseif (\is_float($value)) { + return \rtrim(\rtrim(\number_format($value, 5, '.', ''), '0'), '.'); + } elseif ($value instanceof Column) { + return '(' . \rtrim($this->compileColumnQuery($value), ';') . ')'; + } elseif ($value instanceof BuilderAbstract) { + return '(' . \rtrim($value->toSql(), ';') . ')'; + } elseif ($value instanceof \JsonSerializable) { + $encoded = \json_encode($value); + + return $encoded ? $encoded : 'NULL'; + } elseif ($value instanceof SerializableInterface) { + return $value->serialize(); + } elseif ($value instanceof Parameter) { + return $value->__toString(); + } else { + throw new \InvalidArgumentException(\gettype($value)); + } + } + + /** + * Compile column query. + * + * @param Column $column Where query + * + * @return string + * + * @since 1.0.0 + */ + protected function compileColumnQuery(Column $column) : string + { + return $column->toSql(); + } } diff --git a/DataStorage/Database/Mapper/UpdateMapper.php b/DataStorage/Database/Mapper/UpdateMapper.php index 378e15079..f11171bb8 100755 --- a/DataStorage/Database/Mapper/UpdateMapper.php +++ b/DataStorage/Database/Mapper/UpdateMapper.php @@ -104,59 +104,59 @@ final class UpdateMapper extends DataMapperAbstract */ private function updateModel(object $obj, mixed $objId, \ReflectionClass $refClass = null) : void { - // Model doesn't have anything to update - if (\count($this->mapper::COLUMNS) < 2) { - return; - } - - $query = new Builder($this->db); - $query->update($this->mapper::TABLE) - ->where($this->mapper::TABLE . '.' . $this->mapper::PRIMARYFIELD, '=', $objId); - - foreach ($this->mapper::COLUMNS as $column) { - $propertyName = \stripos($column['internal'], '/') !== false ? \explode('/', $column['internal'])[0] : $column['internal']; - if (isset($this->mapper::HAS_MANY[$propertyName]) - || $column['internal'] === $this->mapper::PRIMARYFIELD - || (($column['readonly'] ?? false) === true && !isset($this->with[$propertyName])) - || (($column['writeonly'] ?? false) === true && !isset($this->with[$propertyName])) - ) { - continue; + try { + // Model doesn't have anything to update + if (\count($this->mapper::COLUMNS) < 2) { + return; } - $refClass = $refClass ?? new \ReflectionClass($obj); - $property = $refClass->getProperty($propertyName); + $query = new Builder($this->db); + $query->update($this->mapper::TABLE) + ->where($this->mapper::TABLE . '.' . $this->mapper::PRIMARYFIELD, '=', $objId); - if (!($property->isPublic())) { - $property->setAccessible(true); - $tValue = $property->getValue($obj); - $property->setAccessible(false); - } else { - $tValue = $obj->{$propertyName}; - } - - if (isset($this->mapper::OWNS_ONE[$propertyName])) { - $id = \is_object($tValue) ? $this->updateOwnsOne($propertyName, $tValue) : $tValue; - $value = $this->parseValue($column['type'], $id); - - $query->set([$this->mapper::TABLE . '.' . $column['name'] => $value]); - } elseif (isset($this->mapper::BELONGS_TO[$propertyName])) { - $id = \is_object($tValue) ? $this->updateBelongsTo($propertyName, $tValue) : $tValue; - $value = $this->parseValue($column['type'], $id); - - $query->set([$this->mapper::TABLE . '.' . $column['name'] => $value]); - } elseif ($column['name'] !== $this->mapper::PRIMARYFIELD) { - if (\stripos($column['internal'], '/') !== false) { - $path = \substr($column['internal'], \stripos($column['internal'], '/') + 1); - $tValue = ArrayUtils::getArray($path, $tValue, '/'); + foreach ($this->mapper::COLUMNS as $column) { + $propertyName = \stripos($column['internal'], '/') !== false ? \explode('/', $column['internal'])[0] : $column['internal']; + if (isset($this->mapper::HAS_MANY[$propertyName]) + || $column['internal'] === $this->mapper::PRIMARYFIELD + || (($column['readonly'] ?? false) === true && !isset($this->with[$propertyName])) + || (($column['writeonly'] ?? false) === true && !isset($this->with[$propertyName])) + ) { + continue; } - $value = $this->parseValue($column['type'], $tValue); + $refClass = $refClass ?? new \ReflectionClass($obj); + $property = $refClass->getProperty($propertyName); - $query->set([$this->mapper::TABLE . '.' . $column['name'] => $value]); + if (!($property->isPublic())) { + $property->setAccessible(true); + $tValue = $property->getValue($obj); + $property->setAccessible(false); + } else { + $tValue = $obj->{$propertyName}; + } + + if (isset($this->mapper::OWNS_ONE[$propertyName])) { + $id = \is_object($tValue) ? $this->updateOwnsOne($propertyName, $tValue) : $tValue; + $value = $this->parseValue($column['type'], $id); + + $query->set([$this->mapper::TABLE . '.' . $column['name'] => $value]); + } elseif (isset($this->mapper::BELONGS_TO[$propertyName])) { + $id = \is_object($tValue) ? $this->updateBelongsTo($propertyName, $tValue) : $tValue; + $value = $this->parseValue($column['type'], $id); + + $query->set([$this->mapper::TABLE . '.' . $column['name'] => $value]); + } elseif ($column['name'] !== $this->mapper::PRIMARYFIELD) { + if (\stripos($column['internal'], '/') !== false) { + $path = \substr($column['internal'], \stripos($column['internal'], '/') + 1); + $tValue = ArrayUtils::getArray($path, $tValue, '/'); + } + + $value = $this->parseValue($column['type'], $tValue); + + $query->set([$this->mapper::TABLE . '.' . $column['name'] => $value]); + } } - } - try { $sth = $this->db->con->prepare($query->toSql()); if ($sth !== false) { $sth->execute(); diff --git a/DataStorage/Database/Mapper/WriteMapper.php b/DataStorage/Database/Mapper/WriteMapper.php index 1aad150fb..6fe1d11e8 100755 --- a/DataStorage/Database/Mapper/WriteMapper.php +++ b/DataStorage/Database/Mapper/WriteMapper.php @@ -106,62 +106,67 @@ final class WriteMapper extends DataMapperAbstract */ private function createModel(object $obj, \ReflectionClass $refClass) : mixed { - $query = new Builder($this->db); - $query->into($this->mapper::TABLE); + try { + $query = new Builder($this->db); + $query->into($this->mapper::TABLE); - $publicProperties = \get_object_vars($obj); + $publicProperties = \get_object_vars($obj); - foreach ($this->mapper::COLUMNS as $column) { - $propertyName = \stripos($column['internal'], '/') !== false - ? \explode('/', $column['internal'])[0] - : $column['internal']; + foreach ($this->mapper::COLUMNS as $column) { + $propertyName = \stripos($column['internal'], '/') !== false + ? \explode('/', $column['internal'])[0] + : $column['internal']; - if (isset($this->mapper::HAS_MANY[$propertyName]) - || ($column['name'] === $this->mapper::PRIMARYFIELD && $this->mapper::AUTOINCREMENT) - ) { - continue; - } - - if (!isset($publicProperties[$propertyName])) { - $property = $refClass->getProperty($propertyName); - $property->setAccessible(true); - $tValue = $property->getValue($obj); - $property->setAccessible(false); - } else { - $tValue = $publicProperties[$propertyName]; - } - - if (isset($this->mapper::OWNS_ONE[$propertyName])) { - $id = \is_object($tValue) ? $this->createOwnsOne($propertyName, $tValue) : $tValue; - $value = $this->parseValue($column['type'], $id); - - $query->insert($column['name'])->value($value); - } elseif (isset($this->mapper::BELONGS_TO[$propertyName])) { - $id = \is_object($tValue) ? $this->createBelongsTo($propertyName, $tValue) : $tValue; - $value = $this->parseValue($column['type'], $id); - - $query->insert($column['name'])->value($value); - } else { - if (\stripos($column['internal'], '/') !== false) { - /** @var array $tValue */ - $path = \substr($column['internal'], \stripos($column['internal'], '/') + 1); - $tValue = ArrayUtils::getArray($path, $tValue, '/'); + if (isset($this->mapper::HAS_MANY[$propertyName]) + || ($column['name'] === $this->mapper::PRIMARYFIELD && $this->mapper::AUTOINCREMENT) + ) { + continue; } - $value = $this->parseValue($column['type'], $tValue); + if (!isset($publicProperties[$propertyName])) { + $property = $refClass->getProperty($propertyName); + $property->setAccessible(true); + $tValue = $property->getValue($obj); + $property->setAccessible(false); + } else { + $tValue = $publicProperties[$propertyName]; + } - $query->insert($column['name'])->value($value); + if (isset($this->mapper::OWNS_ONE[$propertyName])) { + $id = \is_object($tValue) ? $this->createOwnsOne($propertyName, $tValue) : $tValue; + $value = $this->parseValue($column['type'], $id); + + $query->insert($column['name'])->value($value); + } elseif (isset($this->mapper::BELONGS_TO[$propertyName])) { + $id = \is_object($tValue) ? $this->createBelongsTo($propertyName, $tValue) : $tValue; + $value = $this->parseValue($column['type'], $id); + + $query->insert($column['name'])->value($value); + } else { + if (\stripos($column['internal'], '/') !== false) { + /** @var array $tValue */ + $path = \substr($column['internal'], \stripos($column['internal'], '/') + 1); + $tValue = ArrayUtils::getArray($path, $tValue, '/'); + } + + $value = $this->parseValue($column['type'], $tValue); + + $query->insert($column['name'])->value($value); + } } - } - // if a table only has a single column = primary key column. This must be done otherwise the query is empty - if ($query->getType() === QueryType::NONE) { - $query->insert($this->mapper::PRIMARYFIELD)->value(0); - } + // if a table only has a single column = primary key column. This must be done otherwise the query is empty + if ($query->getType() === QueryType::NONE) { + $query->insert($this->mapper::PRIMARYFIELD)->value(0); + } - try { $sth = $this->db->con->prepare($a = $query->toSql()); $sth->execute(); + + $objId = empty($id = $this->mapper::getObjectId($obj, $refClass)) ? $this->db->con->lastInsertId() : $id; + \settype($objId, $this->mapper::COLUMNS[$this->mapper::PRIMARYFIELD]['type']); + + return $objId; } catch (\Throwable $t) { // @codeCoverageIgnoreStart \var_dump($t->getMessage()); @@ -171,11 +176,6 @@ final class WriteMapper extends DataMapperAbstract return -1; // @codeCoverageIgnoreEND } - - $objId = empty($id = $this->mapper::getObjectId($obj, $refClass)) ? $this->db->con->lastInsertId() : $id; - \settype($objId, $this->mapper::COLUMNS[$this->mapper::PRIMARYFIELD]['type']); - - return $objId; } /** @@ -384,28 +384,28 @@ final class WriteMapper extends DataMapperAbstract */ public function createRelationTable(string $propertyName, array $objsIds, mixed $objId) : void { - if (empty($objsIds) || !isset($this->mapper::HAS_MANY[$propertyName]['external'])) { - return; - } - - $relQuery = new Builder($this->db); - $relQuery->into($this->mapper::HAS_MANY[$propertyName]['table']) - ->insert($this->mapper::HAS_MANY[$propertyName]['external'], $this->mapper::HAS_MANY[$propertyName]['self']); - - foreach ($objsIds as $src) { - if (\is_object($src)) { - $mapper = (\stripos($mapper = \get_class($src), '\Null') !== false - ? \str_replace('\Null', '\\', $mapper) - : $mapper) - . 'Mapper'; - - $src = $mapper::getObjectId($src); + try { + if (empty($objsIds) || !isset($this->mapper::HAS_MANY[$propertyName]['external'])) { + return; } - $relQuery->values($src, $objId); - } + $relQuery = new Builder($this->db); + $relQuery->into($this->mapper::HAS_MANY[$propertyName]['table']) + ->insert($this->mapper::HAS_MANY[$propertyName]['external'], $this->mapper::HAS_MANY[$propertyName]['self']); + + foreach ($objsIds as $src) { + if (\is_object($src)) { + $mapper = (\stripos($mapper = \get_class($src), '\Null') !== false + ? \str_replace('\Null', '\\', $mapper) + : $mapper) + . 'Mapper'; + + $src = $mapper::getObjectId($src); + } + + $relQuery->values($src, $objId); + } - try { $sth = $this->db->con->prepare($relQuery->toSql()); if ($sth !== false) { $sth->execute(); diff --git a/DataStorage/Database/Query/Builder.php b/DataStorage/Database/Query/Builder.php index 7fcc94fe6..ffddecb98 100755 --- a/DataStorage/Database/Query/Builder.php +++ b/DataStorage/Database/Query/Builder.php @@ -37,14 +37,6 @@ class Builder extends BuilderAbstract */ public static bool $log = false; - /** - * Is read only. - * - * @var bool - * @since 1.0.0 - */ - protected bool $isReadOnly = false; - /** * Columns. * @@ -354,11 +346,7 @@ class Builder extends BuilderAbstract } /** - * Parsing to sql string. - * - * @return string - * - * @since 1.0.0 + * {@inheritdoc} */ public function toSql() : string { @@ -386,7 +374,7 @@ class Builder extends BuilderAbstract { // create dependencies $dependencies = []; - foreach ($this->joins as $table => $join) { + foreach ($this->joins as $table => $_) { $dependencies[$table] = []; foreach ($this->ons[$table] as $on) { @@ -1384,18 +1372,14 @@ class Builder extends BuilderAbstract } /** - * Execute query. - * - * @return ?\PDOStatement - * - * @since 1.0.0 + * {@inheritdoc} */ public function execute() : ?\PDOStatement { $sth = null; try { - $sth = $this->connection->con->prepare($a = $this->toSql()); + $sth = $this->connection->con->prepare($this->toSql()); if ($sth === false) { return null; } diff --git a/DataStorage/Database/Query/Grammar/Grammar.php b/DataStorage/Database/Query/Grammar/Grammar.php index c1b4ddd82..618ef355a 100755 --- a/DataStorage/Database/Query/Grammar/Grammar.php +++ b/DataStorage/Database/Query/Grammar/Grammar.php @@ -14,12 +14,10 @@ declare(strict_types=1); namespace phpOMS\DataStorage\Database\Query\Grammar; -use phpOMS\Contract\SerializableInterface; +use phpOMS\DataStorage\Database\BuilderAbstract; use phpOMS\DataStorage\Database\GrammarAbstract; use phpOMS\DataStorage\Database\Query\Builder; -use phpOMS\DataStorage\Database\Query\Column; use phpOMS\DataStorage\Database\Query\From; -use phpOMS\DataStorage\Database\Query\Parameter; use phpOMS\DataStorage\Database\Query\QueryType; use phpOMS\DataStorage\Database\Query\Where; @@ -37,94 +35,113 @@ use phpOMS\DataStorage\Database\Query\Where; */ class Grammar extends GrammarAbstract { - /** - * Select components. - * - * @var string[] - * @since 1.0.0 - */ - protected array $selectComponents = [ - 'aggregate', - 'selects', - 'from', - 'joins', - 'wheres', - 'havings', - 'groups', - 'orders', - 'limit', - 'offset', - 'unions', - 'lock', - ]; - - /** - * Insert components. - * - * @var string[] - * @since 1.0.0 - */ - protected array $insertComponents = [ - 'into', - 'inserts', - 'values', - ]; - - /** - * Update components. - * - * @var string[] - * @since 1.0.0 - */ - protected array $updateComponents = [ - 'updates', - 'sets', - 'wheres', - ]; - - /** - * Update components. - * - * @var string[] - * @since 1.0.0 - */ - protected array $deleteComponents = [ - 'deletes', - 'from', - 'wheres', - ]; - - /** - * Random components. - * - * @var string[] - * @since 1.0.0 - */ - protected array $randomComponents = [ - 'random', - ]; - - /** + /** * {@inheritdoc} */ - protected function getComponents(int $type) : array + protected function compileComponents(BuilderAbstract $query) : array { - switch ($type) { + /** @var Builder $query */ + + $sql = []; + switch ($query->getType()) { case QueryType::SELECT: - return $this->selectComponents; + // $sql[] = $this->compileAggregate($query, $query->aggregate); + if (!empty($query->selects)) { + $sql[] = $this->compileSelects($query, $query->selects); + } + + if (!empty($query->from)) { + $sql[] = $this->compileFrom($query, $query->from); + } + + if (!empty($query->joins)) { + $sql[] = $this->compileJoins($query, $query->joins); + } + + if (!empty($query->wheres)) { + $sql[] = $this->compileWheres($query, $query->wheres); + } + + // $sql[] = $this->compileHavings($query, $query->havings); + + if (!empty($query->groups)) { + $sql[] = $this->compileGroups($query, $query->groups); + } + + if (!empty($query->orders)) { + $sql[] = $this->compileOrders($query, $query->orders); + } + + if (!empty($query->limit)) { + $sql[] = $this->compileLimit($query, $query->limit); + } + + if (!empty($query->offset)) { + $sql[] = $this->compileOffset($query, $query->offset); + } + + if (!empty($query->unions)) { + $sql[] = $this->compileUnions($query, $query->unions); + } + + if (!empty($query->lock)) { + $sql[] = $this->compileLock($query, $query->lock); + } + + break; case QueryType::INSERT: - return $this->insertComponents; + if (!empty($query->into)) { + $sql[] = $this->compileInto($query, $query->into); + } + + if (!empty($query->inserts)) { + $sql[] = $this->compileInserts($query, $query->inserts); + } + + if (!empty($query->values)) { + $sql[] = $this->compileValues($query, $query->values); + } + + break; case QueryType::UPDATE: - return $this->updateComponents; + if (!empty($query->updates)) { + $sql[] = $this->compileUpdates($query, $query->updates); + } + + if (!empty($query->sets)) { + $sql[] = $this->compileSets($query, $query->sets); + } + + if (!empty($query->wheres)) { + $sql[] = $this->compileWheres($query, $query->wheres); + } + + break; case QueryType::DELETE: - return $this->deleteComponents; + if (!empty($query->deletes)) { + $sql[] = $this->compileDeletes($query, $query->deletes); + } + + if (!empty($query->from)) { + $sql[] = $this->compileFrom($query, $query->from); + } + + if (!empty($query->wheres)) { + $sql[] = $this->compileWheres($query, $query->wheres); + } + + break; case QueryType::RANDOM: - return $this->randomComponents; + $sql[] = $this->compileRandom($query, $query->random); + + break; case queryType::NONE: return []; default: throw new \InvalidArgumentException('Unknown query type.'); } + + return $sql; } /** @@ -148,6 +165,11 @@ class Grammar extends GrammarAbstract return ($query->distinct ? 'SELECT DISTINCT ' : 'SELECT ') . $expression; } + protected function compileRandom(Builder $query, array $columns) : string + { + return ''; + } + /** * Compile select. * @@ -285,7 +307,7 @@ class Grammar extends GrammarAbstract */ protected function compileWhereQuery(Where $where) : string { - return $where->toSql(); + return $where->toSql()[0]; } /** @@ -299,74 +321,7 @@ class Grammar extends GrammarAbstract */ protected function compileFromQuery(From $from) : string { - return $from->toSql(); - } - - /** - * Compile column query. - * - * @param Column $column Where query - * - * @return string - * - * @since 1.0.0 - */ - protected function compileColumnQuery(Column $column) : string - { - return $column->toSql(); - } - - /** - * Compile value. - * - * @param Builder $query Query builder - * @param mixed $value Value - * - * @return string returns a string representation of the value - * - * @throws \InvalidArgumentException throws this exception if the value to compile is not supported by this function - * - * @since 1.0.0 - */ - protected function compileValue(Builder $query, mixed $value) : string - { - if (\is_string($value)) { - return $query->quote($value); - } elseif (\is_int($value)) { - return (string) $value; - } elseif (\is_array($value)) { - $value = \array_values($value); - $count = \count($value) - 1; - $values = '('; - - for ($i = 0; $i < $count; ++$i) { - $values .= $this->compileValue($query, $value[$i]) . ', '; - } - - return $values . $this->compileValue($query, $value[$count]) . ')'; - } elseif ($value instanceof \DateTime) { - return $query->quote($value->format($this->datetimeFormat)); - } elseif ($value === null) { - return 'NULL'; - } elseif (\is_bool($value)) { - return (string) ((int) $value); - } elseif (\is_float($value)) { - return \rtrim(\rtrim(\number_format($value, 5, '.', ''), '0'), '.'); - } elseif ($value instanceof Column) { - return '(' . \rtrim($this->compileColumnQuery($value), ';') . ')'; - } elseif ($value instanceof Builder) { - return '(' . \rtrim($value->toSql(), ';') . ')'; - } elseif ($value instanceof \JsonSerializable) { - $encoded = \json_encode($value); - - return $encoded ? $encoded : 'NULL'; - } elseif ($value instanceof SerializableInterface) { - return $value->serialize(); - } elseif ($value instanceof Parameter) { - return $value->__toString(); - } else { - throw new \InvalidArgumentException(\gettype($value)); - } + return $from->toSql()[0]; } /** @@ -538,8 +493,7 @@ class Grammar extends GrammarAbstract */ protected function compileOrders(Builder $query, array $orders) : string { - $expression = ''; - $lastOrderType = ''; + $expression = ''; foreach ($orders as $column => $order) { $expression .= $this->compileSystem($column) . ' ' . $order . ', '; diff --git a/DataStorage/Database/Schema/Builder.php b/DataStorage/Database/Schema/Builder.php index 87be0303c..b4c1c9a81 100755 --- a/DataStorage/Database/Schema/Builder.php +++ b/DataStorage/Database/Schema/Builder.php @@ -14,8 +14,8 @@ declare(strict_types=1); namespace phpOMS\DataStorage\Database\Schema; +use phpOMS\DataStorage\Database\BuilderAbstract; use phpOMS\DataStorage\Database\Connection\ConnectionAbstract; -use phpOMS\DataStorage\Database\Query\Builder as QueryBuilder; /** * Database query builder. @@ -24,8 +24,10 @@ use phpOMS\DataStorage\Database\Query\Builder as QueryBuilder; * @license OMS License 2.0 * @link https://jingga.app * @since 1.0.0 + * + * @property \phpOMS\DataStorage\Database\Schema\Grammar $grammar Grammar. */ -class Builder extends QueryBuilder +class Builder extends BuilderAbstract { /** * Table to create. @@ -109,6 +111,8 @@ class Builder extends QueryBuilder */ public array $alterAdd = []; + public bool $hasPostQuery = false; + /** * Constructor. * @@ -157,7 +161,8 @@ class Builder extends QueryBuilder $builder->field( $name, $def['type'], $def['default'] ?? null, $def['null'] ?? true, $def['primary'] ?? false, $def['unique'] ?? false, $def['autoincrement'] ?? false, - $def['foreignTable'] ?? null, $def['foreignKey'] ?? null + $def['foreignTable'] ?? null, $def['foreignKey'] ?? null, + $def ); } @@ -258,6 +263,7 @@ class Builder extends QueryBuilder * @param bool $autoincrement Autoincrements * @param string $foreignTable Foreign table (in case of foreign key) * @param string $foreignKey Foreign key + * @param array $meta Meta data * * @return self * @@ -266,7 +272,7 @@ class Builder extends QueryBuilder public function field( string $name, string $type, $default = null, bool $isNullable = true, bool $isPrimary = false, bool $isUnique = false, bool $autoincrement = false, - string $foreignTable = null, string $foreignKey = null + string $foreignTable = null, string $foreignKey = null, array $meta = [] ) : self { $this->createFields[$name] = [ 'name' => $name, @@ -278,6 +284,7 @@ class Builder extends QueryBuilder 'autoincrement' => $autoincrement, 'foreignTable' => $foreignTable, 'foreignKey' => $foreignKey, + 'meta' => $meta, ]; return $this; @@ -323,11 +330,41 @@ class Builder extends QueryBuilder } /** - * Parsing to string. - * - * @return string - * - * @since 1.0.0 + * {@inheritdoc} + */ + public function execute() : ?\PDOStatement + { + $sth = null; + + try { + $sth = $this->connection->con->prepare($this->toSql()); + if ($sth === false) { + return null; + } + + $sth->execute(); + + if ($this->hasPostQuery) { + $sqls = $this->grammar->compilePostQueries($this); + + foreach ($sqls as $sql) { + $this->connection->con->exec($sql); + } + } + } catch (\Throwable $t) { + // @codeCoverageIgnoreStart + \var_dump($t->getMessage()); + \var_dump($this->toSql()); + + $sth = null; + // @codeCoverageIgnoreEnd + } + + return $sth; + } + + /** + * {@inheritdoc} */ public function toSql() : string { diff --git a/DataStorage/Database/Schema/Grammar/Grammar.php b/DataStorage/Database/Schema/Grammar/Grammar.php index d89ed1b0b..e8af34ab1 100755 --- a/DataStorage/Database/Schema/Grammar/Grammar.php +++ b/DataStorage/Database/Schema/Grammar/Grammar.php @@ -15,7 +15,8 @@ declare(strict_types=1); namespace phpOMS\DataStorage\Database\Schema\Grammar; use phpOMS\DataStorage\Database\BuilderAbstract; -use phpOMS\DataStorage\Database\Query\Grammar\Grammar as QueryGrammar; +use phpOMS\DataStorage\Database\GrammarAbstract; +use phpOMS\DataStorage\Database\Schema\Builder as SchemaBuilder; use phpOMS\DataStorage\Database\Schema\QueryType; /** @@ -26,95 +27,101 @@ use phpOMS\DataStorage\Database\Schema\QueryType; * @link https://jingga.app * @since 1.0.0 */ -class Grammar extends QueryGrammar +class Grammar extends GrammarAbstract { - /** - * Drop components. - * - * @var string[] - * @since 1.0.0 - */ - protected array $dropDatabaseComponents = [ - 'dropDatabase', - ]; - - /** - * Drop components. - * - * @var string[] - * @since 1.0.0 - */ - protected array $dropTableComponents = [ - 'dropTable', - ]; - - /** - * Select tables components. - * - * @var string[] - * @since 1.0.0 - */ - protected array $createTablesComponents = [ - 'createTable', - 'createFields', - 'createTableSettings', - ]; - - /** - * Select tables components. - * - * @var string[] - * @since 1.0.0 - */ - protected array $tablesComponents = [ - 'selectTables', - ]; - - /** - * Select field components. - * - * @var string[] - * @since 1.0.0 - */ - protected array $fieldsComponents = [ - 'selectFields', - ]; - - /** - * Alter components. - * - * @var string[] - * @since 1.0.0 - */ - protected array $alterComponents = [ - 'alterTable', - 'alterColumn', - 'alterAdd', - 'alterRename', - 'alterRemove', - ]; - /** * {@inheritdoc} */ - protected function getComponents(int $type) : array + protected function compileComponents(BuilderAbstract $query) : array { - switch ($type) { + /** @var SchemaBuilder $query */ + + $sql = []; + switch ($query->getType()) { case QueryType::DROP_DATABASE: - return $this->dropDatabaseComponents; + if (empty($query->dropDatabase)) { + break; + } + + $sql[] = $this->compileDropDatabase($query, $query->dropDatabase); + + break; case QueryType::TABLES: - return $this->tablesComponents; + if (empty($query->selectTables)) { + break; + } + + $sql[] = $this->compileSelectTables($query, $query->selectTables); + + break; case QueryType::FIELDS: - return $this->fieldsComponents; + if (empty($query->selectFields)) { + break; + } + + $sql[] = $this->compileSelectFields($query, $query->selectFields); + + break; case QueryType::CREATE_TABLE: - return $this->createTablesComponents; + if (empty($query->createTable)) { + break; + } + + $sql[] = $this->compileCreateTable($query, $query->createTable); + $sql[] = $this->compileCreateFields($query, $query->createFields); + + if (empty($query->createTableSettings)) { + break; + } + + $sql[] = $this->compileCreateTableSettings($query, $query->createTableSettings); + + break; case QueryType::DROP_TABLE: - return $this->dropTableComponents; + if (empty($query->dropTable)) { + break; + } + + $sql[] = $this->compileDropTable($query, $query->dropTable); + + break; case QueryType::ALTER: - return $this->alterComponents; + $sql[] = $this->compileAlterTable($query, $query->alterTable); + $sql[] = $this->compileAlterColumn($query, $query->alterColumn); + $sql[] = $this->compileAlterAdd($query, $query->alterAdd); + // $sql[] = $this->compileAlterRename($query, $query->alterRename); + // $sql[] = $this->compileAlterRemove($query, $query->alterRemove); + + break; + case QueryType::RAW: + $sql[] = $query->raw; + + break; default: - return parent::getComponents($type); + return []; } + + return $sql; + } + + protected function compileSelectTables(SchemaBuilder $query, array $tables) : string + { + return ''; + } + + protected function compileSelectFields(SchemaBuilder $query, string $table) : string + { + return ''; + } + + protected function compileCreateFields(SchemaBuilder $query, array $fields) : string + { + return ''; + } + + public function compilePostQueries(BuilderAbstract $query): array + { + return []; } /** diff --git a/DataStorage/Database/Schema/Grammar/MysqlGrammar.php b/DataStorage/Database/Schema/Grammar/MysqlGrammar.php index df155a8c1..523ed84d1 100755 --- a/DataStorage/Database/Schema/Grammar/MysqlGrammar.php +++ b/DataStorage/Database/Schema/Grammar/MysqlGrammar.php @@ -16,6 +16,8 @@ namespace phpOMS\DataStorage\Database\Schema\Grammar; use phpOMS\DataStorage\Database\BuilderAbstract; use phpOMS\DataStorage\Database\Query\Builder; +use phpOMS\DataStorage\Database\Schema\Builder as SchemaBuilder; +use phpOMS\DataStorage\Database\Schema\QueryType; /** * Database query grammar. @@ -43,6 +45,44 @@ class MysqlGrammar extends Grammar */ public string $systemIdentifierEnd = '`'; + /** + * {@inheritdoc} + */ + public function compilePostQueries(BuilderAbstract $query): array + { + /** @var SchemaBuilder $query */ + + $sql = []; + switch ($query->getType()) { + case QueryType::CREATE_TABLE: + foreach ($query->createFields as $name => $field) { + if (isset($field['meta']['multi_autoincrement'])) { + $tmpSql = 'CREATE TRIGGER update_' . $name + . ' BEFORE INSERT ON ' . $query->createTable + . ' FOR EACH ROW BEGIN' + . ' SET NEW.' . $name . ' = (' + . 'SELECT COALESCE(MAX(' . $name . '), 0) + 1' + . ' FROM ' . $query->createTable + . ' WHERE'; + + foreach ($field['meta']['multi_autoincrement'] as $index => $autoincrement) { + $tmpSql .= ($index > 0 ? ' AND' : '' ) . ' ' . $autoincrement . ' = NEW.' . $autoincrement; + } + + $tmpSql .= ' LIMIT 1); END;'; + + $sql[] = $tmpSql; + } + } + + break; + default: + return []; + } + + return $sql; + } + /** * Compile remove * @@ -63,14 +103,14 @@ class MysqlGrammar extends Grammar /** * Compile from. * - * @param Builder $query Builder + * @param SchemaBuilder $query Builder * @param array $table Tables * * @return string * * @since 1.0.0 */ - protected function compileSelectTables(Builder $query, array $table) : string + protected function compileSelectTables(SchemaBuilder $query, array $table) : string { $builder = new Builder($query->getConnection()); $builder->select('table_name') @@ -83,14 +123,14 @@ class MysqlGrammar extends Grammar /** * Compile from. * - * @param Builder $query Builder + * @param SchemaBuilder $query Builder * @param string $table Tables * * @return string * * @since 1.0.0 */ - protected function compileSelectFields(Builder $query, string $table) : string + protected function compileSelectFields(SchemaBuilder $query, string $table) : string { $builder = new Builder($query->getConnection()); $builder->select('*') @@ -104,14 +144,14 @@ class MysqlGrammar extends Grammar /** * Compile create table fields query. * - * @param Builder $query Query + * @param SchemaBuilder $query Query * @param array $fields Fields to create * * @return string * * @since 1.0.0 */ - protected function compileCreateFields(Builder $query, array $fields) : string + protected function compileCreateFields(SchemaBuilder $query, array $fields) : string { $fieldQuery = ''; $keys = ''; @@ -119,35 +159,37 @@ class MysqlGrammar extends Grammar foreach ($fields as $name => $field) { $fieldQuery .= ' ' . $this->expressionizeTableColumn([$name]) . ' ' . $field['type']; - if (isset($field['default']) || ($field['default'] === null && isset($field['null']) && $field['null'])) { + if (isset($field['default']) || ($field['default'] === null && ($field['null'] ?? false))) { $fieldQuery .= ' DEFAULT ' . $this->compileValue($query, $field['default']); } - if (isset($field['null'])) { + if ($field['null'] ?? false) { $fieldQuery .= ' ' . ($field['null'] ? '' : 'NOT ') . 'NULL'; } - if (isset($field['autoincrement']) && $field['autoincrement']) { + if ($field['autoincrement'] ?? false) { $fieldQuery .= ' AUTO_INCREMENT'; } $fieldQuery .= ','; - if (isset($field['primary']) && $field['primary']) { + if ($field['primary'] ?? false) { $keys .= ' PRIMARY KEY (' . $this->expressionizeTableColumn([$name]) . '),'; } - if (isset($field['unique']) && $field['unique']) { + if ($field['unique'] ?? false) { $keys .= ' UNIQUE KEY (' . $this->expressionizeTableColumn([$name]) . '),'; } - if (isset($field['foreignTable'], $field['foreignKey']) - && !empty($field['foreignTable']) && !empty($field['foreignKey']) - ) { + if (isset($field['foreignTable'], $field['foreignKey'])) { $keys .= ' FOREIGN KEY (' . $this->expressionizeTableColumn([$name]) . ') REFERENCES ' . $this->expressionizeTableColumn([$field['foreignTable']]) . ' (' . $this->expressionizeTableColumn([$field['foreignKey']]) . '),'; } + + if (isset($field['meta']['multi_autoincrement'])) { + $query->hasPostQuery = true; + } } return '(' . \ltrim(\rtrim($fieldQuery . $keys, ','), ' ') . ')'; diff --git a/Message/RequestAbstract.php b/Message/RequestAbstract.php index 97973ac6f..6645d2627 100755 --- a/Message/RequestAbstract.php +++ b/Message/RequestAbstract.php @@ -286,6 +286,8 @@ abstract class RequestAbstract implements MessageInterface /** * Check if has data. * + * The following empty values are considered as not set (null, '', 0) + * * @param string $key Data key * * @return bool @@ -296,7 +298,10 @@ abstract class RequestAbstract implements MessageInterface { $key = \mb_strtolower($key); - return isset($this->data[$key]) && !empty($this->data[$key]); + return isset($this->data[$key]) + && $this->data[$key] !== '' + && $this->data[$key] !== 0 + && $this->data[$key] !== null; } /** diff --git a/Module/InstallerAbstract.php b/Module/InstallerAbstract.php index 6ce3b4b30..fe7716375 100755 --- a/Module/InstallerAbstract.php +++ b/Module/InstallerAbstract.php @@ -80,6 +80,11 @@ abstract class InstallerAbstract /** @var array[] $definitions */ $definitions = \json_decode($content, true); + + if (!\is_array($definitions)) { + return; // @codeCoverageIgnore + } + foreach ($definitions as $definition) { SchemaBuilder::createFromSchema($definition, $dbPool->get('schema'))->execute(); } diff --git a/Module/ModuleManager.php b/Module/ModuleManager.php index 71d64520e..ca0e28bdc 100755 --- a/Module/ModuleManager.php +++ b/Module/ModuleManager.php @@ -293,10 +293,12 @@ final class ModuleManager * * @since 1.0.0 */ + /* public function getAvailableModules() : array { return []; } + * /** * Get all installed modules. diff --git a/tests/Account/AccountStatusTest.php b/tests/Account/AccountStatusTest.php index f39ff58e8..8085f73fe 100755 --- a/tests/Account/AccountStatusTest.php +++ b/tests/Account/AccountStatusTest.php @@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php'; use phpOMS\Account\AccountStatus; /** + * @testdox phpOMS\tests\Account\AccountStatus: Account status * @internal */ final class AccountStatusTest extends \PHPUnit\Framework\TestCase { /** + * @testdoxThe account status enum has the correct number of status codes * @group framework * @coversNothing */ @@ -33,6 +35,7 @@ final class AccountStatusTest extends \PHPUnit\Framework\TestCase } /** + * @testdox The account status enum has only unique values * @group framework * @coversNothing */ @@ -42,6 +45,7 @@ final class AccountStatusTest extends \PHPUnit\Framework\TestCase } /** + * @testdox The account status enum has the correct values * @group framework * @coversNothing */ diff --git a/tests/Account/AccountTest.php b/tests/Account/AccountTest.php index 10f12a21a..1d950f626 100755 --- a/tests/Account/AccountTest.php +++ b/tests/Account/AccountTest.php @@ -245,7 +245,7 @@ final class AccountTest extends \PHPUnit\Framework\TestCase $account->addPermission(new class() extends PermissionAbstract {}); self::assertCount(1, $account->getPermissions()); - self::assertFalse($account->hasPermission(PermissionType::READ, 1, 'a', 'a', 1, 1, 1)); + self::assertFalse($account->hasPermission(PermissionType::READ, 1, 2, 'a', 1, 1, 1)); self::assertTrue($account->hasPermission(PermissionType::NONE)); } diff --git a/tests/Account/AccountTypeTest.php b/tests/Account/AccountTypeTest.php index 1f098b21c..5c0053607 100755 --- a/tests/Account/AccountTypeTest.php +++ b/tests/Account/AccountTypeTest.php @@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php'; use phpOMS\Account\AccountType; /** + * @testdox phpOMS\tests\Account\AccountType: Account type * @internal */ final class AccountTypeTest extends \PHPUnit\Framework\TestCase { /** + * @testdox The account type enum has the correct number of type codes * @group framework * @coversNothing */ @@ -33,6 +35,7 @@ final class AccountTypeTest extends \PHPUnit\Framework\TestCase } /** + * @testdox The account type enum has only unique values * @group framework * @coversNothing */ @@ -42,6 +45,7 @@ final class AccountTypeTest extends \PHPUnit\Framework\TestCase } /** + * @testdox The account type enum has the correct values * @group framework * @coversNothing */ diff --git a/tests/Account/GroupStatusTest.php b/tests/Account/GroupStatusTest.php index b3639ab60..9e9418845 100755 --- a/tests/Account/GroupStatusTest.php +++ b/tests/Account/GroupStatusTest.php @@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php'; use phpOMS\Account\GroupStatus; /** + * @testdox phpOMS\tests\Account\GroupStatus: Group status * @internal */ final class GroupStatusTest extends \PHPUnit\Framework\TestCase { /** + * @testdox The group status enum has the correct number of status codes * @group framework * @coversNothing */ @@ -33,6 +35,7 @@ final class GroupStatusTest extends \PHPUnit\Framework\TestCase } /** + * @testdox The group status enum has only unique values * @group framework * @coversNothing */ @@ -42,6 +45,7 @@ final class GroupStatusTest extends \PHPUnit\Framework\TestCase } /** + * @testdox The group status enum has the correct values * @group framework * @coversNothing */ diff --git a/tests/Account/NullAccountTest.php b/tests/Account/NullAccountTest.php index ae6dc514c..3746adc71 100755 --- a/tests/Account/NullAccountTest.php +++ b/tests/Account/NullAccountTest.php @@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php'; use phpOMS\Account\NullAccount; /** + * @testdox phpOMS\tests\Account\NullAccount: Null account * @internal */ final class NullAccountTest extends \PHPUnit\Framework\TestCase { /** + * @testdox The null account is an instance of the account class * @covers phpOMS\Account\NullAccount * @group framework */ @@ -33,6 +35,7 @@ final class NullAccountTest extends \PHPUnit\Framework\TestCase } /** + * @testdox The null account can get initialized with an id * @covers phpOMS\Account\NullAccount * @group framework */ diff --git a/tests/Account/NullGroupTest.php b/tests/Account/NullGroupTest.php index 4aa74afdb..c1b9ea38a 100755 --- a/tests/Account/NullGroupTest.php +++ b/tests/Account/NullGroupTest.php @@ -19,16 +19,29 @@ require_once __DIR__ . '/../Autoloader.php'; use phpOMS\Account\NullGroup; /** + * @testdox phpOMS\tests\Account\NullGroup: Null group * @internal */ final class NullGroupTest extends \PHPUnit\Framework\TestCase { /** + * @testdox The null group is an instance of the group class * @covers phpOMS\Account\NullGroup - * @group module + * @group framework */ public function testNull() : void { self::assertInstanceOf('\phpOMS\Account\Group', new NullGroup()); } + + /** + * @testdox The null group can get initialized with an id + * @covers phpOMS\Account\NullGroup + * @group framework + */ + public function testId() : void + { + $null = new NullGroup(2); + self::assertEquals(2, $null->getId()); + } } diff --git a/tests/Account/PermissionAbstractTest.php b/tests/Account/PermissionAbstractTest.php index 38b997799..bd35914b1 100755 --- a/tests/Account/PermissionAbstractTest.php +++ b/tests/Account/PermissionAbstractTest.php @@ -86,8 +86,8 @@ final class PermissionAbstractTest extends \PHPUnit\Framework\TestCase { $perm = new class() extends PermissionAbstract {}; - $perm->setApp('Test'); - self::assertEquals('Test', $perm->getApp()); + $perm->setApp(2); + self::assertEquals(2, $perm->getApp()); } /** diff --git a/tests/Account/PermissionTypeTest.php b/tests/Account/PermissionTypeTest.php index 3c1ef22b6..4e8559497 100755 --- a/tests/Account/PermissionTypeTest.php +++ b/tests/Account/PermissionTypeTest.php @@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php'; use phpOMS\Account\PermissionType; /** + * @testdox phpOMS\tests\Account\PermissionType: Permission type * @internal */ final class PermissionTypeTest extends \PHPUnit\Framework\TestCase { /** + * @testdox The permission type enum has the correct number of type codes * @group framework * @coversNothing */ @@ -33,6 +35,7 @@ final class PermissionTypeTest extends \PHPUnit\Framework\TestCase } /** + * @testdox The permission type enum has only unique values * @group framework * @coversNothing */ @@ -42,6 +45,7 @@ final class PermissionTypeTest extends \PHPUnit\Framework\TestCase } /** + * @testdox The permission type enum has the correct values * @group framework * @coversNothing */ diff --git a/tests/Application/ApplicationInfoTest.php b/tests/Application/ApplicationInfoTest.php index d9d71736d..76f2524af 100755 --- a/tests/Application/ApplicationInfoTest.php +++ b/tests/Application/ApplicationInfoTest.php @@ -26,7 +26,7 @@ use phpOMS\Application\ApplicationInfo; final class ApplicationInfoTest extends \PHPUnit\Framework\TestCase { /** - * @testdox A info file can be correctly loaded + * @testdox An application info file can be correctly loaded * @covers phpOMS\Application\ApplicationInfo * @group framework */ diff --git a/tests/Application/ApplicationManagerTest.php b/tests/Application/ApplicationManagerTest.php index 6a03dffa7..b5a375c24 100755 --- a/tests/Application/ApplicationManagerTest.php +++ b/tests/Application/ApplicationManagerTest.php @@ -85,6 +85,7 @@ final class ApplicationManagerTest extends \PHPUnit\Framework\TestCase } /** + * @testdox An application can be installed and uninstalled * @covers phpOMS\Application\ApplicationManager * @covers phpOMS\Application\InstallerAbstract * @covers phpOMS\Application\StatusAbstract @@ -110,6 +111,7 @@ final class ApplicationManagerTest extends \PHPUnit\Framework\TestCase } /** + * @testdox An application can be re-initialized * @testdox A module can be re-initialized * @covers phpOMS\Application\ApplicationManager * @covers phpOMS\Application\InstallerAbstract @@ -139,6 +141,7 @@ final class ApplicationManagerTest extends \PHPUnit\Framework\TestCase } /** + * @testdox A invalid application path results in no installation * @covers phpOMS\Application\ApplicationManager * @group framework */ @@ -149,6 +152,7 @@ final class ApplicationManagerTest extends \PHPUnit\Framework\TestCase } /** + * @testdox A missing installation file results in no installation * @covers phpOMS\Application\ApplicationManager * @group framework */ @@ -158,6 +162,7 @@ final class ApplicationManagerTest extends \PHPUnit\Framework\TestCase } /** + * @testdox A missing info file results in no installation * @covers phpOMS\Application\ApplicationManager * @group framework */ @@ -167,6 +172,7 @@ final class ApplicationManagerTest extends \PHPUnit\Framework\TestCase } /** + * @testdox A invalid application path results in no uninstallation * @covers phpOMS\Application\ApplicationManager * @group framework */ @@ -177,6 +183,7 @@ final class ApplicationManagerTest extends \PHPUnit\Framework\TestCase } /** + * @testdox A missing uninstallation file results in no uninstallation * @covers phpOMS\Application\ApplicationManager * @group framework */ diff --git a/tests/Application/InstallerAbstractTest.php b/tests/Application/InstallerAbstractTest.php index 180761cbd..73d61cef0 100755 --- a/tests/Application/InstallerAbstractTest.php +++ b/tests/Application/InstallerAbstractTest.php @@ -19,7 +19,7 @@ require_once __DIR__ . '/../Autoloader.php'; use phpOMS\Application\InstallerAbstract; /** - * @testdox phpOMS\tests\Application\InstallerAbstractTest: Application installer + * @testdox phpOMS\tests\Application\InstallerAbstractTest: Abstract application installer * * @internal */ @@ -38,6 +38,7 @@ final class InstallerAbstractTest extends \PHPUnit\Framework\TestCase } /** + * @testdox An invalid theme cannot be installed * @covers phpOMS\Application\InstallerAbstract * @group framework */ diff --git a/tests/Application/StatusAbstractTest.php b/tests/Application/StatusAbstractTest.php index 61323844f..b98ead5c9 100755 --- a/tests/Application/StatusAbstractTest.php +++ b/tests/Application/StatusAbstractTest.php @@ -19,7 +19,7 @@ require_once __DIR__ . '/../Autoloader.php'; use phpOMS\Application\StatusAbstract; /** - * @testdox phpOMS\tests\Application\StatusAbstractTest: Application status + * @testdox phpOMS\tests\Application\StatusAbstractTest: Abstract application status * * @internal */ @@ -39,6 +39,7 @@ final class StatusAbstractTest extends \PHPUnit\Framework\TestCase } /** + * @testdox A invalid application path cannot be activated * @covers phpOMS\Application\StatusAbstract * @group framework */ diff --git a/tests/Application/UninstallerAbstractTest.php b/tests/Application/UninstallerAbstractTest.php index b4c5509d9..a75cb8c1b 100755 --- a/tests/Application/UninstallerAbstractTest.php +++ b/tests/Application/UninstallerAbstractTest.php @@ -21,7 +21,7 @@ use phpOMS\Application\UninstallerAbstract; use phpOMS\DataStorage\Database\DatabasePool; /** - * @testdox phpOMS\tests\Application\UninstallerAbstractTest: Abstract module + * @testdox phpOMS\tests\Application\UninstallerAbstractTest: Abstract application uninstaller * * @internal */ @@ -41,6 +41,7 @@ final class UninstallerAbstractTest extends \PHPUnit\Framework\TestCase } /** + * @testdox A missing database schema will not perform any database operations * @covers phpOMS\Application\UninstallerAbstract * @group framework */ diff --git a/tests/Asset/AssetTypeTest.php b/tests/Asset/AssetTypeTest.php index 0708ccb2b..fafe2bcdc 100755 --- a/tests/Asset/AssetTypeTest.php +++ b/tests/Asset/AssetTypeTest.php @@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php'; use phpOMS\Asset\AssetType; /** + * @testdox phpOMS\tests\Asset\AssetType: Asset type * @internal */ final class AssetTypeTest extends \PHPUnit\Framework\TestCase { /** + * @testdox The asset type enum has the correct number of status codes * @group framework * @coversNothing */ @@ -33,6 +35,7 @@ final class AssetTypeTest extends \PHPUnit\Framework\TestCase } /** + * @testdox The asset type enum has only unique values * @group framework * @coversNothing */ @@ -42,6 +45,7 @@ final class AssetTypeTest extends \PHPUnit\Framework\TestCase } /** + * @testdox The asset type enum has the correct values * @group framework * @coversNothing */ diff --git a/tests/Auth/LoginReturnTypeTest.php b/tests/Auth/LoginReturnTypeTest.php index cb4cdad4a..f7ddde1b6 100755 --- a/tests/Auth/LoginReturnTypeTest.php +++ b/tests/Auth/LoginReturnTypeTest.php @@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php'; use phpOMS\Auth\LoginReturnType; /** + * @testdox phpOMS\tests\Auth\LoginReturnType: Login return type * @internal */ final class LoginReturnTypeTest extends \PHPUnit\Framework\TestCase { /** + * @testdox The login return type enum has the correct number of type codes * @group framework * @coversNothing */ @@ -33,6 +35,7 @@ final class LoginReturnTypeTest extends \PHPUnit\Framework\TestCase } /** + * @testdox The login return type enum has only unique values * @group framework * @coversNothing */ @@ -42,6 +45,7 @@ final class LoginReturnTypeTest extends \PHPUnit\Framework\TestCase } /** + * @testdox The login return type enum has the correct values * @group framework * @coversNothing */ diff --git a/tests/Business/Finance/FinanceFormulasTest.php b/tests/Business/Finance/FinanceFormulasTest.php index 73331c399..3ad0b9fa3 100755 --- a/tests/Business/Finance/FinanceFormulasTest.php +++ b/tests/Business/Finance/FinanceFormulasTest.php @@ -282,7 +282,7 @@ final class FinanceFormulasTest extends \PHPUnit\Framework\TestCase } /** - * @testdox Balance / P&L ratios are correct (e.g. inventory turnover, net profit margin) + * @testdox Various ratios are correct (e.g. interest coverage, quick ratio, rate of inflation) * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ diff --git a/tests/DataStorage/Cache/Connection/RedisCacheTest.php b/tests/DataStorage/Cache/Connection/RedisCacheTest.php index 2e1fa0a8e..872f1004e 100755 --- a/tests/DataStorage/Cache/Connection/RedisCacheTest.php +++ b/tests/DataStorage/Cache/Connection/RedisCacheTest.php @@ -20,7 +20,7 @@ use phpOMS\DataStorage\Cache\Connection\RedisCache; use phpOMS\Utils\TestUtils; /** - * @testdox phpOMS\tests\DataStorage\Cache\Connection\RedisCacheTest: Redis cache connection + * @testdox phpOMS\tests\DataStorage\Cache\Connection\RedisCache: Redis cache connection * * @internal */ diff --git a/tests/DataStorage/LockExceptionTest.php b/tests/DataStorage/LockExceptionTest.php index 5169b7889..7ba06da97 100755 --- a/tests/DataStorage/LockExceptionTest.php +++ b/tests/DataStorage/LockExceptionTest.php @@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php'; use phpOMS\DataStorage\LockException; /** + * @testdox phpOMS\tests\DataStorage\LockExceptionTest: Lock exception * @internal */ final class LockExceptionTest extends \PHPUnit\Framework\TestCase { /** + * @testdox The lock exception is an instance of the runtime exception * @covers phpOMS\DataStorage\LockException * @group framework */ diff --git a/tests/Dispatcher/DispatcherTest.php b/tests/Dispatcher/DispatcherTest.php index 168bc1705..0f83ff29b 100755 --- a/tests/Dispatcher/DispatcherTest.php +++ b/tests/Dispatcher/DispatcherTest.php @@ -48,7 +48,7 @@ final class DispatcherTest extends \PHPUnit\Framework\TestCase } /** - * @testdox The dispatcher has the expected member variables + * @testdox The dispatcher has the expected attributes * @covers phpOMS\Dispatcher\Dispatcher * @group framework */ @@ -57,13 +57,18 @@ final class DispatcherTest extends \PHPUnit\Framework\TestCase self::assertObjectHasAttribute('controllers', $this->app->dispatcher); } + /** + * @testdox A route can be added and dispatched + * @covers phpOMS\Dispatcher\Dispatcher + * @group framework + */ public function testControllerInputOutput() : void { $this->app->dispatcher->set(new class() extends ModuleAbstract { - public string $name = 'test'; + public string $name = 'test'; - public function testFunction() { return $this->name; } - }, 'test'); + public function testFunction() { return $this->name; } + }, 'test'); $localization = new Localization(); @@ -199,6 +204,7 @@ final class DispatcherTest extends \PHPUnit\Framework\TestCase } /** + * @testdox The dispatcher can pass additional data to the destination * @covers phpOMS\Dispatcher\Dispatcher * @group framework */ diff --git a/tests/Image/KernelTest.php b/tests/Image/KernelTest.php index 1ffab22b0..fe137285b 100755 --- a/tests/Image/KernelTest.php +++ b/tests/Image/KernelTest.php @@ -19,18 +19,24 @@ require_once __DIR__ . '/../Autoloader.php'; use phpOMS\Image\Kernel; /** + * @testdox phpOMS\tests\Image\KernelTest: Image kernel * @internal */ final class KernelTest extends \PHPUnit\Framework\TestCase { /** + * @testdox The kernel can be applied to an image which is then stored in a new file * @group framework - * @coversNothing + * @covers phpOMS\Image\Kernel */ public function testKernel() : void { Kernel::convolve(__DIR__ . '/img1.png', __DIR__ . '/test_img1_sharpen.png', Kernel::KERNEL_SHARPEN); Kernel::convolve(__DIR__ . '/img1.png', __DIR__ . '/test_img1_blur.png', Kernel::KERNEL_GAUSSUAN_BLUR_3); Kernel::convolve(__DIR__ . '/img1.png', __DIR__ . '/test_img1_emboss.png', Kernel::KERNEL_EMBOSS); + + self::assertTrue(\is_file(__DIR__ . '/test_img1_sharpen.png')); + self::assertTrue(\is_file(__DIR__ . '/test_img1_blur.png')); + self::assertTrue(\is_file(__DIR__ . '/test_img1_emboss.png')); } } diff --git a/tests/Image/SkewTest.php b/tests/Image/SkewTest.php index 273e5a13b..4783d6601 100755 --- a/tests/Image/SkewTest.php +++ b/tests/Image/SkewTest.php @@ -19,13 +19,15 @@ require_once __DIR__ . '/../Autoloader.php'; use phpOMS\Image\Skew; /** + * @testdox phpOMS\tests\Image\SkewTest: Image skew * @internal */ final class SkewTest extends \PHPUnit\Framework\TestCase { /** + * @testdox A image can be automatically unskewed * @group framework - * @coversNothing + * @covers phpOMS\Image\Skew */ public function testSkew() : void { @@ -39,5 +41,7 @@ final class SkewTest extends \PHPUnit\Framework\TestCase [150, 75], [1700, 900] ); + + self::assertTrue(\is_file(__DIR__ . '/test_binary_untilted.png')); } } diff --git a/tests/Image/ThresholdingTest.php b/tests/Image/ThresholdingTest.php index d1b8e57cb..6af1bfe86 100755 --- a/tests/Image/ThresholdingTest.php +++ b/tests/Image/ThresholdingTest.php @@ -19,17 +19,22 @@ require_once __DIR__ . '/../Autoloader.php'; use phpOMS\Image\Thresholding; /** + * @testdox phpOMS\tests\Image\ThresholdingTest: Image thresholding * @internal */ final class ThresholdingTest extends \PHPUnit\Framework\TestCase { /** + * @testdox The thresholding is correctly applied to the image * @group framework - * @coversNothing + * @covers phpOMS\Image\Thresholding */ public function testThresholding() : void { Thresholding::integralThresholding(__DIR__ . '/img1.png', __DIR__ . '/test_img1_integral_thresholding.png'); Thresholding::integralThresholding(__DIR__ . '/img2.jpg', __DIR__ . '/test_img2_integral_thresholding.jpg'); + + self::assertTrue(\is_file(__DIR__ . '/test_img1_integral_thresholding.png')); + self::assertTrue(\is_file(__DIR__ . '/test_img2_integral_thresholding.jpg')); } } diff --git a/tests/Localization/Defaults/CityMapperTest.php b/tests/Localization/Defaults/CityMapperTest.php index 75704f42e..040364d82 100755 --- a/tests/Localization/Defaults/CityMapperTest.php +++ b/tests/Localization/Defaults/CityMapperTest.php @@ -31,7 +31,6 @@ final class CityMapperTest extends \PHPUnit\Framework\TestCase public static function setUpBeforeClass() : void { $con = new SqliteConnection([ - 'prefix' => '', 'db' => 'sqlite', 'database' => \realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'), ]); diff --git a/tests/Localization/Defaults/CountryMapperTest.php b/tests/Localization/Defaults/CountryMapperTest.php index 15c54037e..ed549f6b1 100755 --- a/tests/Localization/Defaults/CountryMapperTest.php +++ b/tests/Localization/Defaults/CountryMapperTest.php @@ -31,7 +31,6 @@ final class CountryMapperTest extends \PHPUnit\Framework\TestCase public static function setUpBeforeClass() : void { $con = new SqliteConnection([ - 'prefix' => '', 'db' => 'sqlite', 'database' => \realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'), ]); diff --git a/tests/Localization/Defaults/CurrencyMapperTest.php b/tests/Localization/Defaults/CurrencyMapperTest.php index bbf22ac20..9e6dbdd04 100755 --- a/tests/Localization/Defaults/CurrencyMapperTest.php +++ b/tests/Localization/Defaults/CurrencyMapperTest.php @@ -31,7 +31,6 @@ final class CurrencyMapperTest extends \PHPUnit\Framework\TestCase public static function setUpBeforeClass() : void { $con = new SqliteConnection([ - 'prefix' => '', 'db' => 'sqlite', 'database' => \realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'), ]); diff --git a/tests/Localization/Defaults/IbanMapperTest.php b/tests/Localization/Defaults/IbanMapperTest.php index 0d5e37851..e898d6799 100755 --- a/tests/Localization/Defaults/IbanMapperTest.php +++ b/tests/Localization/Defaults/IbanMapperTest.php @@ -31,7 +31,6 @@ final class IbanMapperTest extends \PHPUnit\Framework\TestCase public static function setUpBeforeClass() : void { $con = new SqliteConnection([ - 'prefix' => '', 'db' => 'sqlite', 'database' => \realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'), ]); diff --git a/tests/Localization/Defaults/LanguageMapperTest.php b/tests/Localization/Defaults/LanguageMapperTest.php index afe45665b..b6345b4da 100755 --- a/tests/Localization/Defaults/LanguageMapperTest.php +++ b/tests/Localization/Defaults/LanguageMapperTest.php @@ -31,7 +31,6 @@ final class LanguageMapperTest extends \PHPUnit\Framework\TestCase public static function setUpBeforeClass() : void { $con = new SqliteConnection([ - 'prefix' => '', 'db' => 'sqlite', 'database' => \realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'), ]); diff --git a/tests/Localization/ISO3166CharEnumTest.php b/tests/Localization/ISO3166CharEnumTest.php index ec5bf9c9c..9511779c9 100755 --- a/tests/Localization/ISO3166CharEnumTest.php +++ b/tests/Localization/ISO3166CharEnumTest.php @@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php'; use phpOMS\Localization\ISO3166CharEnum; /** + * @testdox phpOMS\tests\Localization\ISO3166CharEnumTest: ISO 3166 country codes * @internal */ final class ISO3166CharEnumTest extends \PHPUnit\Framework\TestCase { /** + * @testdox The ISO 3166 country code enum has the correct format of country codes * @group framework * @coversNothing */ @@ -41,6 +43,15 @@ final class ISO3166CharEnumTest extends \PHPUnit\Framework\TestCase } self::assertTrue($ok); - self::assertEquals(\count($enum), \count(\array_unique($enum))); + } + + /** + * @testdox The ISO 3166 enum has only unique values + * @group framework + * @coversNothing + */ + public function testUnique() : void + { + self::assertEquals(ISO3166CharEnum::getConstants(), \array_unique(ISO3166CharEnum::getConstants())); } } diff --git a/tests/Localization/ISO3166NameEnumTest.php b/tests/Localization/ISO3166NameEnumTest.php index 363cd2fc3..8f9c8e03f 100755 --- a/tests/Localization/ISO3166NameEnumTest.php +++ b/tests/Localization/ISO3166NameEnumTest.php @@ -19,15 +19,17 @@ require_once __DIR__ . '/../Autoloader.php'; use phpOMS\Localization\ISO3166NameEnum; /** + * @testdox phpOMS\tests\Localization\ISO3166NameEnumTest: ISO 3166 country names * @internal */ final class ISO3166NameEnumTest extends \PHPUnit\Framework\TestCase { /** + * @testdox The ISO 3166 enum has only unique values * @group framework * @coversNothing */ - public function testEnums() : void + public function testUnique() : void { $enum = ISO3166NameEnum::getConstants(); self::assertEquals(\count($enum), \count(\array_unique($enum))); diff --git a/tests/Localization/ISO3166NumEnumTest.php b/tests/Localization/ISO3166NumEnumTest.php index f5c3c5172..4c5cd51cf 100755 --- a/tests/Localization/ISO3166NumEnumTest.php +++ b/tests/Localization/ISO3166NumEnumTest.php @@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php'; use phpOMS\Localization\ISO3166NumEnum; /** + * @testdox phpOMS\tests\Localization\ISO3166NumEnumTest: ISO 3166 country codes * @internal */ final class ISO3166NumEnumTest extends \PHPUnit\Framework\TestCase { /** + * @testdox The ISO 3166 country code enum has the correct format of country codes * @group framework * @coversNothing */ @@ -41,6 +43,15 @@ final class ISO3166NumEnumTest extends \PHPUnit\Framework\TestCase } self::assertTrue($ok); - self::assertEquals(\count($enum), \count(\array_unique($enum))); + } + + /** + * @testdox The ISO 3166 enum has only unique values + * @group framework + * @coversNothing + */ + public function testUnique() : void + { + self::assertEquals(ISO3166NumEnum::getConstants(), \array_unique(ISO3166NumEnum::getConstants())); } } diff --git a/tests/Localization/ISO3166TwoEnumTest.php b/tests/Localization/ISO3166TwoEnumTest.php index 3dc4ad8b1..0683cd181 100755 --- a/tests/Localization/ISO3166TwoEnumTest.php +++ b/tests/Localization/ISO3166TwoEnumTest.php @@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php'; use phpOMS\Localization\ISO3166TwoEnum; /** + * @testdox phpOMS\tests\Localization\ISO3166NumEnumTest: ISO 3166 country codes * @internal */ final class ISO3166TwoEnumTest extends \PHPUnit\Framework\TestCase { /** + * @testdox The ISO 3166 country code enum has the correct format of country codes * @group framework * @coversNothing */ @@ -41,6 +43,15 @@ final class ISO3166TwoEnumTest extends \PHPUnit\Framework\TestCase } self::assertTrue($ok); - self::assertEquals(\count($countryCodes), \count(\array_unique($countryCodes))); + } + + /** + * @testdox The ISO 3166 enum has only unique values + * @group framework + * @coversNothing + */ + public function testUnique() : void + { + self::assertEquals(ISO3166TwoEnum::getConstants(), \array_unique(ISO3166TwoEnum::getConstants())); } } diff --git a/tests/Localization/ISO4217CharEnumTest.php b/tests/Localization/ISO4217CharEnumTest.php index d7607c348..918eebb66 100755 --- a/tests/Localization/ISO4217CharEnumTest.php +++ b/tests/Localization/ISO4217CharEnumTest.php @@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php'; use phpOMS\Localization\ISO4217CharEnum; /** + * @testdox phpOMS\tests\Localization\ISO4217CharEnumTest: ISO 4217 currency codes * @internal */ final class ISO4217CharEnumTest extends \PHPUnit\Framework\TestCase { /** + * @testdox The ISO 4217 currency code enum has the correct format of currency codes * @group framework * @coversNothing */ @@ -41,6 +43,15 @@ final class ISO4217CharEnumTest extends \PHPUnit\Framework\TestCase } self::assertTrue($ok); - self::assertEquals(\count($enum), \count(\array_unique($enum))); + } + + /** + * @testdox The ISO 4217 enum has only unique values + * @group framework + * @coversNothing + */ + public function testUnique() : void + { + self::assertEquals(ISO4217CharEnum::getConstants(), \array_unique(ISO4217CharEnum::getConstants())); } } diff --git a/tests/Localization/ISO4217DecimalEnumTest.php b/tests/Localization/ISO4217DecimalEnumTest.php index 3bd4d243e..d4ace844f 100755 --- a/tests/Localization/ISO4217DecimalEnumTest.php +++ b/tests/Localization/ISO4217DecimalEnumTest.php @@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php'; use phpOMS\Localization\ISO4217DecimalEnum; /** + * @testdox phpOMS\tests\Localization\ISO4217DecimalEnumTest: ISO 4217 currency codes * @internal */ final class ISO4217DecimalEnumTest extends \PHPUnit\Framework\TestCase { /** + * @testdox The ISO 4217 currency code enum has the correct format of currency decimal places * @group framework * @coversNothing */ diff --git a/tests/Localization/ISO4217EnumTest.php b/tests/Localization/ISO4217EnumTest.php index 399f3b344..4d68c5821 100755 --- a/tests/Localization/ISO4217EnumTest.php +++ b/tests/Localization/ISO4217EnumTest.php @@ -19,15 +19,17 @@ require_once __DIR__ . '/../Autoloader.php'; use phpOMS\Localization\ISO4217Enum; /** + * @testdox phpOMS\tests\Localization\ISO4217EnumTest: ISO 4217 currency codes * @internal */ final class ISO4217EnumTest extends \PHPUnit\Framework\TestCase { /** + * @testdox The ISO 4217 currency code enum has only unique values * @group framework * @coversNothing */ - public function testEnums() : void + public function testUnique() : void { $enum = ISO4217Enum::getConstants(); self::assertEquals(\count($enum), \count(\array_unique($enum))); diff --git a/tests/Localization/ISO4217NumEnumTest.php b/tests/Localization/ISO4217NumEnumTest.php index ab2a15e29..8fd3faf06 100755 --- a/tests/Localization/ISO4217NumEnumTest.php +++ b/tests/Localization/ISO4217NumEnumTest.php @@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php'; use phpOMS\Localization\ISO4217NumEnum; /** + * @testdox phpOMS\tests\Localization\ISO4217NumEnumTest: ISO 4217 currency codes * @internal */ final class ISO4217NumEnumTest extends \PHPUnit\Framework\TestCase { /** + * @testdox The ISO 4217 currency code enum has the correct format of currency codes * @group framework * @coversNothing */ @@ -41,6 +43,15 @@ final class ISO4217NumEnumTest extends \PHPUnit\Framework\TestCase } self::assertTrue($ok); - self::assertEquals(\count($enum), \count(\array_unique($enum))); + } + + /** + * @testdox The ISO 4217 enum has only unique values + * @group framework + * @coversNothing + */ + public function testUnique() : void + { + self::assertEquals(ISO4217NumEnum::getConstants(), \array_unique(ISO4217NumEnum::getConstants())); } } diff --git a/tests/Localization/ISO4217SubUnitEnumTest.php b/tests/Localization/ISO4217SubUnitEnumTest.php index 1a4f3f364..54f30ebe7 100755 --- a/tests/Localization/ISO4217SubUnitEnumTest.php +++ b/tests/Localization/ISO4217SubUnitEnumTest.php @@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php'; use phpOMS\Localization\ISO4217SubUnitEnum; /** + * @testdox phpOMS\tests\Localization\ISO4217SubUnitEnumTest: ISO 4217 currency codes * @internal */ final class ISO4217SubUnitEnumTest extends \PHPUnit\Framework\TestCase { /** + * @testdox The ISO 4217 currency code enum has the correct format of currency sub units * @group framework * @coversNothing */ diff --git a/tests/Localization/ISO4217SymbolEnumTest.php b/tests/Localization/ISO4217SymbolEnumTest.php index 014158d29..c2c9e3f15 100755 --- a/tests/Localization/ISO4217SymbolEnumTest.php +++ b/tests/Localization/ISO4217SymbolEnumTest.php @@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php'; use phpOMS\Localization\ISO4217SymbolEnum; /** + * @testdox phpOMS\tests\Localization\ISO4217SymbolEnumTest: ISO 4217 currency codes * @internal */ final class ISO4217SymbolEnumTest extends \PHPUnit\Framework\TestCase { /** + * @testdox The ISO 4217 currency code enum has the correct number of currency symbols * @group framework * @coversNothing */ diff --git a/tests/Localization/ISO639EnumTest.php b/tests/Localization/ISO639EnumTest.php index 19d48ad24..638123965 100755 --- a/tests/Localization/ISO639EnumTest.php +++ b/tests/Localization/ISO639EnumTest.php @@ -19,15 +19,17 @@ require_once __DIR__ . '/../Autoloader.php'; use phpOMS\Localization\ISO639Enum; /** + * @testdox phpOMS\tests\Localization\ISO639EnumTest: ISO 639 language codes * @internal */ final class ISO639EnumTest extends \PHPUnit\Framework\TestCase { /** + * @testdox The ISO 639 language code enum has only unique values * @group framework * @coversNothing */ - public function testEnums() : void + public function testUnique() : void { $enum = ISO639Enum::getConstants(); self::assertEquals(\count($enum), \count(\array_unique($enum))); diff --git a/tests/Localization/ISO639x1EnumTest.php b/tests/Localization/ISO639x1EnumTest.php index 0c3df105d..8e13fcd24 100755 --- a/tests/Localization/ISO639x1EnumTest.php +++ b/tests/Localization/ISO639x1EnumTest.php @@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php'; use phpOMS\Localization\ISO639x1Enum; /** + * @testdox phpOMS\tests\Localization\ISO639x1EnumTest: ISO 639-1 language codes * @internal */ final class ISO639x1EnumTest extends \PHPUnit\Framework\TestCase { /** + * @testdox The ISO 639-1 language code enum has the correct format of language codes * @group framework * @coversNothing */ @@ -41,6 +43,15 @@ final class ISO639x1EnumTest extends \PHPUnit\Framework\TestCase } self::assertTrue($ok); - self::assertEquals(\count($enum), \count(\array_unique($enum))); + } + + /** + * @testdox The ISO 639-1 enum has only unique values + * @group framework + * @coversNothing + */ + public function testUnique() : void + { + self::assertEquals(ISO639x1Enum::getConstants(), \array_unique(ISO639x1Enum::getConstants())); } } diff --git a/tests/Localization/ISO639x2EnumTest.php b/tests/Localization/ISO639x2EnumTest.php index 16b023428..61acab688 100755 --- a/tests/Localization/ISO639x2EnumTest.php +++ b/tests/Localization/ISO639x2EnumTest.php @@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php'; use phpOMS\Localization\ISO639x2Enum; /** + * @testdox phpOMS\tests\Localization\ISO639x2EnumTest: ISO 639-2 language codes * @internal */ final class ISO639x2EnumTest extends \PHPUnit\Framework\TestCase { /** + * @testdox The ISO 639-2 language code enum has the correct format of language codes * @group framework * @coversNothing */ @@ -41,6 +43,15 @@ final class ISO639x2EnumTest extends \PHPUnit\Framework\TestCase } self::assertTrue($ok); - self::assertEquals(\count($enum), \count(\array_unique($enum))); + } + + /** + * @testdox The ISO 639-2 enum has only unique values + * @group framework + * @coversNothing + */ + public function testUnique() : void + { + self::assertEquals(ISO639x2Enum::getConstants(), \array_unique(ISO639x2Enum::getConstants())); } } diff --git a/tests/Localization/ISO8601EnumArrayTest.php b/tests/Localization/ISO8601EnumArrayTest.php index 4e3f9ea96..254e19641 100755 --- a/tests/Localization/ISO8601EnumArrayTest.php +++ b/tests/Localization/ISO8601EnumArrayTest.php @@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php'; use phpOMS\Localization\ISO8601EnumArray; /** + * @testdox phpOMS\tests\Localization\ISO8601EnumArrayTest: ISO 8601 date time formats * @internal */ final class ISO8601EnumArrayTest extends \PHPUnit\Framework\TestCase { /** + * @testdox The ISO 8601 date time format enum has the correct number of date time formats * @group framework * @coversNothing */ @@ -31,4 +33,14 @@ final class ISO8601EnumArrayTest extends \PHPUnit\Framework\TestCase { self::assertCount(4, ISO8601EnumArray::getConstants()); } + + /** + * @testdox The ISO 8601 enum has only unique values + * @group framework + * @coversNothing + */ + public function testUnique() : void + { + self::assertEquals(ISO8601EnumArray::getConstants(), \array_unique(ISO8601EnumArray::getConstants())); + } } diff --git a/tests/Localization/L11nManagerTest.php b/tests/Localization/L11nManagerTest.php index 192372910..5f862280d 100755 --- a/tests/Localization/L11nManagerTest.php +++ b/tests/Localization/L11nManagerTest.php @@ -27,6 +27,7 @@ require_once __DIR__ . '/../Autoloader.php'; final class L11nManagerTest extends \PHPUnit\Framework\TestCase { protected L11nManager $l11nManager; + protected L11nManager $l11nManager2; /** * {@inheritdoc} @@ -118,7 +119,7 @@ final class L11nManagerTest extends \PHPUnit\Framework\TestCase } /** - * @testdox Language data can be loaded from a file + * @testdox Multiple languages can be loaded from a file * @covers phpOMS\Localization\L11nManager * @group framework */ diff --git a/tests/Localization/PhoneEnumTest.php b/tests/Localization/PhoneEnumTest.php index 65b18b258..e9859aab3 100755 --- a/tests/Localization/PhoneEnumTest.php +++ b/tests/Localization/PhoneEnumTest.php @@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php'; use phpOMS\Localization\PhoneEnum; /** + * @testdox phpOMS\tests\Localization\PhoneEnumTest: Country phone codes * @internal */ final class PhoneEnumTest extends \PHPUnit\Framework\TestCase { /** + * @testdox The phone enum has the correct format of country phone numbers * @group framework * @coversNothing */ diff --git a/tests/Localization/TimeZoneEnumArrayTest.php b/tests/Localization/TimeZoneEnumArrayTest.php index 7ab7f2a0a..098dc09e8 100755 --- a/tests/Localization/TimeZoneEnumArrayTest.php +++ b/tests/Localization/TimeZoneEnumArrayTest.php @@ -19,15 +19,17 @@ require_once __DIR__ . '/../Autoloader.php'; use phpOMS\Localization\TimeZoneEnumArray; /** + * @testdox phpOMS\tests\Localization\TimeZoneEnumArrayTest: Time zone enum array * @internal */ final class TimeZoneEnumArrayTest extends \PHPUnit\Framework\TestCase { /** + * @testdox The time zone enum array has only unique values * @group framework * @coversNothing */ - public function testEnums() : void + public function testUnique() : void { self::assertEquals(\count(TimeZoneEnumArray::getConstants()), \count(\array_unique(TimeZoneEnumArray::getConstants()))); } diff --git a/tests/Log/LogLevelTest.php b/tests/Log/LogLevelTest.php index dd4dd7b29..7a0e5f3c5 100755 --- a/tests/Log/LogLevelTest.php +++ b/tests/Log/LogLevelTest.php @@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php'; use phpOMS\Log\LogLevel; /** + * @testdox phpOMS\tests\Log\LogLevelTest: Log level enum * @internal */ final class LogLevelTest extends \PHPUnit\Framework\TestCase { /** + * @testdox The log level enum has the correct number of log levels * @group framework * @coversNothing */ @@ -33,6 +35,7 @@ final class LogLevelTest extends \PHPUnit\Framework\TestCase } /** + * @testdox The log level enum has only unique values * @group framework * @coversNothing */ @@ -42,6 +45,7 @@ final class LogLevelTest extends \PHPUnit\Framework\TestCase } /** + * @testdox The log level enum has the correct values * @group framework * @coversNothing */ diff --git a/tests/Module/InstallerAbstractTest.php b/tests/Module/InstallerAbstractTest.php index 80f14227c..3bc0e2c0a 100755 --- a/tests/Module/InstallerAbstractTest.php +++ b/tests/Module/InstallerAbstractTest.php @@ -23,7 +23,7 @@ use phpOMS\Module\InstallerAbstract; use phpOMS\Module\ModuleInfo; /** - * @testdox phpOMS\tests\Module\InstallerAbstractTest: Abstract module + * @testdox phpOMS\tests\Module\InstallerAbstractTest: Abstract module installer * * @internal */ @@ -42,6 +42,7 @@ final class InstallerAbstractTest extends \PHPUnit\Framework\TestCase } /** + * @testdox Invalid or missing module status file throws exception during installation * @covers phpOMS\Module\InstallerAbstract * @group framework */ diff --git a/tests/Module/ModuleAbstractTest.php b/tests/Module/ModuleAbstractTest.php index af9e787f1..646399c75 100755 --- a/tests/Module/ModuleAbstractTest.php +++ b/tests/Module/ModuleAbstractTest.php @@ -218,7 +218,7 @@ final class ModuleAbstractTest extends \PHPUnit\Framework\TestCase } /** - * @testdox A invalid language or theme returns in an empty localization/language dataset + * @testdox A module can load its own localization/language dataset * @covers phpOMS\Module\ModuleAbstract * @group framework */ @@ -459,6 +459,11 @@ final class ModuleAbstractTest extends \PHPUnit\Framework\TestCase $this->dbTeardown(); } + /** + * @testdox The model CRUD functions can be called with a closure + * @covers phpOMS\Module\ModuleAbstract + * @group framework + */ public function testModelFunctionsWithClosure() : void { $output = $this->module->createWithCallable(); diff --git a/tests/Module/ModuleManagerTest.php b/tests/Module/ModuleManagerTest.php index 88a229454..929140c96 100755 --- a/tests/Module/ModuleManagerTest.php +++ b/tests/Module/ModuleManagerTest.php @@ -199,7 +199,7 @@ final class ModuleManagerTest extends \PHPUnit\Framework\TestCase } /** - * @testdox A module can be re-initialized + * @testdox A none-existing module cannot be re-initialized * @covers phpOMS\Module\ModuleManager * @group framework */ @@ -251,6 +251,11 @@ final class ModuleManagerTest extends \PHPUnit\Framework\TestCase self::assertTrue($this->moduleManager->isRunning('TestModule')); } + /** + * @testdox Getting language files for an invalid module returns an empty array + * @covers phpOMS\Module\ModuleManager + * @group framework + */ public function testGetLanguageForInvalidRequest() : void { $request = new HttpRequest(new HttpUri('http://127.0.0.1/en/error/invalid')); @@ -261,12 +266,6 @@ final class ModuleManagerTest extends \PHPUnit\Framework\TestCase self::assertEquals([], $this->moduleManager->getLanguageFiles($request)); } - public function testGetActiveModulesWithInvalidBasePath() : void - { - $this->moduleManager = new ModuleManager($this->app, __DIR__ . '/invalid'); - self::assertEquals([], $this->moduleManager->getActiveModules(false)); - } - /** * @testdox Installed modules can be returned * @covers phpOMS\Module\ModuleManager @@ -279,21 +278,26 @@ final class ModuleManagerTest extends \PHPUnit\Framework\TestCase self::assertNotEmpty($installed); } + /** + * @testdox A module can be checked if it is installed + * @covers phpOMS\Module\ModuleManager + * @group framework + */ public function testIsInstalled() : void { self::assertTrue($this->moduleManager->isInstalled('TestModule')); } + /** + * @testdox Installing an already installed module doesn't perform anything + * @covers phpOMS\Module\ModuleManager + * @group framework + */ public function testInstallingAlreadyInstalledModule() : void { self::assertTrue($this->moduleManager->install('TestModule')); } - public function testAvailableModules() : void - { - self::assertEquals([], $this->moduleManager->getAvailableModules()); - } - /** * @testdox The valid module can be returned * @covers phpOMS\Module\ModuleManager @@ -325,6 +329,7 @@ final class ModuleManagerTest extends \PHPUnit\Framework\TestCase } /** + * @testdox A empty or invalid module path returns an empty array on module getter functions. * @covers phpOMS\Module\ModuleManager * @group framework */ @@ -334,9 +339,11 @@ final class ModuleManagerTest extends \PHPUnit\Framework\TestCase self::assertEquals([], $moduleManager->getAllModules()); self::assertEquals([], $moduleManager->getInstalledModules()); + self::assertEquals([], $moduleManager->getActiveModules(false)); } /** + * @testdox A invalid module name cannot be installed * @covers phpOMS\Module\ModuleManager * @group framework */ @@ -346,6 +353,7 @@ final class ModuleManagerTest extends \PHPUnit\Framework\TestCase } /** + * @testdox A invalid module name cannot be uninstalled * @covers phpOMS\Module\ModuleManager * @group framework */ diff --git a/tests/Module/NullModuleTest.php b/tests/Module/NullModuleTest.php index 41ec4c5b5..fa94960c3 100755 --- a/tests/Module/NullModuleTest.php +++ b/tests/Module/NullModuleTest.php @@ -43,6 +43,8 @@ final class NullModuleTest extends \PHPUnit\Framework\TestCase } /** + * @testdox The null module is an instance of the module abstract + * @covers phpOMS\Module\NullModule * @group framework */ public function testModule() : void diff --git a/tests/Module/StatusAbstractTest.php b/tests/Module/StatusAbstractTest.php index 76c7bb725..39c7f2c7d 100755 --- a/tests/Module/StatusAbstractTest.php +++ b/tests/Module/StatusAbstractTest.php @@ -20,7 +20,7 @@ use phpOMS\Module\ModuleInfo; use phpOMS\Module\StatusAbstract; /** - * @testdox phpOMS\tests\Module\StatusAbstractTest: Abstract module + * @testdox phpOMS\tests\Module\StatusAbstractTest: Abstract module status * * @internal */ @@ -40,6 +40,7 @@ final class StatusAbstractTest extends \PHPUnit\Framework\TestCase } /** + * A invalid module path cannot be activated * @covers phpOMS\Module\StatusAbstract * @group framework */ diff --git a/tests/Module/UninstallerAbstractTest.php b/tests/Module/UninstallerAbstractTest.php index 2267c43c0..15ea0f323 100755 --- a/tests/Module/UninstallerAbstractTest.php +++ b/tests/Module/UninstallerAbstractTest.php @@ -21,7 +21,7 @@ use phpOMS\Module\ModuleInfo; use phpOMS\Module\UninstallerAbstract; /** - * @testdox phpOMS\tests\Module\UninstallerAbstractTest: Abstract module + * @testdox phpOMS\tests\Module\UninstallerAbstractTest: Abstract module uninstaller * * @internal */ @@ -41,6 +41,7 @@ final class UninstallerAbstractTest extends \PHPUnit\Framework\TestCase } /** + * @testdox A missing database schema will not perform any database operations * @covers phpOMS\Module\UninstallerAbstract * @group framework */ diff --git a/tests/Router/RouteVerbTest.php b/tests/Router/RouteVerbTest.php index b7fb61620..fb52b491a 100755 --- a/tests/Router/RouteVerbTest.php +++ b/tests/Router/RouteVerbTest.php @@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php'; use phpOMS\Router\RouteVerb; /** + * @testdox phpOMS\tests\WebRouter\RouteVerbTest: Route verb enum * @internal */ final class RouteVerbTest extends \PHPUnit\Framework\TestCase { /** + * @testdox The route verb enum has the correct values * @group framework * @coversNothing */ @@ -37,10 +39,11 @@ final class RouteVerbTest extends \PHPUnit\Framework\TestCase } /** + * @testdox The route verb enum has only unique values * @group framework * @coversNothing */ - public function testEnumUnique() : void + public function testUnique() : void { $values = RouteVerb::getConstants(); self::assertEquals(\count($values), \array_sum(\array_count_values($values))); diff --git a/tests/System/CharsetTypeTest.php b/tests/System/CharsetTypeTest.php index 2331450e6..64aad6189 100755 --- a/tests/System/CharsetTypeTest.php +++ b/tests/System/CharsetTypeTest.php @@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php'; use phpOMS\System\CharsetType; /** + * @testdox phpOMS\tests\System\CharsetTypeTest: Character set type enum * @internal */ final class CharsetTypeTest extends \PHPUnit\Framework\TestCase { /** + * @testdox The character set type enum has the correct amount of values * @group framework * @coversNothing */ @@ -33,6 +35,7 @@ final class CharsetTypeTest extends \PHPUnit\Framework\TestCase } /** + * @testdox The character set type enum has only unique values * @group framework * @coversNothing */ @@ -42,6 +45,7 @@ final class CharsetTypeTest extends \PHPUnit\Framework\TestCase } /** + * @testdox The character set type enum has the correct values * @group framework * @coversNothing */ diff --git a/tests/System/MimeTypeTest.php b/tests/System/MimeTypeTest.php index 13bf2de18..3da46cd4e 100755 --- a/tests/System/MimeTypeTest.php +++ b/tests/System/MimeTypeTest.php @@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php'; use phpOMS\System\MimeType; /** + * @testdox phpOMS\tests\System\MimeTypeTest: MimeType * @internal */ final class MimeTypeTest extends \PHPUnit\Framework\TestCase { /** + * @testdox The mime type enum vales have the correct format * @group framework * @coversNothing */ @@ -31,7 +33,7 @@ final class MimeTypeTest extends \PHPUnit\Framework\TestCase { $enums = MimeType::getConstants(); - foreach ($enums as $key => $value) { + foreach ($enums as $value) { if (\stripos($value, '/') === false) { self::assertFalse(true); } @@ -41,6 +43,7 @@ final class MimeTypeTest extends \PHPUnit\Framework\TestCase } /** + * @testdox The mime type enum vales can be retreived by extension * @covers phpOMS\System\MimeType * @group framework */ @@ -50,6 +53,7 @@ final class MimeTypeTest extends \PHPUnit\Framework\TestCase } /** + * @testdox A unknown extension returns application/octet-stream * @covers phpOMS\System\MimeType * @group framework */ diff --git a/tests/System/OperatingSystemTest.php b/tests/System/OperatingSystemTest.php index cc8ad15b0..ce3bccbdd 100755 --- a/tests/System/OperatingSystemTest.php +++ b/tests/System/OperatingSystemTest.php @@ -20,11 +20,13 @@ use phpOMS\System\OperatingSystem; use phpOMS\System\SystemType; /** + * @testdox phpOMS\tests\System\OperatingSystemTest: Operating system * @internal */ final class OperatingSystemTest extends \PHPUnit\Framework\TestCase { /** + * @testdox The current operating system can be returned * @covers phpOMS\System\OperatingSystem * @group framework */ diff --git a/tests/System/SystemTypeTest.php b/tests/System/SystemTypeTest.php index 03d2e9a1a..6f4a23fe4 100755 --- a/tests/System/SystemTypeTest.php +++ b/tests/System/SystemTypeTest.php @@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php'; use phpOMS\System\SystemType; /** + * @testdox phpOMS\tests\System\SystemTypeTest: System type * @internal */ final class SystemTypeTest extends \PHPUnit\Framework\TestCase { /** + * @testdox The system type enum has the correct amount of values * @group framework * @coversNothing */ @@ -33,6 +35,7 @@ final class SystemTypeTest extends \PHPUnit\Framework\TestCase } /** + * @testdox The system type enum has only unique values * @group framework * @coversNothing */ @@ -42,6 +45,7 @@ final class SystemTypeTest extends \PHPUnit\Framework\TestCase } /** + * @testdox The system type enum has the correct values * @group framework * @coversNothing */ diff --git a/tests/Uri/ArgumentTest.php b/tests/Uri/ArgumentTest.php index a206f398e..5faa599b9 100755 --- a/tests/Uri/ArgumentTest.php +++ b/tests/Uri/ArgumentTest.php @@ -78,6 +78,7 @@ final class ArgumentTest extends \PHPUnit\Framework\TestCase } /** + * @testdox The path can be set and returned * @covers phpOMS\Uri\Argument * @group framework */ @@ -89,66 +90,6 @@ final class ArgumentTest extends \PHPUnit\Framework\TestCase self::assertEquals('modules/admin/new/path', $obj->getPath()); } - /** - * @covers phpOMS\Uri\Argument - * @group framework - */ - public function testSchemeInputOutput() : void - { - $obj = new Argument(':modules/admin/test/path.php ?para1=abc ?para2=2 #frag'); - - $obj->scheme = 'scheme'; - self::assertEquals('scheme', $obj->scheme); - } - - /** - * @covers phpOMS\Uri\Argument - * @group framework - */ - public function testUserInputOutput() : void - { - $obj = new Argument(':modules/admin/test/path.php ?para1=abc ?para2=2 #frag'); - - $obj->user = 'user'; - self::assertEquals('user', $obj->user); - } - - /** - * @covers phpOMS\Uri\Argument - * @group framework - */ - public function testPassInputOutput() : void - { - $obj = new Argument(':modules/admin/test/path.php ?para1=abc ?para2=2 #frag'); - - $obj->pass = 'pass'; - self::assertEquals('pass', $obj->pass); - } - - /** - * @covers phpOMS\Uri\Argument - * @group framework - */ - public function testHostInputOutput() : void - { - $obj = new Argument(':modules/admin/test/path.php ?para1=abc ?para2=2 #frag'); - - $obj->host = 'host'; - self::assertEquals('host', $obj->host); - } - - /** - * @covers phpOMS\Uri\Argument - * @group framework - */ - public function testPortInputOutput() : void - { - $obj = new Argument(':modules/admin/test/path.php ?para1=abc ?para2=2 #frag'); - - $obj->port = 123; - self::assertEquals(123, $obj->port); - } - /** * @testdox The path offset can be set and returned * @covers phpOMS\Uri\Argument diff --git a/tests/Uri/HttpUriTest.php b/tests/Uri/HttpUriTest.php index 8c1287281..d62532266 100755 --- a/tests/Uri/HttpUriTest.php +++ b/tests/Uri/HttpUriTest.php @@ -56,7 +56,7 @@ final class HttpUriTest extends \PHPUnit\Framework\TestCase } /** - * @testdox The url schema can be parsed correctly from a url + * @testdox The url schema can be parsed correctly from a url and overwritten * @covers phpOMS\Uri\HttpUri * @group framework */ @@ -71,6 +71,7 @@ final class HttpUriTest extends \PHPUnit\Framework\TestCase } /** + * @testdox The port can be parsed correctly from a url and overwritten * @covers phpOMS\Uri\HttpUri * @group framework */ @@ -191,6 +192,7 @@ final class HttpUriTest extends \PHPUnit\Framework\TestCase } /** + * @testdox A path can be overwritten * @covers phpOMS\Uri\HttpUri * @group framework */ @@ -203,6 +205,7 @@ final class HttpUriTest extends \PHPUnit\Framework\TestCase } /** + * @testdox The path elements can be parsed from a url and overwritten * @covers phpOMS\Uri\HttpUri * @group framework */ diff --git a/tests/Uri/InvalidUriExceptionTest.php b/tests/Uri/InvalidUriExceptionTest.php index 99a97d876..1555d1d60 100755 --- a/tests/Uri/InvalidUriExceptionTest.php +++ b/tests/Uri/InvalidUriExceptionTest.php @@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php'; use phpOMS\Uri\InvalidUriException; /** + * @testdox phpOMS\tests\Uri\InvalidUriExceptionTest: Invalid uri exception * @internal */ final class InvalidUriExceptionTest extends \PHPUnit\Framework\TestCase { /** + * @testdox The invalid uri exception is an unexpected value exception * @covers phpOMS\Uri\InvalidUriException * @group framework */ diff --git a/tests/Uri/UriFactoryTest.php b/tests/Uri/UriFactoryTest.php index 010ca702d..21bb48fb7 100755 --- a/tests/Uri/UriFactoryTest.php +++ b/tests/Uri/UriFactoryTest.php @@ -240,7 +240,7 @@ final class UriFactoryTest extends \PHPUnit\Framework\TestCase } /** - * @testdox In case of missing ? for query the builder automatically fixes it + * @testdox A normal url will not be changed * @covers phpOMS\Uri\UriFactory * @group framework */