mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 17:58:41 +00:00
fix demoSetup
This commit is contained in:
parent
3d68874c2c
commit
5b2c9d499b
|
|
@ -27,6 +27,14 @@ use phpOMS\DataStorage\Database\Query\QueryType;
|
||||||
*/
|
*/
|
||||||
abstract class BuilderAbstract
|
abstract class BuilderAbstract
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Is read only.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected bool $isReadOnly = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Grammar.
|
* Grammar.
|
||||||
*
|
*
|
||||||
|
|
@ -105,4 +113,13 @@ abstract class BuilderAbstract
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
abstract public function toSql() : string;
|
abstract public function toSql() : string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute query.
|
||||||
|
*
|
||||||
|
* @return ?\PDOStatement
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
abstract public function execute() : ?\PDOStatement;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,10 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace phpOMS\DataStorage\Database;
|
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;
|
use phpOMS\DataStorage\Database\Query\QueryType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -135,6 +139,11 @@ abstract class GrammarAbstract
|
||||||
return \substr($queryString, 0, -1) . ';';
|
return \substr($queryString, 0, -1) . ';';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function compilePostQuerys(BuilderAbstract $query) : array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compile components.
|
* Compile components.
|
||||||
*
|
*
|
||||||
|
|
@ -146,37 +155,7 @@ abstract class GrammarAbstract
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected function compileComponents(BuilderAbstract $query) : array
|
abstract 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;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get date format.
|
* Get date format.
|
||||||
|
|
@ -265,4 +244,71 @@ abstract class GrammarAbstract
|
||||||
. $system
|
. $system
|
||||||
. ($system !== '*' ? $identifierEnd : '');
|
. ($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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -104,59 +104,59 @@ final class UpdateMapper extends DataMapperAbstract
|
||||||
*/
|
*/
|
||||||
private function updateModel(object $obj, mixed $objId, \ReflectionClass $refClass = null) : void
|
private function updateModel(object $obj, mixed $objId, \ReflectionClass $refClass = null) : void
|
||||||
{
|
{
|
||||||
// Model doesn't have anything to update
|
try {
|
||||||
if (\count($this->mapper::COLUMNS) < 2) {
|
// Model doesn't have anything to update
|
||||||
return;
|
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$refClass = $refClass ?? new \ReflectionClass($obj);
|
$query = new Builder($this->db);
|
||||||
$property = $refClass->getProperty($propertyName);
|
$query->update($this->mapper::TABLE)
|
||||||
|
->where($this->mapper::TABLE . '.' . $this->mapper::PRIMARYFIELD, '=', $objId);
|
||||||
|
|
||||||
if (!($property->isPublic())) {
|
foreach ($this->mapper::COLUMNS as $column) {
|
||||||
$property->setAccessible(true);
|
$propertyName = \stripos($column['internal'], '/') !== false ? \explode('/', $column['internal'])[0] : $column['internal'];
|
||||||
$tValue = $property->getValue($obj);
|
if (isset($this->mapper::HAS_MANY[$propertyName])
|
||||||
$property->setAccessible(false);
|
|| $column['internal'] === $this->mapper::PRIMARYFIELD
|
||||||
} else {
|
|| (($column['readonly'] ?? false) === true && !isset($this->with[$propertyName]))
|
||||||
$tValue = $obj->{$propertyName};
|
|| (($column['writeonly'] ?? false) === true && !isset($this->with[$propertyName]))
|
||||||
}
|
) {
|
||||||
|
continue;
|
||||||
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);
|
$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());
|
$sth = $this->db->con->prepare($query->toSql());
|
||||||
if ($sth !== false) {
|
if ($sth !== false) {
|
||||||
$sth->execute();
|
$sth->execute();
|
||||||
|
|
|
||||||
|
|
@ -106,62 +106,67 @@ final class WriteMapper extends DataMapperAbstract
|
||||||
*/
|
*/
|
||||||
private function createModel(object $obj, \ReflectionClass $refClass) : mixed
|
private function createModel(object $obj, \ReflectionClass $refClass) : mixed
|
||||||
{
|
{
|
||||||
$query = new Builder($this->db);
|
try {
|
||||||
$query->into($this->mapper::TABLE);
|
$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) {
|
foreach ($this->mapper::COLUMNS as $column) {
|
||||||
$propertyName = \stripos($column['internal'], '/') !== false
|
$propertyName = \stripos($column['internal'], '/') !== false
|
||||||
? \explode('/', $column['internal'])[0]
|
? \explode('/', $column['internal'])[0]
|
||||||
: $column['internal'];
|
: $column['internal'];
|
||||||
|
|
||||||
if (isset($this->mapper::HAS_MANY[$propertyName])
|
if (isset($this->mapper::HAS_MANY[$propertyName])
|
||||||
|| ($column['name'] === $this->mapper::PRIMARYFIELD && $this->mapper::AUTOINCREMENT)
|
|| ($column['name'] === $this->mapper::PRIMARYFIELD && $this->mapper::AUTOINCREMENT)
|
||||||
) {
|
) {
|
||||||
continue;
|
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, '/');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$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 a table only has a single column = primary key column. This must be done otherwise the query is empty
|
||||||
if ($query->getType() === QueryType::NONE) {
|
if ($query->getType() === QueryType::NONE) {
|
||||||
$query->insert($this->mapper::PRIMARYFIELD)->value(0);
|
$query->insert($this->mapper::PRIMARYFIELD)->value(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
$sth = $this->db->con->prepare($a = $query->toSql());
|
$sth = $this->db->con->prepare($a = $query->toSql());
|
||||||
$sth->execute();
|
$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) {
|
} catch (\Throwable $t) {
|
||||||
// @codeCoverageIgnoreStart
|
// @codeCoverageIgnoreStart
|
||||||
\var_dump($t->getMessage());
|
\var_dump($t->getMessage());
|
||||||
|
|
@ -171,11 +176,6 @@ final class WriteMapper extends DataMapperAbstract
|
||||||
return -1;
|
return -1;
|
||||||
// @codeCoverageIgnoreEND
|
// @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
|
public function createRelationTable(string $propertyName, array $objsIds, mixed $objId) : void
|
||||||
{
|
{
|
||||||
if (empty($objsIds) || !isset($this->mapper::HAS_MANY[$propertyName]['external'])) {
|
try {
|
||||||
return;
|
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$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());
|
$sth = $this->db->con->prepare($relQuery->toSql());
|
||||||
if ($sth !== false) {
|
if ($sth !== false) {
|
||||||
$sth->execute();
|
$sth->execute();
|
||||||
|
|
|
||||||
|
|
@ -37,14 +37,6 @@ class Builder extends BuilderAbstract
|
||||||
*/
|
*/
|
||||||
public static bool $log = false;
|
public static bool $log = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* Is read only.
|
|
||||||
*
|
|
||||||
* @var bool
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
protected bool $isReadOnly = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Columns.
|
* Columns.
|
||||||
*
|
*
|
||||||
|
|
@ -354,11 +346,7 @@ class Builder extends BuilderAbstract
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parsing to sql string.
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
*/
|
||||||
public function toSql() : string
|
public function toSql() : string
|
||||||
{
|
{
|
||||||
|
|
@ -386,7 +374,7 @@ class Builder extends BuilderAbstract
|
||||||
{
|
{
|
||||||
// create dependencies
|
// create dependencies
|
||||||
$dependencies = [];
|
$dependencies = [];
|
||||||
foreach ($this->joins as $table => $join) {
|
foreach ($this->joins as $table => $_) {
|
||||||
$dependencies[$table] = [];
|
$dependencies[$table] = [];
|
||||||
|
|
||||||
foreach ($this->ons[$table] as $on) {
|
foreach ($this->ons[$table] as $on) {
|
||||||
|
|
@ -1384,18 +1372,14 @@ class Builder extends BuilderAbstract
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute query.
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* @return ?\PDOStatement
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
*/
|
||||||
public function execute() : ?\PDOStatement
|
public function execute() : ?\PDOStatement
|
||||||
{
|
{
|
||||||
$sth = null;
|
$sth = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$sth = $this->connection->con->prepare($a = $this->toSql());
|
$sth = $this->connection->con->prepare($this->toSql());
|
||||||
if ($sth === false) {
|
if ($sth === false) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,12 +14,10 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace phpOMS\DataStorage\Database\Query\Grammar;
|
namespace phpOMS\DataStorage\Database\Query\Grammar;
|
||||||
|
|
||||||
use phpOMS\Contract\SerializableInterface;
|
use phpOMS\DataStorage\Database\BuilderAbstract;
|
||||||
use phpOMS\DataStorage\Database\GrammarAbstract;
|
use phpOMS\DataStorage\Database\GrammarAbstract;
|
||||||
use phpOMS\DataStorage\Database\Query\Builder;
|
use phpOMS\DataStorage\Database\Query\Builder;
|
||||||
use phpOMS\DataStorage\Database\Query\Column;
|
|
||||||
use phpOMS\DataStorage\Database\Query\From;
|
use phpOMS\DataStorage\Database\Query\From;
|
||||||
use phpOMS\DataStorage\Database\Query\Parameter;
|
|
||||||
use phpOMS\DataStorage\Database\Query\QueryType;
|
use phpOMS\DataStorage\Database\Query\QueryType;
|
||||||
use phpOMS\DataStorage\Database\Query\Where;
|
use phpOMS\DataStorage\Database\Query\Where;
|
||||||
|
|
||||||
|
|
@ -37,94 +35,113 @@ use phpOMS\DataStorage\Database\Query\Where;
|
||||||
*/
|
*/
|
||||||
class Grammar extends GrammarAbstract
|
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}
|
* {@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:
|
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:
|
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:
|
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:
|
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:
|
case QueryType::RANDOM:
|
||||||
return $this->randomComponents;
|
$sql[] = $this->compileRandom($query, $query->random);
|
||||||
|
|
||||||
|
break;
|
||||||
case queryType::NONE:
|
case queryType::NONE:
|
||||||
return [];
|
return [];
|
||||||
default:
|
default:
|
||||||
throw new \InvalidArgumentException('Unknown query type.');
|
throw new \InvalidArgumentException('Unknown query type.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -148,6 +165,11 @@ class Grammar extends GrammarAbstract
|
||||||
return ($query->distinct ? 'SELECT DISTINCT ' : 'SELECT ') . $expression;
|
return ($query->distinct ? 'SELECT DISTINCT ' : 'SELECT ') . $expression;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function compileRandom(Builder $query, array $columns) : string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compile select.
|
* Compile select.
|
||||||
*
|
*
|
||||||
|
|
@ -285,7 +307,7 @@ class Grammar extends GrammarAbstract
|
||||||
*/
|
*/
|
||||||
protected function compileWhereQuery(Where $where) : string
|
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
|
protected function compileFromQuery(From $from) : string
|
||||||
{
|
{
|
||||||
return $from->toSql();
|
return $from->toSql()[0];
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -538,8 +493,7 @@ class Grammar extends GrammarAbstract
|
||||||
*/
|
*/
|
||||||
protected function compileOrders(Builder $query, array $orders) : string
|
protected function compileOrders(Builder $query, array $orders) : string
|
||||||
{
|
{
|
||||||
$expression = '';
|
$expression = '';
|
||||||
$lastOrderType = '';
|
|
||||||
|
|
||||||
foreach ($orders as $column => $order) {
|
foreach ($orders as $column => $order) {
|
||||||
$expression .= $this->compileSystem($column) . ' ' . $order . ', ';
|
$expression .= $this->compileSystem($column) . ' ' . $order . ', ';
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace phpOMS\DataStorage\Database\Schema;
|
namespace phpOMS\DataStorage\Database\Schema;
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\BuilderAbstract;
|
||||||
use phpOMS\DataStorage\Database\Connection\ConnectionAbstract;
|
use phpOMS\DataStorage\Database\Connection\ConnectionAbstract;
|
||||||
use phpOMS\DataStorage\Database\Query\Builder as QueryBuilder;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database query builder.
|
* Database query builder.
|
||||||
|
|
@ -24,8 +24,10 @@ use phpOMS\DataStorage\Database\Query\Builder as QueryBuilder;
|
||||||
* @license OMS License 2.0
|
* @license OMS License 2.0
|
||||||
* @link https://jingga.app
|
* @link https://jingga.app
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
|
*
|
||||||
|
* @property \phpOMS\DataStorage\Database\Schema\Grammar $grammar Grammar.
|
||||||
*/
|
*/
|
||||||
class Builder extends QueryBuilder
|
class Builder extends BuilderAbstract
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Table to create.
|
* Table to create.
|
||||||
|
|
@ -109,6 +111,8 @@ class Builder extends QueryBuilder
|
||||||
*/
|
*/
|
||||||
public array $alterAdd = [];
|
public array $alterAdd = [];
|
||||||
|
|
||||||
|
public bool $hasPostQuery = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
|
|
@ -157,7 +161,8 @@ class Builder extends QueryBuilder
|
||||||
$builder->field(
|
$builder->field(
|
||||||
$name, $def['type'], $def['default'] ?? null,
|
$name, $def['type'], $def['default'] ?? null,
|
||||||
$def['null'] ?? true, $def['primary'] ?? false, $def['unique'] ?? false, $def['autoincrement'] ?? false,
|
$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 bool $autoincrement Autoincrements
|
||||||
* @param string $foreignTable Foreign table (in case of foreign key)
|
* @param string $foreignTable Foreign table (in case of foreign key)
|
||||||
* @param string $foreignKey Foreign key
|
* @param string $foreignKey Foreign key
|
||||||
|
* @param array $meta Meta data
|
||||||
*
|
*
|
||||||
* @return self
|
* @return self
|
||||||
*
|
*
|
||||||
|
|
@ -266,7 +272,7 @@ class Builder extends QueryBuilder
|
||||||
public function field(
|
public function field(
|
||||||
string $name, string $type, $default = null,
|
string $name, string $type, $default = null,
|
||||||
bool $isNullable = true, bool $isPrimary = false, bool $isUnique = false, bool $autoincrement = false,
|
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 {
|
) : self {
|
||||||
$this->createFields[$name] = [
|
$this->createFields[$name] = [
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
|
|
@ -278,6 +284,7 @@ class Builder extends QueryBuilder
|
||||||
'autoincrement' => $autoincrement,
|
'autoincrement' => $autoincrement,
|
||||||
'foreignTable' => $foreignTable,
|
'foreignTable' => $foreignTable,
|
||||||
'foreignKey' => $foreignKey,
|
'foreignKey' => $foreignKey,
|
||||||
|
'meta' => $meta,
|
||||||
];
|
];
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
@ -323,11 +330,41 @@ class Builder extends QueryBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parsing to string.
|
* {@inheritdoc}
|
||||||
*
|
*/
|
||||||
* @return string
|
public function execute() : ?\PDOStatement
|
||||||
*
|
{
|
||||||
* @since 1.0.0
|
$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
|
public function toSql() : string
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,8 @@ declare(strict_types=1);
|
||||||
namespace phpOMS\DataStorage\Database\Schema\Grammar;
|
namespace phpOMS\DataStorage\Database\Schema\Grammar;
|
||||||
|
|
||||||
use phpOMS\DataStorage\Database\BuilderAbstract;
|
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;
|
use phpOMS\DataStorage\Database\Schema\QueryType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -26,95 +27,101 @@ use phpOMS\DataStorage\Database\Schema\QueryType;
|
||||||
* @link https://jingga.app
|
* @link https://jingga.app
|
||||||
* @since 1.0.0
|
* @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}
|
* {@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:
|
case QueryType::DROP_DATABASE:
|
||||||
return $this->dropDatabaseComponents;
|
if (empty($query->dropDatabase)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql[] = $this->compileDropDatabase($query, $query->dropDatabase);
|
||||||
|
|
||||||
|
break;
|
||||||
case QueryType::TABLES:
|
case QueryType::TABLES:
|
||||||
return $this->tablesComponents;
|
if (empty($query->selectTables)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql[] = $this->compileSelectTables($query, $query->selectTables);
|
||||||
|
|
||||||
|
break;
|
||||||
case QueryType::FIELDS:
|
case QueryType::FIELDS:
|
||||||
return $this->fieldsComponents;
|
if (empty($query->selectFields)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql[] = $this->compileSelectFields($query, $query->selectFields);
|
||||||
|
|
||||||
|
break;
|
||||||
case QueryType::CREATE_TABLE:
|
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:
|
case QueryType::DROP_TABLE:
|
||||||
return $this->dropTableComponents;
|
if (empty($query->dropTable)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql[] = $this->compileDropTable($query, $query->dropTable);
|
||||||
|
|
||||||
|
break;
|
||||||
case QueryType::ALTER:
|
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:
|
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 [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@ namespace phpOMS\DataStorage\Database\Schema\Grammar;
|
||||||
|
|
||||||
use phpOMS\DataStorage\Database\BuilderAbstract;
|
use phpOMS\DataStorage\Database\BuilderAbstract;
|
||||||
use phpOMS\DataStorage\Database\Query\Builder;
|
use phpOMS\DataStorage\Database\Query\Builder;
|
||||||
|
use phpOMS\DataStorage\Database\Schema\Builder as SchemaBuilder;
|
||||||
|
use phpOMS\DataStorage\Database\Schema\QueryType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database query grammar.
|
* Database query grammar.
|
||||||
|
|
@ -43,6 +45,44 @@ class MysqlGrammar extends Grammar
|
||||||
*/
|
*/
|
||||||
public string $systemIdentifierEnd = '`';
|
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
|
* Compile remove
|
||||||
*
|
*
|
||||||
|
|
@ -63,14 +103,14 @@ class MysqlGrammar extends Grammar
|
||||||
/**
|
/**
|
||||||
* Compile from.
|
* Compile from.
|
||||||
*
|
*
|
||||||
* @param Builder $query Builder
|
* @param SchemaBuilder $query Builder
|
||||||
* @param array $table Tables
|
* @param array $table Tables
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @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 = new Builder($query->getConnection());
|
||||||
$builder->select('table_name')
|
$builder->select('table_name')
|
||||||
|
|
@ -83,14 +123,14 @@ class MysqlGrammar extends Grammar
|
||||||
/**
|
/**
|
||||||
* Compile from.
|
* Compile from.
|
||||||
*
|
*
|
||||||
* @param Builder $query Builder
|
* @param SchemaBuilder $query Builder
|
||||||
* @param string $table Tables
|
* @param string $table Tables
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @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 = new Builder($query->getConnection());
|
||||||
$builder->select('*')
|
$builder->select('*')
|
||||||
|
|
@ -104,14 +144,14 @@ class MysqlGrammar extends Grammar
|
||||||
/**
|
/**
|
||||||
* Compile create table fields query.
|
* Compile create table fields query.
|
||||||
*
|
*
|
||||||
* @param Builder $query Query
|
* @param SchemaBuilder $query Query
|
||||||
* @param array $fields Fields to create
|
* @param array $fields Fields to create
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected function compileCreateFields(Builder $query, array $fields) : string
|
protected function compileCreateFields(SchemaBuilder $query, array $fields) : string
|
||||||
{
|
{
|
||||||
$fieldQuery = '';
|
$fieldQuery = '';
|
||||||
$keys = '';
|
$keys = '';
|
||||||
|
|
@ -119,35 +159,37 @@ class MysqlGrammar extends Grammar
|
||||||
foreach ($fields as $name => $field) {
|
foreach ($fields as $name => $field) {
|
||||||
$fieldQuery .= ' ' . $this->expressionizeTableColumn([$name]) . ' ' . $field['type'];
|
$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']);
|
$fieldQuery .= ' DEFAULT ' . $this->compileValue($query, $field['default']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($field['null'])) {
|
if ($field['null'] ?? false) {
|
||||||
$fieldQuery .= ' ' . ($field['null'] ? '' : 'NOT ') . 'NULL';
|
$fieldQuery .= ' ' . ($field['null'] ? '' : 'NOT ') . 'NULL';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($field['autoincrement']) && $field['autoincrement']) {
|
if ($field['autoincrement'] ?? false) {
|
||||||
$fieldQuery .= ' AUTO_INCREMENT';
|
$fieldQuery .= ' AUTO_INCREMENT';
|
||||||
}
|
}
|
||||||
|
|
||||||
$fieldQuery .= ',';
|
$fieldQuery .= ',';
|
||||||
|
|
||||||
if (isset($field['primary']) && $field['primary']) {
|
if ($field['primary'] ?? false) {
|
||||||
$keys .= ' PRIMARY KEY (' . $this->expressionizeTableColumn([$name]) . '),';
|
$keys .= ' PRIMARY KEY (' . $this->expressionizeTableColumn([$name]) . '),';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($field['unique']) && $field['unique']) {
|
if ($field['unique'] ?? false) {
|
||||||
$keys .= ' UNIQUE KEY (' . $this->expressionizeTableColumn([$name]) . '),';
|
$keys .= ' UNIQUE KEY (' . $this->expressionizeTableColumn([$name]) . '),';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($field['foreignTable'], $field['foreignKey'])
|
if (isset($field['foreignTable'], $field['foreignKey'])) {
|
||||||
&& !empty($field['foreignTable']) && !empty($field['foreignKey'])
|
|
||||||
) {
|
|
||||||
$keys .= ' FOREIGN KEY (' . $this->expressionizeTableColumn([$name]) . ') REFERENCES '
|
$keys .= ' FOREIGN KEY (' . $this->expressionizeTableColumn([$name]) . ') REFERENCES '
|
||||||
. $this->expressionizeTableColumn([$field['foreignTable']])
|
. $this->expressionizeTableColumn([$field['foreignTable']])
|
||||||
. ' (' . $this->expressionizeTableColumn([$field['foreignKey']]) . '),';
|
. ' (' . $this->expressionizeTableColumn([$field['foreignKey']]) . '),';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($field['meta']['multi_autoincrement'])) {
|
||||||
|
$query->hasPostQuery = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return '(' . \ltrim(\rtrim($fieldQuery . $keys, ','), ' ') . ')';
|
return '(' . \ltrim(\rtrim($fieldQuery . $keys, ','), ' ') . ')';
|
||||||
|
|
|
||||||
|
|
@ -286,6 +286,8 @@ abstract class RequestAbstract implements MessageInterface
|
||||||
/**
|
/**
|
||||||
* Check if has data.
|
* Check if has data.
|
||||||
*
|
*
|
||||||
|
* The following empty values are considered as not set (null, '', 0)
|
||||||
|
*
|
||||||
* @param string $key Data key
|
* @param string $key Data key
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
|
|
@ -296,7 +298,10 @@ abstract class RequestAbstract implements MessageInterface
|
||||||
{
|
{
|
||||||
$key = \mb_strtolower($key);
|
$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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,11 @@ abstract class InstallerAbstract
|
||||||
|
|
||||||
/** @var array[] $definitions */
|
/** @var array[] $definitions */
|
||||||
$definitions = \json_decode($content, true);
|
$definitions = \json_decode($content, true);
|
||||||
|
|
||||||
|
if (!\is_array($definitions)) {
|
||||||
|
return; // @codeCoverageIgnore
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($definitions as $definition) {
|
foreach ($definitions as $definition) {
|
||||||
SchemaBuilder::createFromSchema($definition, $dbPool->get('schema'))->execute();
|
SchemaBuilder::createFromSchema($definition, $dbPool->get('schema'))->execute();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -293,10 +293,12 @@ final class ModuleManager
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
public function getAvailableModules() : array
|
public function getAvailableModules() : array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all installed modules.
|
* Get all installed modules.
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
||||||
use phpOMS\Account\AccountStatus;
|
use phpOMS\Account\AccountStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox phpOMS\tests\Account\AccountStatus: Account status
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class AccountStatusTest extends \PHPUnit\Framework\TestCase
|
final class AccountStatusTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* @testdoxThe account status enum has the correct number of status codes
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
@ -33,6 +35,7 @@ final class AccountStatusTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox The account status enum has only unique values
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
@ -42,6 +45,7 @@ final class AccountStatusTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox The account status enum has the correct values
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -245,7 +245,7 @@ final class AccountTest extends \PHPUnit\Framework\TestCase
|
||||||
$account->addPermission(new class() extends PermissionAbstract {});
|
$account->addPermission(new class() extends PermissionAbstract {});
|
||||||
self::assertCount(1, $account->getPermissions());
|
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));
|
self::assertTrue($account->hasPermission(PermissionType::NONE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
||||||
use phpOMS\Account\AccountType;
|
use phpOMS\Account\AccountType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox phpOMS\tests\Account\AccountType: Account type
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class AccountTypeTest extends \PHPUnit\Framework\TestCase
|
final class AccountTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* @testdox The account type enum has the correct number of type codes
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
@ -33,6 +35,7 @@ final class AccountTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox The account type enum has only unique values
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
@ -42,6 +45,7 @@ final class AccountTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox The account type enum has the correct values
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
||||||
use phpOMS\Account\GroupStatus;
|
use phpOMS\Account\GroupStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox phpOMS\tests\Account\GroupStatus: Group status
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class GroupStatusTest extends \PHPUnit\Framework\TestCase
|
final class GroupStatusTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* @testdox The group status enum has the correct number of status codes
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
@ -33,6 +35,7 @@ final class GroupStatusTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox The group status enum has only unique values
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
@ -42,6 +45,7 @@ final class GroupStatusTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox The group status enum has the correct values
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
||||||
use phpOMS\Account\NullAccount;
|
use phpOMS\Account\NullAccount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox phpOMS\tests\Account\NullAccount: Null account
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class NullAccountTest extends \PHPUnit\Framework\TestCase
|
final class NullAccountTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* @testdox The null account is an instance of the account class
|
||||||
* @covers phpOMS\Account\NullAccount
|
* @covers phpOMS\Account\NullAccount
|
||||||
* @group framework
|
* @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
|
* @covers phpOMS\Account\NullAccount
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -19,16 +19,29 @@ require_once __DIR__ . '/../Autoloader.php';
|
||||||
use phpOMS\Account\NullGroup;
|
use phpOMS\Account\NullGroup;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox phpOMS\tests\Account\NullGroup: Null group
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class NullGroupTest extends \PHPUnit\Framework\TestCase
|
final class NullGroupTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* @testdox The null group is an instance of the group class
|
||||||
* @covers phpOMS\Account\NullGroup
|
* @covers phpOMS\Account\NullGroup
|
||||||
* @group module
|
* @group framework
|
||||||
*/
|
*/
|
||||||
public function testNull() : void
|
public function testNull() : void
|
||||||
{
|
{
|
||||||
self::assertInstanceOf('\phpOMS\Account\Group', new NullGroup());
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -86,8 +86,8 @@ final class PermissionAbstractTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
$perm = new class() extends PermissionAbstract {};
|
$perm = new class() extends PermissionAbstract {};
|
||||||
|
|
||||||
$perm->setApp('Test');
|
$perm->setApp(2);
|
||||||
self::assertEquals('Test', $perm->getApp());
|
self::assertEquals(2, $perm->getApp());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
||||||
use phpOMS\Account\PermissionType;
|
use phpOMS\Account\PermissionType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox phpOMS\tests\Account\PermissionType: Permission type
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class PermissionTypeTest extends \PHPUnit\Framework\TestCase
|
final class PermissionTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* @testdox The permission type enum has the correct number of type codes
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
@ -33,6 +35,7 @@ final class PermissionTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox The permission type enum has only unique values
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
@ -42,6 +45,7 @@ final class PermissionTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox The permission type enum has the correct values
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ use phpOMS\Application\ApplicationInfo;
|
||||||
final class ApplicationInfoTest extends \PHPUnit\Framework\TestCase
|
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
|
* @covers phpOMS\Application\ApplicationInfo
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -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\ApplicationManager
|
||||||
* @covers phpOMS\Application\InstallerAbstract
|
* @covers phpOMS\Application\InstallerAbstract
|
||||||
* @covers phpOMS\Application\StatusAbstract
|
* @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
|
* @testdox A module can be re-initialized
|
||||||
* @covers phpOMS\Application\ApplicationManager
|
* @covers phpOMS\Application\ApplicationManager
|
||||||
* @covers phpOMS\Application\InstallerAbstract
|
* @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
|
* @covers phpOMS\Application\ApplicationManager
|
||||||
* @group framework
|
* @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
|
* @covers phpOMS\Application\ApplicationManager
|
||||||
* @group framework
|
* @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
|
* @covers phpOMS\Application\ApplicationManager
|
||||||
* @group framework
|
* @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
|
* @covers phpOMS\Application\ApplicationManager
|
||||||
* @group framework
|
* @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
|
* @covers phpOMS\Application\ApplicationManager
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ require_once __DIR__ . '/../Autoloader.php';
|
||||||
use phpOMS\Application\InstallerAbstract;
|
use phpOMS\Application\InstallerAbstract;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox phpOMS\tests\Application\InstallerAbstractTest: Application installer
|
* @testdox phpOMS\tests\Application\InstallerAbstractTest: Abstract application installer
|
||||||
*
|
*
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
|
|
@ -38,6 +38,7 @@ final class InstallerAbstractTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox An invalid theme cannot be installed
|
||||||
* @covers phpOMS\Application\InstallerAbstract
|
* @covers phpOMS\Application\InstallerAbstract
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ require_once __DIR__ . '/../Autoloader.php';
|
||||||
use phpOMS\Application\StatusAbstract;
|
use phpOMS\Application\StatusAbstract;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox phpOMS\tests\Application\StatusAbstractTest: Application status
|
* @testdox phpOMS\tests\Application\StatusAbstractTest: Abstract application status
|
||||||
*
|
*
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
|
|
@ -39,6 +39,7 @@ final class StatusAbstractTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox A invalid application path cannot be activated
|
||||||
* @covers phpOMS\Application\StatusAbstract
|
* @covers phpOMS\Application\StatusAbstract
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ use phpOMS\Application\UninstallerAbstract;
|
||||||
use phpOMS\DataStorage\Database\DatabasePool;
|
use phpOMS\DataStorage\Database\DatabasePool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox phpOMS\tests\Application\UninstallerAbstractTest: Abstract module
|
* @testdox phpOMS\tests\Application\UninstallerAbstractTest: Abstract application uninstaller
|
||||||
*
|
*
|
||||||
* @internal
|
* @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
|
* @covers phpOMS\Application\UninstallerAbstract
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
||||||
use phpOMS\Asset\AssetType;
|
use phpOMS\Asset\AssetType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox phpOMS\tests\Asset\AssetType: Asset type
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class AssetTypeTest extends \PHPUnit\Framework\TestCase
|
final class AssetTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* @testdox The asset type enum has the correct number of status codes
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
@ -33,6 +35,7 @@ final class AssetTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox The asset type enum has only unique values
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
@ -42,6 +45,7 @@ final class AssetTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox The asset type enum has the correct values
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
||||||
use phpOMS\Auth\LoginReturnType;
|
use phpOMS\Auth\LoginReturnType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox phpOMS\tests\Auth\LoginReturnType: Login return type
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class LoginReturnTypeTest extends \PHPUnit\Framework\TestCase
|
final class LoginReturnTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* @testdox The login return type enum has the correct number of type codes
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
@ -33,6 +35,7 @@ final class LoginReturnTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox The login return type enum has only unique values
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
@ -42,6 +45,7 @@ final class LoginReturnTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox The login return type enum has the correct values
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -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
|
* @covers phpOMS\Business\Finance\FinanceFormulas
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ use phpOMS\DataStorage\Cache\Connection\RedisCache;
|
||||||
use phpOMS\Utils\TestUtils;
|
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
|
* @internal
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
||||||
use phpOMS\DataStorage\LockException;
|
use phpOMS\DataStorage\LockException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox phpOMS\tests\DataStorage\LockExceptionTest: Lock exception
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class LockExceptionTest extends \PHPUnit\Framework\TestCase
|
final class LockExceptionTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* @testdox The lock exception is an instance of the runtime exception
|
||||||
* @covers phpOMS\DataStorage\LockException
|
* @covers phpOMS\DataStorage\LockException
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -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
|
* @covers phpOMS\Dispatcher\Dispatcher
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
|
|
@ -57,13 +57,18 @@ final class DispatcherTest extends \PHPUnit\Framework\TestCase
|
||||||
self::assertObjectHasAttribute('controllers', $this->app->dispatcher);
|
self::assertObjectHasAttribute('controllers', $this->app->dispatcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @testdox A route can be added and dispatched
|
||||||
|
* @covers phpOMS\Dispatcher\Dispatcher
|
||||||
|
* @group framework
|
||||||
|
*/
|
||||||
public function testControllerInputOutput() : void
|
public function testControllerInputOutput() : void
|
||||||
{
|
{
|
||||||
$this->app->dispatcher->set(new class() extends ModuleAbstract {
|
$this->app->dispatcher->set(new class() extends ModuleAbstract {
|
||||||
public string $name = 'test';
|
public string $name = 'test';
|
||||||
|
|
||||||
public function testFunction() { return $this->name; }
|
public function testFunction() { return $this->name; }
|
||||||
}, 'test');
|
}, 'test');
|
||||||
|
|
||||||
$localization = new Localization();
|
$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
|
* @covers phpOMS\Dispatcher\Dispatcher
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -19,18 +19,24 @@ require_once __DIR__ . '/../Autoloader.php';
|
||||||
use phpOMS\Image\Kernel;
|
use phpOMS\Image\Kernel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox phpOMS\tests\Image\KernelTest: Image kernel
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class KernelTest extends \PHPUnit\Framework\TestCase
|
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
|
* @group framework
|
||||||
* @coversNothing
|
* @covers phpOMS\Image\Kernel
|
||||||
*/
|
*/
|
||||||
public function testKernel() : void
|
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_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_blur.png', Kernel::KERNEL_GAUSSUAN_BLUR_3);
|
||||||
Kernel::convolve(__DIR__ . '/img1.png', __DIR__ . '/test_img1_emboss.png', Kernel::KERNEL_EMBOSS);
|
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'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,13 +19,15 @@ require_once __DIR__ . '/../Autoloader.php';
|
||||||
use phpOMS\Image\Skew;
|
use phpOMS\Image\Skew;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox phpOMS\tests\Image\SkewTest: Image skew
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class SkewTest extends \PHPUnit\Framework\TestCase
|
final class SkewTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* @testdox A image can be automatically unskewed
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @covers phpOMS\Image\Skew
|
||||||
*/
|
*/
|
||||||
public function testSkew() : void
|
public function testSkew() : void
|
||||||
{
|
{
|
||||||
|
|
@ -39,5 +41,7 @@ final class SkewTest extends \PHPUnit\Framework\TestCase
|
||||||
[150, 75],
|
[150, 75],
|
||||||
[1700, 900]
|
[1700, 900]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
self::assertTrue(\is_file(__DIR__ . '/test_binary_untilted.png'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,17 +19,22 @@ require_once __DIR__ . '/../Autoloader.php';
|
||||||
use phpOMS\Image\Thresholding;
|
use phpOMS\Image\Thresholding;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox phpOMS\tests\Image\ThresholdingTest: Image thresholding
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class ThresholdingTest extends \PHPUnit\Framework\TestCase
|
final class ThresholdingTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* @testdox The thresholding is correctly applied to the image
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @covers phpOMS\Image\Thresholding
|
||||||
*/
|
*/
|
||||||
public function testThresholding() : void
|
public function testThresholding() : void
|
||||||
{
|
{
|
||||||
Thresholding::integralThresholding(__DIR__ . '/img1.png', __DIR__ . '/test_img1_integral_thresholding.png');
|
Thresholding::integralThresholding(__DIR__ . '/img1.png', __DIR__ . '/test_img1_integral_thresholding.png');
|
||||||
Thresholding::integralThresholding(__DIR__ . '/img2.jpg', __DIR__ . '/test_img2_integral_thresholding.jpg');
|
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'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,6 @@ final class CityMapperTest extends \PHPUnit\Framework\TestCase
|
||||||
public static function setUpBeforeClass() : void
|
public static function setUpBeforeClass() : void
|
||||||
{
|
{
|
||||||
$con = new SqliteConnection([
|
$con = new SqliteConnection([
|
||||||
'prefix' => '',
|
|
||||||
'db' => 'sqlite',
|
'db' => 'sqlite',
|
||||||
'database' => \realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'),
|
'database' => \realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'),
|
||||||
]);
|
]);
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,6 @@ final class CountryMapperTest extends \PHPUnit\Framework\TestCase
|
||||||
public static function setUpBeforeClass() : void
|
public static function setUpBeforeClass() : void
|
||||||
{
|
{
|
||||||
$con = new SqliteConnection([
|
$con = new SqliteConnection([
|
||||||
'prefix' => '',
|
|
||||||
'db' => 'sqlite',
|
'db' => 'sqlite',
|
||||||
'database' => \realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'),
|
'database' => \realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'),
|
||||||
]);
|
]);
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,6 @@ final class CurrencyMapperTest extends \PHPUnit\Framework\TestCase
|
||||||
public static function setUpBeforeClass() : void
|
public static function setUpBeforeClass() : void
|
||||||
{
|
{
|
||||||
$con = new SqliteConnection([
|
$con = new SqliteConnection([
|
||||||
'prefix' => '',
|
|
||||||
'db' => 'sqlite',
|
'db' => 'sqlite',
|
||||||
'database' => \realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'),
|
'database' => \realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'),
|
||||||
]);
|
]);
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,6 @@ final class IbanMapperTest extends \PHPUnit\Framework\TestCase
|
||||||
public static function setUpBeforeClass() : void
|
public static function setUpBeforeClass() : void
|
||||||
{
|
{
|
||||||
$con = new SqliteConnection([
|
$con = new SqliteConnection([
|
||||||
'prefix' => '',
|
|
||||||
'db' => 'sqlite',
|
'db' => 'sqlite',
|
||||||
'database' => \realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'),
|
'database' => \realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'),
|
||||||
]);
|
]);
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,6 @@ final class LanguageMapperTest extends \PHPUnit\Framework\TestCase
|
||||||
public static function setUpBeforeClass() : void
|
public static function setUpBeforeClass() : void
|
||||||
{
|
{
|
||||||
$con = new SqliteConnection([
|
$con = new SqliteConnection([
|
||||||
'prefix' => '',
|
|
||||||
'db' => 'sqlite',
|
'db' => 'sqlite',
|
||||||
'database' => \realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'),
|
'database' => \realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'),
|
||||||
]);
|
]);
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
||||||
use phpOMS\Localization\ISO3166CharEnum;
|
use phpOMS\Localization\ISO3166CharEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox phpOMS\tests\Localization\ISO3166CharEnumTest: ISO 3166 country codes
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class ISO3166CharEnumTest extends \PHPUnit\Framework\TestCase
|
final class ISO3166CharEnumTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* @testdox The ISO 3166 country code enum has the correct format of country codes
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
@ -41,6 +43,15 @@ final class ISO3166CharEnumTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
self::assertTrue($ok);
|
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()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,15 +19,17 @@ require_once __DIR__ . '/../Autoloader.php';
|
||||||
use phpOMS\Localization\ISO3166NameEnum;
|
use phpOMS\Localization\ISO3166NameEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox phpOMS\tests\Localization\ISO3166NameEnumTest: ISO 3166 country names
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class ISO3166NameEnumTest extends \PHPUnit\Framework\TestCase
|
final class ISO3166NameEnumTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* @testdox The ISO 3166 enum has only unique values
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
public function testEnums() : void
|
public function testUnique() : void
|
||||||
{
|
{
|
||||||
$enum = ISO3166NameEnum::getConstants();
|
$enum = ISO3166NameEnum::getConstants();
|
||||||
self::assertEquals(\count($enum), \count(\array_unique($enum)));
|
self::assertEquals(\count($enum), \count(\array_unique($enum)));
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
||||||
use phpOMS\Localization\ISO3166NumEnum;
|
use phpOMS\Localization\ISO3166NumEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox phpOMS\tests\Localization\ISO3166NumEnumTest: ISO 3166 country codes
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class ISO3166NumEnumTest extends \PHPUnit\Framework\TestCase
|
final class ISO3166NumEnumTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* @testdox The ISO 3166 country code enum has the correct format of country codes
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
@ -41,6 +43,15 @@ final class ISO3166NumEnumTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
self::assertTrue($ok);
|
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()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
||||||
use phpOMS\Localization\ISO3166TwoEnum;
|
use phpOMS\Localization\ISO3166TwoEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox phpOMS\tests\Localization\ISO3166NumEnumTest: ISO 3166 country codes
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class ISO3166TwoEnumTest extends \PHPUnit\Framework\TestCase
|
final class ISO3166TwoEnumTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* @testdox The ISO 3166 country code enum has the correct format of country codes
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
@ -41,6 +43,15 @@ final class ISO3166TwoEnumTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
self::assertTrue($ok);
|
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()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
||||||
use phpOMS\Localization\ISO4217CharEnum;
|
use phpOMS\Localization\ISO4217CharEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox phpOMS\tests\Localization\ISO4217CharEnumTest: ISO 4217 currency codes
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class ISO4217CharEnumTest extends \PHPUnit\Framework\TestCase
|
final class ISO4217CharEnumTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* @testdox The ISO 4217 currency code enum has the correct format of currency codes
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
@ -41,6 +43,15 @@ final class ISO4217CharEnumTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
self::assertTrue($ok);
|
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()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
||||||
use phpOMS\Localization\ISO4217DecimalEnum;
|
use phpOMS\Localization\ISO4217DecimalEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox phpOMS\tests\Localization\ISO4217DecimalEnumTest: ISO 4217 currency codes
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class ISO4217DecimalEnumTest extends \PHPUnit\Framework\TestCase
|
final class ISO4217DecimalEnumTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* @testdox The ISO 4217 currency code enum has the correct format of currency decimal places
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -19,15 +19,17 @@ require_once __DIR__ . '/../Autoloader.php';
|
||||||
use phpOMS\Localization\ISO4217Enum;
|
use phpOMS\Localization\ISO4217Enum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox phpOMS\tests\Localization\ISO4217EnumTest: ISO 4217 currency codes
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class ISO4217EnumTest extends \PHPUnit\Framework\TestCase
|
final class ISO4217EnumTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* @testdox The ISO 4217 currency code enum has only unique values
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
public function testEnums() : void
|
public function testUnique() : void
|
||||||
{
|
{
|
||||||
$enum = ISO4217Enum::getConstants();
|
$enum = ISO4217Enum::getConstants();
|
||||||
self::assertEquals(\count($enum), \count(\array_unique($enum)));
|
self::assertEquals(\count($enum), \count(\array_unique($enum)));
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
||||||
use phpOMS\Localization\ISO4217NumEnum;
|
use phpOMS\Localization\ISO4217NumEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox phpOMS\tests\Localization\ISO4217NumEnumTest: ISO 4217 currency codes
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class ISO4217NumEnumTest extends \PHPUnit\Framework\TestCase
|
final class ISO4217NumEnumTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* @testdox The ISO 4217 currency code enum has the correct format of currency codes
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
@ -41,6 +43,15 @@ final class ISO4217NumEnumTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
self::assertTrue($ok);
|
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()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
||||||
use phpOMS\Localization\ISO4217SubUnitEnum;
|
use phpOMS\Localization\ISO4217SubUnitEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox phpOMS\tests\Localization\ISO4217SubUnitEnumTest: ISO 4217 currency codes
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class ISO4217SubUnitEnumTest extends \PHPUnit\Framework\TestCase
|
final class ISO4217SubUnitEnumTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* @testdox The ISO 4217 currency code enum has the correct format of currency sub units
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
||||||
use phpOMS\Localization\ISO4217SymbolEnum;
|
use phpOMS\Localization\ISO4217SymbolEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox phpOMS\tests\Localization\ISO4217SymbolEnumTest: ISO 4217 currency codes
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class ISO4217SymbolEnumTest extends \PHPUnit\Framework\TestCase
|
final class ISO4217SymbolEnumTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* @testdox The ISO 4217 currency code enum has the correct number of currency symbols
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -19,15 +19,17 @@ require_once __DIR__ . '/../Autoloader.php';
|
||||||
use phpOMS\Localization\ISO639Enum;
|
use phpOMS\Localization\ISO639Enum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox phpOMS\tests\Localization\ISO639EnumTest: ISO 639 language codes
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class ISO639EnumTest extends \PHPUnit\Framework\TestCase
|
final class ISO639EnumTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* @testdox The ISO 639 language code enum has only unique values
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
public function testEnums() : void
|
public function testUnique() : void
|
||||||
{
|
{
|
||||||
$enum = ISO639Enum::getConstants();
|
$enum = ISO639Enum::getConstants();
|
||||||
self::assertEquals(\count($enum), \count(\array_unique($enum)));
|
self::assertEquals(\count($enum), \count(\array_unique($enum)));
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
||||||
use phpOMS\Localization\ISO639x1Enum;
|
use phpOMS\Localization\ISO639x1Enum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox phpOMS\tests\Localization\ISO639x1EnumTest: ISO 639-1 language codes
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class ISO639x1EnumTest extends \PHPUnit\Framework\TestCase
|
final class ISO639x1EnumTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* @testdox The ISO 639-1 language code enum has the correct format of language codes
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
@ -41,6 +43,15 @@ final class ISO639x1EnumTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
self::assertTrue($ok);
|
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()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
||||||
use phpOMS\Localization\ISO639x2Enum;
|
use phpOMS\Localization\ISO639x2Enum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox phpOMS\tests\Localization\ISO639x2EnumTest: ISO 639-2 language codes
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class ISO639x2EnumTest extends \PHPUnit\Framework\TestCase
|
final class ISO639x2EnumTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* @testdox The ISO 639-2 language code enum has the correct format of language codes
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
@ -41,6 +43,15 @@ final class ISO639x2EnumTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
self::assertTrue($ok);
|
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()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
||||||
use phpOMS\Localization\ISO8601EnumArray;
|
use phpOMS\Localization\ISO8601EnumArray;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox phpOMS\tests\Localization\ISO8601EnumArrayTest: ISO 8601 date time formats
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class ISO8601EnumArrayTest extends \PHPUnit\Framework\TestCase
|
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
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
@ -31,4 +33,14 @@ final class ISO8601EnumArrayTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
self::assertCount(4, ISO8601EnumArray::getConstants());
|
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()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ require_once __DIR__ . '/../Autoloader.php';
|
||||||
final class L11nManagerTest extends \PHPUnit\Framework\TestCase
|
final class L11nManagerTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
protected L11nManager $l11nManager;
|
protected L11nManager $l11nManager;
|
||||||
|
protected L11nManager $l11nManager2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@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
|
* @covers phpOMS\Localization\L11nManager
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
||||||
use phpOMS\Localization\PhoneEnum;
|
use phpOMS\Localization\PhoneEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox phpOMS\tests\Localization\PhoneEnumTest: Country phone codes
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class PhoneEnumTest extends \PHPUnit\Framework\TestCase
|
final class PhoneEnumTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* @testdox The phone enum has the correct format of country phone numbers
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -19,15 +19,17 @@ require_once __DIR__ . '/../Autoloader.php';
|
||||||
use phpOMS\Localization\TimeZoneEnumArray;
|
use phpOMS\Localization\TimeZoneEnumArray;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox phpOMS\tests\Localization\TimeZoneEnumArrayTest: Time zone enum array
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class TimeZoneEnumArrayTest extends \PHPUnit\Framework\TestCase
|
final class TimeZoneEnumArrayTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* @testdox The time zone enum array has only unique values
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
public function testEnums() : void
|
public function testUnique() : void
|
||||||
{
|
{
|
||||||
self::assertEquals(\count(TimeZoneEnumArray::getConstants()), \count(\array_unique(TimeZoneEnumArray::getConstants())));
|
self::assertEquals(\count(TimeZoneEnumArray::getConstants()), \count(\array_unique(TimeZoneEnumArray::getConstants())));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
||||||
use phpOMS\Log\LogLevel;
|
use phpOMS\Log\LogLevel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox phpOMS\tests\Log\LogLevelTest: Log level enum
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class LogLevelTest extends \PHPUnit\Framework\TestCase
|
final class LogLevelTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* @testdox The log level enum has the correct number of log levels
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
@ -33,6 +35,7 @@ final class LogLevelTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox The log level enum has only unique values
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
@ -42,6 +45,7 @@ final class LogLevelTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox The log level enum has the correct values
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ use phpOMS\Module\InstallerAbstract;
|
||||||
use phpOMS\Module\ModuleInfo;
|
use phpOMS\Module\ModuleInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox phpOMS\tests\Module\InstallerAbstractTest: Abstract module
|
* @testdox phpOMS\tests\Module\InstallerAbstractTest: Abstract module installer
|
||||||
*
|
*
|
||||||
* @internal
|
* @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
|
* @covers phpOMS\Module\InstallerAbstract
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -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<extended>
|
* @covers phpOMS\Module\ModuleAbstract<extended>
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
|
|
@ -459,6 +459,11 @@ final class ModuleAbstractTest extends \PHPUnit\Framework\TestCase
|
||||||
$this->dbTeardown();
|
$this->dbTeardown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @testdox The model CRUD functions can be called with a closure
|
||||||
|
* @covers phpOMS\Module\ModuleAbstract<extended>
|
||||||
|
* @group framework
|
||||||
|
*/
|
||||||
public function testModelFunctionsWithClosure() : void
|
public function testModelFunctionsWithClosure() : void
|
||||||
{
|
{
|
||||||
$output = $this->module->createWithCallable();
|
$output = $this->module->createWithCallable();
|
||||||
|
|
|
||||||
|
|
@ -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
|
* @covers phpOMS\Module\ModuleManager
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
|
|
@ -251,6 +251,11 @@ final class ModuleManagerTest extends \PHPUnit\Framework\TestCase
|
||||||
self::assertTrue($this->moduleManager->isRunning('TestModule'));
|
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
|
public function testGetLanguageForInvalidRequest() : void
|
||||||
{
|
{
|
||||||
$request = new HttpRequest(new HttpUri('http://127.0.0.1/en/error/invalid'));
|
$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));
|
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
|
* @testdox Installed modules can be returned
|
||||||
* @covers phpOMS\Module\ModuleManager
|
* @covers phpOMS\Module\ModuleManager
|
||||||
|
|
@ -279,21 +278,26 @@ final class ModuleManagerTest extends \PHPUnit\Framework\TestCase
|
||||||
self::assertNotEmpty($installed);
|
self::assertNotEmpty($installed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @testdox A module can be checked if it is installed
|
||||||
|
* @covers phpOMS\Module\ModuleManager
|
||||||
|
* @group framework
|
||||||
|
*/
|
||||||
public function testIsInstalled() : void
|
public function testIsInstalled() : void
|
||||||
{
|
{
|
||||||
self::assertTrue($this->moduleManager->isInstalled('TestModule'));
|
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
|
public function testInstallingAlreadyInstalledModule() : void
|
||||||
{
|
{
|
||||||
self::assertTrue($this->moduleManager->install('TestModule'));
|
self::assertTrue($this->moduleManager->install('TestModule'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAvailableModules() : void
|
|
||||||
{
|
|
||||||
self::assertEquals([], $this->moduleManager->getAvailableModules());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox The valid module can be returned
|
* @testdox The valid module can be returned
|
||||||
* @covers phpOMS\Module\ModuleManager
|
* @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
|
* @covers phpOMS\Module\ModuleManager
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
|
|
@ -334,9 +339,11 @@ final class ModuleManagerTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
self::assertEquals([], $moduleManager->getAllModules());
|
self::assertEquals([], $moduleManager->getAllModules());
|
||||||
self::assertEquals([], $moduleManager->getInstalledModules());
|
self::assertEquals([], $moduleManager->getInstalledModules());
|
||||||
|
self::assertEquals([], $moduleManager->getActiveModules(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox A invalid module name cannot be installed
|
||||||
* @covers phpOMS\Module\ModuleManager
|
* @covers phpOMS\Module\ModuleManager
|
||||||
* @group framework
|
* @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
|
* @covers phpOMS\Module\ModuleManager
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -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
|
* @group framework
|
||||||
*/
|
*/
|
||||||
public function testModule() : void
|
public function testModule() : void
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ use phpOMS\Module\ModuleInfo;
|
||||||
use phpOMS\Module\StatusAbstract;
|
use phpOMS\Module\StatusAbstract;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox phpOMS\tests\Module\StatusAbstractTest: Abstract module
|
* @testdox phpOMS\tests\Module\StatusAbstractTest: Abstract module status
|
||||||
*
|
*
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
|
|
@ -40,6 +40,7 @@ final class StatusAbstractTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* A invalid module path cannot be activated
|
||||||
* @covers phpOMS\Module\StatusAbstract
|
* @covers phpOMS\Module\StatusAbstract
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ use phpOMS\Module\ModuleInfo;
|
||||||
use phpOMS\Module\UninstallerAbstract;
|
use phpOMS\Module\UninstallerAbstract;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox phpOMS\tests\Module\UninstallerAbstractTest: Abstract module
|
* @testdox phpOMS\tests\Module\UninstallerAbstractTest: Abstract module uninstaller
|
||||||
*
|
*
|
||||||
* @internal
|
* @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
|
* @covers phpOMS\Module\UninstallerAbstract
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
||||||
use phpOMS\Router\RouteVerb;
|
use phpOMS\Router\RouteVerb;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox phpOMS\tests\WebRouter\RouteVerbTest: Route verb enum
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class RouteVerbTest extends \PHPUnit\Framework\TestCase
|
final class RouteVerbTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* @testdox The route verb enum has the correct values
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
@ -37,10 +39,11 @@ final class RouteVerbTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox The route verb enum has only unique values
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
public function testEnumUnique() : void
|
public function testUnique() : void
|
||||||
{
|
{
|
||||||
$values = RouteVerb::getConstants();
|
$values = RouteVerb::getConstants();
|
||||||
self::assertEquals(\count($values), \array_sum(\array_count_values($values)));
|
self::assertEquals(\count($values), \array_sum(\array_count_values($values)));
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
||||||
use phpOMS\System\CharsetType;
|
use phpOMS\System\CharsetType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox phpOMS\tests\System\CharsetTypeTest: Character set type enum
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class CharsetTypeTest extends \PHPUnit\Framework\TestCase
|
final class CharsetTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* @testdox The character set type enum has the correct amount of values
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
@ -33,6 +35,7 @@ final class CharsetTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox The character set type enum has only unique values
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
@ -42,6 +45,7 @@ final class CharsetTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox The character set type enum has the correct values
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
||||||
use phpOMS\System\MimeType;
|
use phpOMS\System\MimeType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox phpOMS\tests\System\MimeTypeTest: MimeType
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class MimeTypeTest extends \PHPUnit\Framework\TestCase
|
final class MimeTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* @testdox The mime type enum vales have the correct format
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
@ -31,7 +33,7 @@ final class MimeTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
$enums = MimeType::getConstants();
|
$enums = MimeType::getConstants();
|
||||||
|
|
||||||
foreach ($enums as $key => $value) {
|
foreach ($enums as $value) {
|
||||||
if (\stripos($value, '/') === false) {
|
if (\stripos($value, '/') === false) {
|
||||||
self::assertFalse(true);
|
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
|
* @covers phpOMS\System\MimeType
|
||||||
* @group framework
|
* @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
|
* @covers phpOMS\System\MimeType
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,13 @@ use phpOMS\System\OperatingSystem;
|
||||||
use phpOMS\System\SystemType;
|
use phpOMS\System\SystemType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox phpOMS\tests\System\OperatingSystemTest: Operating system
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class OperatingSystemTest extends \PHPUnit\Framework\TestCase
|
final class OperatingSystemTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* @testdox The current operating system can be returned
|
||||||
* @covers phpOMS\System\OperatingSystem
|
* @covers phpOMS\System\OperatingSystem
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
||||||
use phpOMS\System\SystemType;
|
use phpOMS\System\SystemType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox phpOMS\tests\System\SystemTypeTest: System type
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class SystemTypeTest extends \PHPUnit\Framework\TestCase
|
final class SystemTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* @testdox The system type enum has the correct amount of values
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
@ -33,6 +35,7 @@ final class SystemTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox The system type enum has only unique values
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
@ -42,6 +45,7 @@ final class SystemTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox The system type enum has the correct values
|
||||||
* @group framework
|
* @group framework
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,7 @@ final class ArgumentTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox The path can be set and returned
|
||||||
* @covers phpOMS\Uri\Argument
|
* @covers phpOMS\Uri\Argument
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
|
|
@ -89,66 +90,6 @@ final class ArgumentTest extends \PHPUnit\Framework\TestCase
|
||||||
self::assertEquals('modules/admin/new/path', $obj->getPath());
|
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
|
* @testdox The path offset can be set and returned
|
||||||
* @covers phpOMS\Uri\Argument
|
* @covers phpOMS\Uri\Argument
|
||||||
|
|
|
||||||
|
|
@ -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
|
* @covers phpOMS\Uri\HttpUri
|
||||||
* @group framework
|
* @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
|
* @covers phpOMS\Uri\HttpUri
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
|
|
@ -191,6 +192,7 @@ final class HttpUriTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox A path can be overwritten
|
||||||
* @covers phpOMS\Uri\HttpUri
|
* @covers phpOMS\Uri\HttpUri
|
||||||
* @group framework
|
* @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
|
* @covers phpOMS\Uri\HttpUri
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
||||||
use phpOMS\Uri\InvalidUriException;
|
use phpOMS\Uri\InvalidUriException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @testdox phpOMS\tests\Uri\InvalidUriExceptionTest: Invalid uri exception
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class InvalidUriExceptionTest extends \PHPUnit\Framework\TestCase
|
final class InvalidUriExceptionTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* @testdox The invalid uri exception is an unexpected value exception
|
||||||
* @covers phpOMS\Uri\InvalidUriException
|
* @covers phpOMS\Uri\InvalidUriException
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -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
|
* @covers phpOMS\Uri\UriFactory
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user