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
|
||||
{
|
||||
/**
|
||||
* Is read only.
|
||||
*
|
||||
* @var bool
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected bool $isReadOnly = false;
|
||||
|
||||
/**
|
||||
* Grammar.
|
||||
*
|
||||
|
|
@ -105,4 +113,13 @@ abstract class BuilderAbstract
|
|||
* @since 1.0.0
|
||||
*/
|
||||
abstract public function toSql() : string;
|
||||
|
||||
/**
|
||||
* Execute query.
|
||||
*
|
||||
* @return ?\PDOStatement
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
abstract public function execute() : ?\PDOStatement;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,10 @@ declare(strict_types=1);
|
|||
|
||||
namespace phpOMS\DataStorage\Database;
|
||||
|
||||
use phpOMS\Contract\SerializableInterface;
|
||||
use phpOMS\DataStorage\Database\Query\Builder;
|
||||
use phpOMS\DataStorage\Database\Query\Column;
|
||||
use phpOMS\DataStorage\Database\Query\Parameter;
|
||||
use phpOMS\DataStorage\Database\Query\QueryType;
|
||||
|
||||
/**
|
||||
|
|
@ -135,6 +139,11 @@ abstract class GrammarAbstract
|
|||
return \substr($queryString, 0, -1) . ';';
|
||||
}
|
||||
|
||||
public function compilePostQuerys(BuilderAbstract $query) : array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile components.
|
||||
*
|
||||
|
|
@ -146,37 +155,7 @@ abstract class GrammarAbstract
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected function compileComponents(BuilderAbstract $query) : array
|
||||
{
|
||||
if ($query->getType() === QueryType::RAW) {
|
||||
return [$query->raw];
|
||||
}
|
||||
|
||||
$sql = [];
|
||||
$components = $this->getComponents($query->getType());
|
||||
|
||||
/* Loop all possible query components and if they exist compile them. */
|
||||
foreach ($components as $component) {
|
||||
if (isset($query->{$component}) && !empty($query->{$component})) {
|
||||
$sql[$component] = $this->{'compile' . \ucfirst($component)}($query, $query->{$component});
|
||||
}
|
||||
}
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get query components based on query type.
|
||||
*
|
||||
* @param int $type Query type
|
||||
*
|
||||
* @return array Array of components to build query
|
||||
*
|
||||
* @throws \InvalidArgumentException Throws this exception if the query type is undefined
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
abstract protected function getComponents(int $type) : array;
|
||||
abstract protected function compileComponents(BuilderAbstract $query) : array;
|
||||
|
||||
/**
|
||||
* Get date format.
|
||||
|
|
@ -265,4 +244,71 @@ abstract class GrammarAbstract
|
|||
. $system
|
||||
. ($system !== '*' ? $identifierEnd : '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile value.
|
||||
*
|
||||
* @param BuilderAbstract $query Query builder
|
||||
* @param mixed $value Value
|
||||
*
|
||||
* @return string returns a string representation of the value
|
||||
*
|
||||
* @throws \InvalidArgumentException throws this exception if the value to compile is not supported by this function
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected function compileValue(BuilderAbstract $query, mixed $value) : string
|
||||
{
|
||||
if (\is_string($value)) {
|
||||
return $query->quote($value);
|
||||
} elseif (\is_int($value)) {
|
||||
return (string) $value;
|
||||
} elseif (\is_array($value)) {
|
||||
$value = \array_values($value);
|
||||
$count = \count($value) - 1;
|
||||
$values = '(';
|
||||
|
||||
for ($i = 0; $i < $count; ++$i) {
|
||||
$values .= $this->compileValue($query, $value[$i]) . ', ';
|
||||
}
|
||||
|
||||
return $values . $this->compileValue($query, $value[$count]) . ')';
|
||||
} elseif ($value instanceof \DateTime) {
|
||||
return $query->quote($value->format($this->datetimeFormat));
|
||||
} elseif ($value === null) {
|
||||
return 'NULL';
|
||||
} elseif (\is_bool($value)) {
|
||||
return (string) ((int) $value);
|
||||
} elseif (\is_float($value)) {
|
||||
return \rtrim(\rtrim(\number_format($value, 5, '.', ''), '0'), '.');
|
||||
} elseif ($value instanceof Column) {
|
||||
return '(' . \rtrim($this->compileColumnQuery($value), ';') . ')';
|
||||
} elseif ($value instanceof BuilderAbstract) {
|
||||
return '(' . \rtrim($value->toSql(), ';') . ')';
|
||||
} elseif ($value instanceof \JsonSerializable) {
|
||||
$encoded = \json_encode($value);
|
||||
|
||||
return $encoded ? $encoded : 'NULL';
|
||||
} elseif ($value instanceof SerializableInterface) {
|
||||
return $value->serialize();
|
||||
} elseif ($value instanceof Parameter) {
|
||||
return $value->__toString();
|
||||
} else {
|
||||
throw new \InvalidArgumentException(\gettype($value));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile column query.
|
||||
*
|
||||
* @param Column $column Where query
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected function compileColumnQuery(Column $column) : string
|
||||
{
|
||||
return $column->toSql();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,6 +104,7 @@ final class UpdateMapper extends DataMapperAbstract
|
|||
*/
|
||||
private function updateModel(object $obj, mixed $objId, \ReflectionClass $refClass = null) : void
|
||||
{
|
||||
try {
|
||||
// Model doesn't have anything to update
|
||||
if (\count($this->mapper::COLUMNS) < 2) {
|
||||
return;
|
||||
|
|
@ -156,7 +157,6 @@ final class UpdateMapper extends DataMapperAbstract
|
|||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$sth = $this->db->con->prepare($query->toSql());
|
||||
if ($sth !== false) {
|
||||
$sth->execute();
|
||||
|
|
|
|||
|
|
@ -106,6 +106,7 @@ final class WriteMapper extends DataMapperAbstract
|
|||
*/
|
||||
private function createModel(object $obj, \ReflectionClass $refClass) : mixed
|
||||
{
|
||||
try {
|
||||
$query = new Builder($this->db);
|
||||
$query->into($this->mapper::TABLE);
|
||||
|
||||
|
|
@ -159,9 +160,13 @@ final class WriteMapper extends DataMapperAbstract
|
|||
$query->insert($this->mapper::PRIMARYFIELD)->value(0);
|
||||
}
|
||||
|
||||
try {
|
||||
$sth = $this->db->con->prepare($a = $query->toSql());
|
||||
$sth->execute();
|
||||
|
||||
$objId = empty($id = $this->mapper::getObjectId($obj, $refClass)) ? $this->db->con->lastInsertId() : $id;
|
||||
\settype($objId, $this->mapper::COLUMNS[$this->mapper::PRIMARYFIELD]['type']);
|
||||
|
||||
return $objId;
|
||||
} catch (\Throwable $t) {
|
||||
// @codeCoverageIgnoreStart
|
||||
\var_dump($t->getMessage());
|
||||
|
|
@ -171,11 +176,6 @@ final class WriteMapper extends DataMapperAbstract
|
|||
return -1;
|
||||
// @codeCoverageIgnoreEND
|
||||
}
|
||||
|
||||
$objId = empty($id = $this->mapper::getObjectId($obj, $refClass)) ? $this->db->con->lastInsertId() : $id;
|
||||
\settype($objId, $this->mapper::COLUMNS[$this->mapper::PRIMARYFIELD]['type']);
|
||||
|
||||
return $objId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -384,6 +384,7 @@ final class WriteMapper extends DataMapperAbstract
|
|||
*/
|
||||
public function createRelationTable(string $propertyName, array $objsIds, mixed $objId) : void
|
||||
{
|
||||
try {
|
||||
if (empty($objsIds) || !isset($this->mapper::HAS_MANY[$propertyName]['external'])) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -405,7 +406,6 @@ final class WriteMapper extends DataMapperAbstract
|
|||
$relQuery->values($src, $objId);
|
||||
}
|
||||
|
||||
try {
|
||||
$sth = $this->db->con->prepare($relQuery->toSql());
|
||||
if ($sth !== false) {
|
||||
$sth->execute();
|
||||
|
|
|
|||
|
|
@ -37,14 +37,6 @@ class Builder extends BuilderAbstract
|
|||
*/
|
||||
public static bool $log = false;
|
||||
|
||||
/**
|
||||
* Is read only.
|
||||
*
|
||||
* @var bool
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected bool $isReadOnly = false;
|
||||
|
||||
/**
|
||||
* Columns.
|
||||
*
|
||||
|
|
@ -354,11 +346,7 @@ class Builder extends BuilderAbstract
|
|||
}
|
||||
|
||||
/**
|
||||
* Parsing to sql string.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toSql() : string
|
||||
{
|
||||
|
|
@ -386,7 +374,7 @@ class Builder extends BuilderAbstract
|
|||
{
|
||||
// create dependencies
|
||||
$dependencies = [];
|
||||
foreach ($this->joins as $table => $join) {
|
||||
foreach ($this->joins as $table => $_) {
|
||||
$dependencies[$table] = [];
|
||||
|
||||
foreach ($this->ons[$table] as $on) {
|
||||
|
|
@ -1384,18 +1372,14 @@ class Builder extends BuilderAbstract
|
|||
}
|
||||
|
||||
/**
|
||||
* Execute query.
|
||||
*
|
||||
* @return ?\PDOStatement
|
||||
*
|
||||
* @since 1.0.0
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function execute() : ?\PDOStatement
|
||||
{
|
||||
$sth = null;
|
||||
|
||||
try {
|
||||
$sth = $this->connection->con->prepare($a = $this->toSql());
|
||||
$sth = $this->connection->con->prepare($this->toSql());
|
||||
if ($sth === false) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,12 +14,10 @@ declare(strict_types=1);
|
|||
|
||||
namespace phpOMS\DataStorage\Database\Query\Grammar;
|
||||
|
||||
use phpOMS\Contract\SerializableInterface;
|
||||
use phpOMS\DataStorage\Database\BuilderAbstract;
|
||||
use phpOMS\DataStorage\Database\GrammarAbstract;
|
||||
use phpOMS\DataStorage\Database\Query\Builder;
|
||||
use phpOMS\DataStorage\Database\Query\Column;
|
||||
use phpOMS\DataStorage\Database\Query\From;
|
||||
use phpOMS\DataStorage\Database\Query\Parameter;
|
||||
use phpOMS\DataStorage\Database\Query\QueryType;
|
||||
use phpOMS\DataStorage\Database\Query\Where;
|
||||
|
||||
|
|
@ -37,94 +35,113 @@ use phpOMS\DataStorage\Database\Query\Where;
|
|||
*/
|
||||
class Grammar extends GrammarAbstract
|
||||
{
|
||||
/**
|
||||
* Select components.
|
||||
*
|
||||
* @var string[]
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected array $selectComponents = [
|
||||
'aggregate',
|
||||
'selects',
|
||||
'from',
|
||||
'joins',
|
||||
'wheres',
|
||||
'havings',
|
||||
'groups',
|
||||
'orders',
|
||||
'limit',
|
||||
'offset',
|
||||
'unions',
|
||||
'lock',
|
||||
];
|
||||
|
||||
/**
|
||||
* Insert components.
|
||||
*
|
||||
* @var string[]
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected array $insertComponents = [
|
||||
'into',
|
||||
'inserts',
|
||||
'values',
|
||||
];
|
||||
|
||||
/**
|
||||
* Update components.
|
||||
*
|
||||
* @var string[]
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected array $updateComponents = [
|
||||
'updates',
|
||||
'sets',
|
||||
'wheres',
|
||||
];
|
||||
|
||||
/**
|
||||
* Update components.
|
||||
*
|
||||
* @var string[]
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected array $deleteComponents = [
|
||||
'deletes',
|
||||
'from',
|
||||
'wheres',
|
||||
];
|
||||
|
||||
/**
|
||||
* Random components.
|
||||
*
|
||||
* @var string[]
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected array $randomComponents = [
|
||||
'random',
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getComponents(int $type) : array
|
||||
protected function compileComponents(BuilderAbstract $query) : array
|
||||
{
|
||||
switch ($type) {
|
||||
/** @var Builder $query */
|
||||
|
||||
$sql = [];
|
||||
switch ($query->getType()) {
|
||||
case QueryType::SELECT:
|
||||
return $this->selectComponents;
|
||||
// $sql[] = $this->compileAggregate($query, $query->aggregate);
|
||||
if (!empty($query->selects)) {
|
||||
$sql[] = $this->compileSelects($query, $query->selects);
|
||||
}
|
||||
|
||||
if (!empty($query->from)) {
|
||||
$sql[] = $this->compileFrom($query, $query->from);
|
||||
}
|
||||
|
||||
if (!empty($query->joins)) {
|
||||
$sql[] = $this->compileJoins($query, $query->joins);
|
||||
}
|
||||
|
||||
if (!empty($query->wheres)) {
|
||||
$sql[] = $this->compileWheres($query, $query->wheres);
|
||||
}
|
||||
|
||||
// $sql[] = $this->compileHavings($query, $query->havings);
|
||||
|
||||
if (!empty($query->groups)) {
|
||||
$sql[] = $this->compileGroups($query, $query->groups);
|
||||
}
|
||||
|
||||
if (!empty($query->orders)) {
|
||||
$sql[] = $this->compileOrders($query, $query->orders);
|
||||
}
|
||||
|
||||
if (!empty($query->limit)) {
|
||||
$sql[] = $this->compileLimit($query, $query->limit);
|
||||
}
|
||||
|
||||
if (!empty($query->offset)) {
|
||||
$sql[] = $this->compileOffset($query, $query->offset);
|
||||
}
|
||||
|
||||
if (!empty($query->unions)) {
|
||||
$sql[] = $this->compileUnions($query, $query->unions);
|
||||
}
|
||||
|
||||
if (!empty($query->lock)) {
|
||||
$sql[] = $this->compileLock($query, $query->lock);
|
||||
}
|
||||
|
||||
break;
|
||||
case QueryType::INSERT:
|
||||
return $this->insertComponents;
|
||||
if (!empty($query->into)) {
|
||||
$sql[] = $this->compileInto($query, $query->into);
|
||||
}
|
||||
|
||||
if (!empty($query->inserts)) {
|
||||
$sql[] = $this->compileInserts($query, $query->inserts);
|
||||
}
|
||||
|
||||
if (!empty($query->values)) {
|
||||
$sql[] = $this->compileValues($query, $query->values);
|
||||
}
|
||||
|
||||
break;
|
||||
case QueryType::UPDATE:
|
||||
return $this->updateComponents;
|
||||
if (!empty($query->updates)) {
|
||||
$sql[] = $this->compileUpdates($query, $query->updates);
|
||||
}
|
||||
|
||||
if (!empty($query->sets)) {
|
||||
$sql[] = $this->compileSets($query, $query->sets);
|
||||
}
|
||||
|
||||
if (!empty($query->wheres)) {
|
||||
$sql[] = $this->compileWheres($query, $query->wheres);
|
||||
}
|
||||
|
||||
break;
|
||||
case QueryType::DELETE:
|
||||
return $this->deleteComponents;
|
||||
if (!empty($query->deletes)) {
|
||||
$sql[] = $this->compileDeletes($query, $query->deletes);
|
||||
}
|
||||
|
||||
if (!empty($query->from)) {
|
||||
$sql[] = $this->compileFrom($query, $query->from);
|
||||
}
|
||||
|
||||
if (!empty($query->wheres)) {
|
||||
$sql[] = $this->compileWheres($query, $query->wheres);
|
||||
}
|
||||
|
||||
break;
|
||||
case QueryType::RANDOM:
|
||||
return $this->randomComponents;
|
||||
$sql[] = $this->compileRandom($query, $query->random);
|
||||
|
||||
break;
|
||||
case queryType::NONE:
|
||||
return [];
|
||||
default:
|
||||
throw new \InvalidArgumentException('Unknown query type.');
|
||||
}
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -148,6 +165,11 @@ class Grammar extends GrammarAbstract
|
|||
return ($query->distinct ? 'SELECT DISTINCT ' : 'SELECT ') . $expression;
|
||||
}
|
||||
|
||||
protected function compileRandom(Builder $query, array $columns) : string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile select.
|
||||
*
|
||||
|
|
@ -285,7 +307,7 @@ class Grammar extends GrammarAbstract
|
|||
*/
|
||||
protected function compileWhereQuery(Where $where) : string
|
||||
{
|
||||
return $where->toSql();
|
||||
return $where->toSql()[0];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -299,74 +321,7 @@ class Grammar extends GrammarAbstract
|
|||
*/
|
||||
protected function compileFromQuery(From $from) : string
|
||||
{
|
||||
return $from->toSql();
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile column query.
|
||||
*
|
||||
* @param Column $column Where query
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected function compileColumnQuery(Column $column) : string
|
||||
{
|
||||
return $column->toSql();
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile value.
|
||||
*
|
||||
* @param Builder $query Query builder
|
||||
* @param mixed $value Value
|
||||
*
|
||||
* @return string returns a string representation of the value
|
||||
*
|
||||
* @throws \InvalidArgumentException throws this exception if the value to compile is not supported by this function
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected function compileValue(Builder $query, mixed $value) : string
|
||||
{
|
||||
if (\is_string($value)) {
|
||||
return $query->quote($value);
|
||||
} elseif (\is_int($value)) {
|
||||
return (string) $value;
|
||||
} elseif (\is_array($value)) {
|
||||
$value = \array_values($value);
|
||||
$count = \count($value) - 1;
|
||||
$values = '(';
|
||||
|
||||
for ($i = 0; $i < $count; ++$i) {
|
||||
$values .= $this->compileValue($query, $value[$i]) . ', ';
|
||||
}
|
||||
|
||||
return $values . $this->compileValue($query, $value[$count]) . ')';
|
||||
} elseif ($value instanceof \DateTime) {
|
||||
return $query->quote($value->format($this->datetimeFormat));
|
||||
} elseif ($value === null) {
|
||||
return 'NULL';
|
||||
} elseif (\is_bool($value)) {
|
||||
return (string) ((int) $value);
|
||||
} elseif (\is_float($value)) {
|
||||
return \rtrim(\rtrim(\number_format($value, 5, '.', ''), '0'), '.');
|
||||
} elseif ($value instanceof Column) {
|
||||
return '(' . \rtrim($this->compileColumnQuery($value), ';') . ')';
|
||||
} elseif ($value instanceof Builder) {
|
||||
return '(' . \rtrim($value->toSql(), ';') . ')';
|
||||
} elseif ($value instanceof \JsonSerializable) {
|
||||
$encoded = \json_encode($value);
|
||||
|
||||
return $encoded ? $encoded : 'NULL';
|
||||
} elseif ($value instanceof SerializableInterface) {
|
||||
return $value->serialize();
|
||||
} elseif ($value instanceof Parameter) {
|
||||
return $value->__toString();
|
||||
} else {
|
||||
throw new \InvalidArgumentException(\gettype($value));
|
||||
}
|
||||
return $from->toSql()[0];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -539,7 +494,6 @@ class Grammar extends GrammarAbstract
|
|||
protected function compileOrders(Builder $query, array $orders) : string
|
||||
{
|
||||
$expression = '';
|
||||
$lastOrderType = '';
|
||||
|
||||
foreach ($orders as $column => $order) {
|
||||
$expression .= $this->compileSystem($column) . ' ' . $order . ', ';
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace phpOMS\DataStorage\Database\Schema;
|
||||
|
||||
use phpOMS\DataStorage\Database\BuilderAbstract;
|
||||
use phpOMS\DataStorage\Database\Connection\ConnectionAbstract;
|
||||
use phpOMS\DataStorage\Database\Query\Builder as QueryBuilder;
|
||||
|
||||
/**
|
||||
* Database query builder.
|
||||
|
|
@ -24,8 +24,10 @@ use phpOMS\DataStorage\Database\Query\Builder as QueryBuilder;
|
|||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @property \phpOMS\DataStorage\Database\Schema\Grammar $grammar Grammar.
|
||||
*/
|
||||
class Builder extends QueryBuilder
|
||||
class Builder extends BuilderAbstract
|
||||
{
|
||||
/**
|
||||
* Table to create.
|
||||
|
|
@ -109,6 +111,8 @@ class Builder extends QueryBuilder
|
|||
*/
|
||||
public array $alterAdd = [];
|
||||
|
||||
public bool $hasPostQuery = false;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
|
@ -157,7 +161,8 @@ class Builder extends QueryBuilder
|
|||
$builder->field(
|
||||
$name, $def['type'], $def['default'] ?? null,
|
||||
$def['null'] ?? true, $def['primary'] ?? false, $def['unique'] ?? false, $def['autoincrement'] ?? false,
|
||||
$def['foreignTable'] ?? null, $def['foreignKey'] ?? null
|
||||
$def['foreignTable'] ?? null, $def['foreignKey'] ?? null,
|
||||
$def
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -258,6 +263,7 @@ class Builder extends QueryBuilder
|
|||
* @param bool $autoincrement Autoincrements
|
||||
* @param string $foreignTable Foreign table (in case of foreign key)
|
||||
* @param string $foreignKey Foreign key
|
||||
* @param array $meta Meta data
|
||||
*
|
||||
* @return self
|
||||
*
|
||||
|
|
@ -266,7 +272,7 @@ class Builder extends QueryBuilder
|
|||
public function field(
|
||||
string $name, string $type, $default = null,
|
||||
bool $isNullable = true, bool $isPrimary = false, bool $isUnique = false, bool $autoincrement = false,
|
||||
string $foreignTable = null, string $foreignKey = null
|
||||
string $foreignTable = null, string $foreignKey = null, array $meta = []
|
||||
) : self {
|
||||
$this->createFields[$name] = [
|
||||
'name' => $name,
|
||||
|
|
@ -278,6 +284,7 @@ class Builder extends QueryBuilder
|
|||
'autoincrement' => $autoincrement,
|
||||
'foreignTable' => $foreignTable,
|
||||
'foreignKey' => $foreignKey,
|
||||
'meta' => $meta,
|
||||
];
|
||||
|
||||
return $this;
|
||||
|
|
@ -323,11 +330,41 @@ class Builder extends QueryBuilder
|
|||
}
|
||||
|
||||
/**
|
||||
* Parsing to string.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function execute() : ?\PDOStatement
|
||||
{
|
||||
$sth = null;
|
||||
|
||||
try {
|
||||
$sth = $this->connection->con->prepare($this->toSql());
|
||||
if ($sth === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$sth->execute();
|
||||
|
||||
if ($this->hasPostQuery) {
|
||||
$sqls = $this->grammar->compilePostQueries($this);
|
||||
|
||||
foreach ($sqls as $sql) {
|
||||
$this->connection->con->exec($sql);
|
||||
}
|
||||
}
|
||||
} catch (\Throwable $t) {
|
||||
// @codeCoverageIgnoreStart
|
||||
\var_dump($t->getMessage());
|
||||
\var_dump($this->toSql());
|
||||
|
||||
$sth = null;
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
return $sth;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toSql() : string
|
||||
{
|
||||
|
|
|
|||
|
|
@ -15,7 +15,8 @@ declare(strict_types=1);
|
|||
namespace phpOMS\DataStorage\Database\Schema\Grammar;
|
||||
|
||||
use phpOMS\DataStorage\Database\BuilderAbstract;
|
||||
use phpOMS\DataStorage\Database\Query\Grammar\Grammar as QueryGrammar;
|
||||
use phpOMS\DataStorage\Database\GrammarAbstract;
|
||||
use phpOMS\DataStorage\Database\Schema\Builder as SchemaBuilder;
|
||||
use phpOMS\DataStorage\Database\Schema\QueryType;
|
||||
|
||||
/**
|
||||
|
|
@ -26,95 +27,101 @@ use phpOMS\DataStorage\Database\Schema\QueryType;
|
|||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Grammar extends QueryGrammar
|
||||
class Grammar extends GrammarAbstract
|
||||
{
|
||||
/**
|
||||
* Drop components.
|
||||
*
|
||||
* @var string[]
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected array $dropDatabaseComponents = [
|
||||
'dropDatabase',
|
||||
];
|
||||
|
||||
/**
|
||||
* Drop components.
|
||||
*
|
||||
* @var string[]
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected array $dropTableComponents = [
|
||||
'dropTable',
|
||||
];
|
||||
|
||||
/**
|
||||
* Select tables components.
|
||||
*
|
||||
* @var string[]
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected array $createTablesComponents = [
|
||||
'createTable',
|
||||
'createFields',
|
||||
'createTableSettings',
|
||||
];
|
||||
|
||||
/**
|
||||
* Select tables components.
|
||||
*
|
||||
* @var string[]
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected array $tablesComponents = [
|
||||
'selectTables',
|
||||
];
|
||||
|
||||
/**
|
||||
* Select field components.
|
||||
*
|
||||
* @var string[]
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected array $fieldsComponents = [
|
||||
'selectFields',
|
||||
];
|
||||
|
||||
/**
|
||||
* Alter components.
|
||||
*
|
||||
* @var string[]
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected array $alterComponents = [
|
||||
'alterTable',
|
||||
'alterColumn',
|
||||
'alterAdd',
|
||||
'alterRename',
|
||||
'alterRemove',
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getComponents(int $type) : array
|
||||
protected function compileComponents(BuilderAbstract $query) : array
|
||||
{
|
||||
switch ($type) {
|
||||
/** @var SchemaBuilder $query */
|
||||
|
||||
$sql = [];
|
||||
switch ($query->getType()) {
|
||||
case QueryType::DROP_DATABASE:
|
||||
return $this->dropDatabaseComponents;
|
||||
case QueryType::TABLES:
|
||||
return $this->tablesComponents;
|
||||
case QueryType::FIELDS:
|
||||
return $this->fieldsComponents;
|
||||
case QueryType::CREATE_TABLE:
|
||||
return $this->createTablesComponents;
|
||||
case QueryType::DROP_TABLE:
|
||||
return $this->dropTableComponents;
|
||||
case QueryType::ALTER:
|
||||
return $this->alterComponents;
|
||||
default:
|
||||
return parent::getComponents($type);
|
||||
if (empty($query->dropDatabase)) {
|
||||
break;
|
||||
}
|
||||
|
||||
$sql[] = $this->compileDropDatabase($query, $query->dropDatabase);
|
||||
|
||||
break;
|
||||
case QueryType::TABLES:
|
||||
if (empty($query->selectTables)) {
|
||||
break;
|
||||
}
|
||||
|
||||
$sql[] = $this->compileSelectTables($query, $query->selectTables);
|
||||
|
||||
break;
|
||||
case QueryType::FIELDS:
|
||||
if (empty($query->selectFields)) {
|
||||
break;
|
||||
}
|
||||
|
||||
$sql[] = $this->compileSelectFields($query, $query->selectFields);
|
||||
|
||||
break;
|
||||
case QueryType::CREATE_TABLE:
|
||||
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:
|
||||
if (empty($query->dropTable)) {
|
||||
break;
|
||||
}
|
||||
|
||||
$sql[] = $this->compileDropTable($query, $query->dropTable);
|
||||
|
||||
break;
|
||||
case QueryType::ALTER:
|
||||
$sql[] = $this->compileAlterTable($query, $query->alterTable);
|
||||
$sql[] = $this->compileAlterColumn($query, $query->alterColumn);
|
||||
$sql[] = $this->compileAlterAdd($query, $query->alterAdd);
|
||||
// $sql[] = $this->compileAlterRename($query, $query->alterRename);
|
||||
// $sql[] = $this->compileAlterRemove($query, $query->alterRemove);
|
||||
|
||||
break;
|
||||
case QueryType::RAW:
|
||||
$sql[] = $query->raw;
|
||||
|
||||
break;
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
|
||||
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\Query\Builder;
|
||||
use phpOMS\DataStorage\Database\Schema\Builder as SchemaBuilder;
|
||||
use phpOMS\DataStorage\Database\Schema\QueryType;
|
||||
|
||||
/**
|
||||
* Database query grammar.
|
||||
|
|
@ -43,6 +45,44 @@ class MysqlGrammar extends Grammar
|
|||
*/
|
||||
public string $systemIdentifierEnd = '`';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function compilePostQueries(BuilderAbstract $query): array
|
||||
{
|
||||
/** @var SchemaBuilder $query */
|
||||
|
||||
$sql = [];
|
||||
switch ($query->getType()) {
|
||||
case QueryType::CREATE_TABLE:
|
||||
foreach ($query->createFields as $name => $field) {
|
||||
if (isset($field['meta']['multi_autoincrement'])) {
|
||||
$tmpSql = 'CREATE TRIGGER update_' . $name
|
||||
. ' BEFORE INSERT ON ' . $query->createTable
|
||||
. ' FOR EACH ROW BEGIN'
|
||||
. ' SET NEW.' . $name . ' = ('
|
||||
. 'SELECT COALESCE(MAX(' . $name . '), 0) + 1'
|
||||
. ' FROM ' . $query->createTable
|
||||
. ' WHERE';
|
||||
|
||||
foreach ($field['meta']['multi_autoincrement'] as $index => $autoincrement) {
|
||||
$tmpSql .= ($index > 0 ? ' AND' : '' ) . ' ' . $autoincrement . ' = NEW.' . $autoincrement;
|
||||
}
|
||||
|
||||
$tmpSql .= ' LIMIT 1); END;';
|
||||
|
||||
$sql[] = $tmpSql;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile remove
|
||||
*
|
||||
|
|
@ -63,14 +103,14 @@ class MysqlGrammar extends Grammar
|
|||
/**
|
||||
* Compile from.
|
||||
*
|
||||
* @param Builder $query Builder
|
||||
* @param SchemaBuilder $query Builder
|
||||
* @param array $table Tables
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected function compileSelectTables(Builder $query, array $table) : string
|
||||
protected function compileSelectTables(SchemaBuilder $query, array $table) : string
|
||||
{
|
||||
$builder = new Builder($query->getConnection());
|
||||
$builder->select('table_name')
|
||||
|
|
@ -83,14 +123,14 @@ class MysqlGrammar extends Grammar
|
|||
/**
|
||||
* Compile from.
|
||||
*
|
||||
* @param Builder $query Builder
|
||||
* @param SchemaBuilder $query Builder
|
||||
* @param string $table Tables
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected function compileSelectFields(Builder $query, string $table) : string
|
||||
protected function compileSelectFields(SchemaBuilder $query, string $table) : string
|
||||
{
|
||||
$builder = new Builder($query->getConnection());
|
||||
$builder->select('*')
|
||||
|
|
@ -104,14 +144,14 @@ class MysqlGrammar extends Grammar
|
|||
/**
|
||||
* Compile create table fields query.
|
||||
*
|
||||
* @param Builder $query Query
|
||||
* @param SchemaBuilder $query Query
|
||||
* @param array $fields Fields to create
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected function compileCreateFields(Builder $query, array $fields) : string
|
||||
protected function compileCreateFields(SchemaBuilder $query, array $fields) : string
|
||||
{
|
||||
$fieldQuery = '';
|
||||
$keys = '';
|
||||
|
|
@ -119,35 +159,37 @@ class MysqlGrammar extends Grammar
|
|||
foreach ($fields as $name => $field) {
|
||||
$fieldQuery .= ' ' . $this->expressionizeTableColumn([$name]) . ' ' . $field['type'];
|
||||
|
||||
if (isset($field['default']) || ($field['default'] === null && isset($field['null']) && $field['null'])) {
|
||||
if (isset($field['default']) || ($field['default'] === null && ($field['null'] ?? false))) {
|
||||
$fieldQuery .= ' DEFAULT ' . $this->compileValue($query, $field['default']);
|
||||
}
|
||||
|
||||
if (isset($field['null'])) {
|
||||
if ($field['null'] ?? false) {
|
||||
$fieldQuery .= ' ' . ($field['null'] ? '' : 'NOT ') . 'NULL';
|
||||
}
|
||||
|
||||
if (isset($field['autoincrement']) && $field['autoincrement']) {
|
||||
if ($field['autoincrement'] ?? false) {
|
||||
$fieldQuery .= ' AUTO_INCREMENT';
|
||||
}
|
||||
|
||||
$fieldQuery .= ',';
|
||||
|
||||
if (isset($field['primary']) && $field['primary']) {
|
||||
if ($field['primary'] ?? false) {
|
||||
$keys .= ' PRIMARY KEY (' . $this->expressionizeTableColumn([$name]) . '),';
|
||||
}
|
||||
|
||||
if (isset($field['unique']) && $field['unique']) {
|
||||
if ($field['unique'] ?? false) {
|
||||
$keys .= ' UNIQUE KEY (' . $this->expressionizeTableColumn([$name]) . '),';
|
||||
}
|
||||
|
||||
if (isset($field['foreignTable'], $field['foreignKey'])
|
||||
&& !empty($field['foreignTable']) && !empty($field['foreignKey'])
|
||||
) {
|
||||
if (isset($field['foreignTable'], $field['foreignKey'])) {
|
||||
$keys .= ' FOREIGN KEY (' . $this->expressionizeTableColumn([$name]) . ') REFERENCES '
|
||||
. $this->expressionizeTableColumn([$field['foreignTable']])
|
||||
. ' (' . $this->expressionizeTableColumn([$field['foreignKey']]) . '),';
|
||||
}
|
||||
|
||||
if (isset($field['meta']['multi_autoincrement'])) {
|
||||
$query->hasPostQuery = true;
|
||||
}
|
||||
}
|
||||
|
||||
return '(' . \ltrim(\rtrim($fieldQuery . $keys, ','), ' ') . ')';
|
||||
|
|
|
|||
|
|
@ -286,6 +286,8 @@ abstract class RequestAbstract implements MessageInterface
|
|||
/**
|
||||
* Check if has data.
|
||||
*
|
||||
* The following empty values are considered as not set (null, '', 0)
|
||||
*
|
||||
* @param string $key Data key
|
||||
*
|
||||
* @return bool
|
||||
|
|
@ -296,7 +298,10 @@ abstract class RequestAbstract implements MessageInterface
|
|||
{
|
||||
$key = \mb_strtolower($key);
|
||||
|
||||
return isset($this->data[$key]) && !empty($this->data[$key]);
|
||||
return isset($this->data[$key])
|
||||
&& $this->data[$key] !== ''
|
||||
&& $this->data[$key] !== 0
|
||||
&& $this->data[$key] !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -80,6 +80,11 @@ abstract class InstallerAbstract
|
|||
|
||||
/** @var array[] $definitions */
|
||||
$definitions = \json_decode($content, true);
|
||||
|
||||
if (!\is_array($definitions)) {
|
||||
return; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
foreach ($definitions as $definition) {
|
||||
SchemaBuilder::createFromSchema($definition, $dbPool->get('schema'))->execute();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -293,10 +293,12 @@ final class ModuleManager
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
/*
|
||||
public function getAvailableModules() : array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
*
|
||||
|
||||
/**
|
||||
* Get all installed modules.
|
||||
|
|
|
|||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
use phpOMS\Account\AccountStatus;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Account\AccountStatus: Account status
|
||||
* @internal
|
||||
*/
|
||||
final class AccountStatusTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @testdoxThe account status enum has the correct number of status codes
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
@ -33,6 +35,7 @@ final class AccountStatusTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox The account status enum has only unique values
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
@ -42,6 +45,7 @@ final class AccountStatusTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox The account status enum has the correct values
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -245,7 +245,7 @@ final class AccountTest extends \PHPUnit\Framework\TestCase
|
|||
$account->addPermission(new class() extends PermissionAbstract {});
|
||||
self::assertCount(1, $account->getPermissions());
|
||||
|
||||
self::assertFalse($account->hasPermission(PermissionType::READ, 1, 'a', 'a', 1, 1, 1));
|
||||
self::assertFalse($account->hasPermission(PermissionType::READ, 1, 2, 'a', 1, 1, 1));
|
||||
self::assertTrue($account->hasPermission(PermissionType::NONE));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
use phpOMS\Account\AccountType;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Account\AccountType: Account type
|
||||
* @internal
|
||||
*/
|
||||
final class AccountTypeTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox The account type enum has the correct number of type codes
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
@ -33,6 +35,7 @@ final class AccountTypeTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox The account type enum has only unique values
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
@ -42,6 +45,7 @@ final class AccountTypeTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox The account type enum has the correct values
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
use phpOMS\Account\GroupStatus;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Account\GroupStatus: Group status
|
||||
* @internal
|
||||
*/
|
||||
final class GroupStatusTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox The group status enum has the correct number of status codes
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
@ -33,6 +35,7 @@ final class GroupStatusTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox The group status enum has only unique values
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
@ -42,6 +45,7 @@ final class GroupStatusTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox The group status enum has the correct values
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
use phpOMS\Account\NullAccount;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Account\NullAccount: Null account
|
||||
* @internal
|
||||
*/
|
||||
final class NullAccountTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox The null account is an instance of the account class
|
||||
* @covers phpOMS\Account\NullAccount
|
||||
* @group framework
|
||||
*/
|
||||
|
|
@ -33,6 +35,7 @@ final class NullAccountTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox The null account can get initialized with an id
|
||||
* @covers phpOMS\Account\NullAccount
|
||||
* @group framework
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -19,16 +19,29 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
use phpOMS\Account\NullGroup;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Account\NullGroup: Null group
|
||||
* @internal
|
||||
*/
|
||||
final class NullGroupTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox The null group is an instance of the group class
|
||||
* @covers phpOMS\Account\NullGroup
|
||||
* @group module
|
||||
* @group framework
|
||||
*/
|
||||
public function testNull() : void
|
||||
{
|
||||
self::assertInstanceOf('\phpOMS\Account\Group', new NullGroup());
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The null group can get initialized with an id
|
||||
* @covers phpOMS\Account\NullGroup
|
||||
* @group framework
|
||||
*/
|
||||
public function testId() : void
|
||||
{
|
||||
$null = new NullGroup(2);
|
||||
self::assertEquals(2, $null->getId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,8 +86,8 @@ final class PermissionAbstractTest extends \PHPUnit\Framework\TestCase
|
|||
{
|
||||
$perm = new class() extends PermissionAbstract {};
|
||||
|
||||
$perm->setApp('Test');
|
||||
self::assertEquals('Test', $perm->getApp());
|
||||
$perm->setApp(2);
|
||||
self::assertEquals(2, $perm->getApp());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
use phpOMS\Account\PermissionType;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Account\PermissionType: Permission type
|
||||
* @internal
|
||||
*/
|
||||
final class PermissionTypeTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox The permission type enum has the correct number of type codes
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
@ -33,6 +35,7 @@ final class PermissionTypeTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox The permission type enum has only unique values
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
@ -42,6 +45,7 @@ final class PermissionTypeTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox The permission type enum has the correct values
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ use phpOMS\Application\ApplicationInfo;
|
|||
final class ApplicationInfoTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox A info file can be correctly loaded
|
||||
* @testdox An application info file can be correctly loaded
|
||||
* @covers phpOMS\Application\ApplicationInfo
|
||||
* @group framework
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ final class ApplicationManagerTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox An application can be installed and uninstalled
|
||||
* @covers phpOMS\Application\ApplicationManager
|
||||
* @covers phpOMS\Application\InstallerAbstract
|
||||
* @covers phpOMS\Application\StatusAbstract
|
||||
|
|
@ -110,6 +111,7 @@ final class ApplicationManagerTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox An application can be re-initialized
|
||||
* @testdox A module can be re-initialized
|
||||
* @covers phpOMS\Application\ApplicationManager
|
||||
* @covers phpOMS\Application\InstallerAbstract
|
||||
|
|
@ -139,6 +141,7 @@ final class ApplicationManagerTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox A invalid application path results in no installation
|
||||
* @covers phpOMS\Application\ApplicationManager
|
||||
* @group framework
|
||||
*/
|
||||
|
|
@ -149,6 +152,7 @@ final class ApplicationManagerTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox A missing installation file results in no installation
|
||||
* @covers phpOMS\Application\ApplicationManager
|
||||
* @group framework
|
||||
*/
|
||||
|
|
@ -158,6 +162,7 @@ final class ApplicationManagerTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox A missing info file results in no installation
|
||||
* @covers phpOMS\Application\ApplicationManager
|
||||
* @group framework
|
||||
*/
|
||||
|
|
@ -167,6 +172,7 @@ final class ApplicationManagerTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox A invalid application path results in no uninstallation
|
||||
* @covers phpOMS\Application\ApplicationManager
|
||||
* @group framework
|
||||
*/
|
||||
|
|
@ -177,6 +183,7 @@ final class ApplicationManagerTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox A missing uninstallation file results in no uninstallation
|
||||
* @covers phpOMS\Application\ApplicationManager
|
||||
* @group framework
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
use phpOMS\Application\InstallerAbstract;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Application\InstallerAbstractTest: Application installer
|
||||
* @testdox phpOMS\tests\Application\InstallerAbstractTest: Abstract application installer
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
|
|
@ -38,6 +38,7 @@ final class InstallerAbstractTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox An invalid theme cannot be installed
|
||||
* @covers phpOMS\Application\InstallerAbstract
|
||||
* @group framework
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
use phpOMS\Application\StatusAbstract;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Application\StatusAbstractTest: Application status
|
||||
* @testdox phpOMS\tests\Application\StatusAbstractTest: Abstract application status
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
|
|
@ -39,6 +39,7 @@ final class StatusAbstractTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox A invalid application path cannot be activated
|
||||
* @covers phpOMS\Application\StatusAbstract
|
||||
* @group framework
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ use phpOMS\Application\UninstallerAbstract;
|
|||
use phpOMS\DataStorage\Database\DatabasePool;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Application\UninstallerAbstractTest: Abstract module
|
||||
* @testdox phpOMS\tests\Application\UninstallerAbstractTest: Abstract application uninstaller
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
|
|
@ -41,6 +41,7 @@ final class UninstallerAbstractTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox A missing database schema will not perform any database operations
|
||||
* @covers phpOMS\Application\UninstallerAbstract
|
||||
* @group framework
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
use phpOMS\Asset\AssetType;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Asset\AssetType: Asset type
|
||||
* @internal
|
||||
*/
|
||||
final class AssetTypeTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox The asset type enum has the correct number of status codes
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
@ -33,6 +35,7 @@ final class AssetTypeTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox The asset type enum has only unique values
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
@ -42,6 +45,7 @@ final class AssetTypeTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox The asset type enum has the correct values
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
use phpOMS\Auth\LoginReturnType;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Auth\LoginReturnType: Login return type
|
||||
* @internal
|
||||
*/
|
||||
final class LoginReturnTypeTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox The login return type enum has the correct number of type codes
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
@ -33,6 +35,7 @@ final class LoginReturnTypeTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox The login return type enum has only unique values
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
@ -42,6 +45,7 @@ final class LoginReturnTypeTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox The login return type enum has the correct values
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -282,7 +282,7 @@ final class FinanceFormulasTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox Balance / P&L ratios are correct (e.g. inventory turnover, net profit margin)
|
||||
* @testdox Various ratios are correct (e.g. interest coverage, quick ratio, rate of inflation)
|
||||
* @covers phpOMS\Business\Finance\FinanceFormulas
|
||||
* @group framework
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ use phpOMS\DataStorage\Cache\Connection\RedisCache;
|
|||
use phpOMS\Utils\TestUtils;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\DataStorage\Cache\Connection\RedisCacheTest: Redis cache connection
|
||||
* @testdox phpOMS\tests\DataStorage\Cache\Connection\RedisCache: Redis cache connection
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
use phpOMS\DataStorage\LockException;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\DataStorage\LockExceptionTest: Lock exception
|
||||
* @internal
|
||||
*/
|
||||
final class LockExceptionTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox The lock exception is an instance of the runtime exception
|
||||
* @covers phpOMS\DataStorage\LockException
|
||||
* @group framework
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ final class DispatcherTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox The dispatcher has the expected member variables
|
||||
* @testdox The dispatcher has the expected attributes
|
||||
* @covers phpOMS\Dispatcher\Dispatcher
|
||||
* @group framework
|
||||
*/
|
||||
|
|
@ -57,6 +57,11 @@ final class DispatcherTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertObjectHasAttribute('controllers', $this->app->dispatcher);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox A route can be added and dispatched
|
||||
* @covers phpOMS\Dispatcher\Dispatcher
|
||||
* @group framework
|
||||
*/
|
||||
public function testControllerInputOutput() : void
|
||||
{
|
||||
$this->app->dispatcher->set(new class() extends ModuleAbstract {
|
||||
|
|
@ -199,6 +204,7 @@ final class DispatcherTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox The dispatcher can pass additional data to the destination
|
||||
* @covers phpOMS\Dispatcher\Dispatcher
|
||||
* @group framework
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -19,18 +19,24 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
use phpOMS\Image\Kernel;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Image\KernelTest: Image kernel
|
||||
* @internal
|
||||
*/
|
||||
final class KernelTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox The kernel can be applied to an image which is then stored in a new file
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
* @covers phpOMS\Image\Kernel
|
||||
*/
|
||||
public function testKernel() : void
|
||||
{
|
||||
Kernel::convolve(__DIR__ . '/img1.png', __DIR__ . '/test_img1_sharpen.png', Kernel::KERNEL_SHARPEN);
|
||||
Kernel::convolve(__DIR__ . '/img1.png', __DIR__ . '/test_img1_blur.png', Kernel::KERNEL_GAUSSUAN_BLUR_3);
|
||||
Kernel::convolve(__DIR__ . '/img1.png', __DIR__ . '/test_img1_emboss.png', Kernel::KERNEL_EMBOSS);
|
||||
|
||||
self::assertTrue(\is_file(__DIR__ . '/test_img1_sharpen.png'));
|
||||
self::assertTrue(\is_file(__DIR__ . '/test_img1_blur.png'));
|
||||
self::assertTrue(\is_file(__DIR__ . '/test_img1_emboss.png'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,13 +19,15 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
use phpOMS\Image\Skew;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Image\SkewTest: Image skew
|
||||
* @internal
|
||||
*/
|
||||
final class SkewTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox A image can be automatically unskewed
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
* @covers phpOMS\Image\Skew
|
||||
*/
|
||||
public function testSkew() : void
|
||||
{
|
||||
|
|
@ -39,5 +41,7 @@ final class SkewTest extends \PHPUnit\Framework\TestCase
|
|||
[150, 75],
|
||||
[1700, 900]
|
||||
);
|
||||
|
||||
self::assertTrue(\is_file(__DIR__ . '/test_binary_untilted.png'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,17 +19,22 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
use phpOMS\Image\Thresholding;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Image\ThresholdingTest: Image thresholding
|
||||
* @internal
|
||||
*/
|
||||
final class ThresholdingTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox The thresholding is correctly applied to the image
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
* @covers phpOMS\Image\Thresholding
|
||||
*/
|
||||
public function testThresholding() : void
|
||||
{
|
||||
Thresholding::integralThresholding(__DIR__ . '/img1.png', __DIR__ . '/test_img1_integral_thresholding.png');
|
||||
Thresholding::integralThresholding(__DIR__ . '/img2.jpg', __DIR__ . '/test_img2_integral_thresholding.jpg');
|
||||
|
||||
self::assertTrue(\is_file(__DIR__ . '/test_img1_integral_thresholding.png'));
|
||||
self::assertTrue(\is_file(__DIR__ . '/test_img2_integral_thresholding.jpg'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ final class CityMapperTest extends \PHPUnit\Framework\TestCase
|
|||
public static function setUpBeforeClass() : void
|
||||
{
|
||||
$con = new SqliteConnection([
|
||||
'prefix' => '',
|
||||
'db' => 'sqlite',
|
||||
'database' => \realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'),
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ final class CountryMapperTest extends \PHPUnit\Framework\TestCase
|
|||
public static function setUpBeforeClass() : void
|
||||
{
|
||||
$con = new SqliteConnection([
|
||||
'prefix' => '',
|
||||
'db' => 'sqlite',
|
||||
'database' => \realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'),
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ final class CurrencyMapperTest extends \PHPUnit\Framework\TestCase
|
|||
public static function setUpBeforeClass() : void
|
||||
{
|
||||
$con = new SqliteConnection([
|
||||
'prefix' => '',
|
||||
'db' => 'sqlite',
|
||||
'database' => \realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'),
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ final class IbanMapperTest extends \PHPUnit\Framework\TestCase
|
|||
public static function setUpBeforeClass() : void
|
||||
{
|
||||
$con = new SqliteConnection([
|
||||
'prefix' => '',
|
||||
'db' => 'sqlite',
|
||||
'database' => \realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'),
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ final class LanguageMapperTest extends \PHPUnit\Framework\TestCase
|
|||
public static function setUpBeforeClass() : void
|
||||
{
|
||||
$con = new SqliteConnection([
|
||||
'prefix' => '',
|
||||
'db' => 'sqlite',
|
||||
'database' => \realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'),
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
use phpOMS\Localization\ISO3166CharEnum;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Localization\ISO3166CharEnumTest: ISO 3166 country codes
|
||||
* @internal
|
||||
*/
|
||||
final class ISO3166CharEnumTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox The ISO 3166 country code enum has the correct format of country codes
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
@ -41,6 +43,15 @@ final class ISO3166CharEnumTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
self::assertTrue($ok);
|
||||
self::assertEquals(\count($enum), \count(\array_unique($enum)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The ISO 3166 enum has only unique values
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
public function testUnique() : void
|
||||
{
|
||||
self::assertEquals(ISO3166CharEnum::getConstants(), \array_unique(ISO3166CharEnum::getConstants()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,15 +19,17 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
use phpOMS\Localization\ISO3166NameEnum;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Localization\ISO3166NameEnumTest: ISO 3166 country names
|
||||
* @internal
|
||||
*/
|
||||
final class ISO3166NameEnumTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox The ISO 3166 enum has only unique values
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
public function testEnums() : void
|
||||
public function testUnique() : void
|
||||
{
|
||||
$enum = ISO3166NameEnum::getConstants();
|
||||
self::assertEquals(\count($enum), \count(\array_unique($enum)));
|
||||
|
|
|
|||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
use phpOMS\Localization\ISO3166NumEnum;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Localization\ISO3166NumEnumTest: ISO 3166 country codes
|
||||
* @internal
|
||||
*/
|
||||
final class ISO3166NumEnumTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox The ISO 3166 country code enum has the correct format of country codes
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
@ -41,6 +43,15 @@ final class ISO3166NumEnumTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
self::assertTrue($ok);
|
||||
self::assertEquals(\count($enum), \count(\array_unique($enum)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The ISO 3166 enum has only unique values
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
public function testUnique() : void
|
||||
{
|
||||
self::assertEquals(ISO3166NumEnum::getConstants(), \array_unique(ISO3166NumEnum::getConstants()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
use phpOMS\Localization\ISO3166TwoEnum;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Localization\ISO3166NumEnumTest: ISO 3166 country codes
|
||||
* @internal
|
||||
*/
|
||||
final class ISO3166TwoEnumTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox The ISO 3166 country code enum has the correct format of country codes
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
@ -41,6 +43,15 @@ final class ISO3166TwoEnumTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
self::assertTrue($ok);
|
||||
self::assertEquals(\count($countryCodes), \count(\array_unique($countryCodes)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The ISO 3166 enum has only unique values
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
public function testUnique() : void
|
||||
{
|
||||
self::assertEquals(ISO3166TwoEnum::getConstants(), \array_unique(ISO3166TwoEnum::getConstants()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
use phpOMS\Localization\ISO4217CharEnum;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Localization\ISO4217CharEnumTest: ISO 4217 currency codes
|
||||
* @internal
|
||||
*/
|
||||
final class ISO4217CharEnumTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox The ISO 4217 currency code enum has the correct format of currency codes
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
@ -41,6 +43,15 @@ final class ISO4217CharEnumTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
self::assertTrue($ok);
|
||||
self::assertEquals(\count($enum), \count(\array_unique($enum)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The ISO 4217 enum has only unique values
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
public function testUnique() : void
|
||||
{
|
||||
self::assertEquals(ISO4217CharEnum::getConstants(), \array_unique(ISO4217CharEnum::getConstants()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
use phpOMS\Localization\ISO4217DecimalEnum;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Localization\ISO4217DecimalEnumTest: ISO 4217 currency codes
|
||||
* @internal
|
||||
*/
|
||||
final class ISO4217DecimalEnumTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox The ISO 4217 currency code enum has the correct format of currency decimal places
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -19,15 +19,17 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
use phpOMS\Localization\ISO4217Enum;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Localization\ISO4217EnumTest: ISO 4217 currency codes
|
||||
* @internal
|
||||
*/
|
||||
final class ISO4217EnumTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox The ISO 4217 currency code enum has only unique values
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
public function testEnums() : void
|
||||
public function testUnique() : void
|
||||
{
|
||||
$enum = ISO4217Enum::getConstants();
|
||||
self::assertEquals(\count($enum), \count(\array_unique($enum)));
|
||||
|
|
|
|||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
use phpOMS\Localization\ISO4217NumEnum;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Localization\ISO4217NumEnumTest: ISO 4217 currency codes
|
||||
* @internal
|
||||
*/
|
||||
final class ISO4217NumEnumTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox The ISO 4217 currency code enum has the correct format of currency codes
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
@ -41,6 +43,15 @@ final class ISO4217NumEnumTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
self::assertTrue($ok);
|
||||
self::assertEquals(\count($enum), \count(\array_unique($enum)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The ISO 4217 enum has only unique values
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
public function testUnique() : void
|
||||
{
|
||||
self::assertEquals(ISO4217NumEnum::getConstants(), \array_unique(ISO4217NumEnum::getConstants()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
use phpOMS\Localization\ISO4217SubUnitEnum;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Localization\ISO4217SubUnitEnumTest: ISO 4217 currency codes
|
||||
* @internal
|
||||
*/
|
||||
final class ISO4217SubUnitEnumTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox The ISO 4217 currency code enum has the correct format of currency sub units
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
use phpOMS\Localization\ISO4217SymbolEnum;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Localization\ISO4217SymbolEnumTest: ISO 4217 currency codes
|
||||
* @internal
|
||||
*/
|
||||
final class ISO4217SymbolEnumTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox The ISO 4217 currency code enum has the correct number of currency symbols
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -19,15 +19,17 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
use phpOMS\Localization\ISO639Enum;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Localization\ISO639EnumTest: ISO 639 language codes
|
||||
* @internal
|
||||
*/
|
||||
final class ISO639EnumTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox The ISO 639 language code enum has only unique values
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
public function testEnums() : void
|
||||
public function testUnique() : void
|
||||
{
|
||||
$enum = ISO639Enum::getConstants();
|
||||
self::assertEquals(\count($enum), \count(\array_unique($enum)));
|
||||
|
|
|
|||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
use phpOMS\Localization\ISO639x1Enum;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Localization\ISO639x1EnumTest: ISO 639-1 language codes
|
||||
* @internal
|
||||
*/
|
||||
final class ISO639x1EnumTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox The ISO 639-1 language code enum has the correct format of language codes
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
@ -41,6 +43,15 @@ final class ISO639x1EnumTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
self::assertTrue($ok);
|
||||
self::assertEquals(\count($enum), \count(\array_unique($enum)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The ISO 639-1 enum has only unique values
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
public function testUnique() : void
|
||||
{
|
||||
self::assertEquals(ISO639x1Enum::getConstants(), \array_unique(ISO639x1Enum::getConstants()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
use phpOMS\Localization\ISO639x2Enum;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Localization\ISO639x2EnumTest: ISO 639-2 language codes
|
||||
* @internal
|
||||
*/
|
||||
final class ISO639x2EnumTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox The ISO 639-2 language code enum has the correct format of language codes
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
@ -41,6 +43,15 @@ final class ISO639x2EnumTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
self::assertTrue($ok);
|
||||
self::assertEquals(\count($enum), \count(\array_unique($enum)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The ISO 639-2 enum has only unique values
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
public function testUnique() : void
|
||||
{
|
||||
self::assertEquals(ISO639x2Enum::getConstants(), \array_unique(ISO639x2Enum::getConstants()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
use phpOMS\Localization\ISO8601EnumArray;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Localization\ISO8601EnumArrayTest: ISO 8601 date time formats
|
||||
* @internal
|
||||
*/
|
||||
final class ISO8601EnumArrayTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox The ISO 8601 date time format enum has the correct number of date time formats
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
@ -31,4 +33,14 @@ final class ISO8601EnumArrayTest extends \PHPUnit\Framework\TestCase
|
|||
{
|
||||
self::assertCount(4, ISO8601EnumArray::getConstants());
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The ISO 8601 enum has only unique values
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
public function testUnique() : void
|
||||
{
|
||||
self::assertEquals(ISO8601EnumArray::getConstants(), \array_unique(ISO8601EnumArray::getConstants()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
final class L11nManagerTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
protected L11nManager $l11nManager;
|
||||
protected L11nManager $l11nManager2;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
|
@ -118,7 +119,7 @@ final class L11nManagerTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox Language data can be loaded from a file
|
||||
* @testdox Multiple languages can be loaded from a file
|
||||
* @covers phpOMS\Localization\L11nManager
|
||||
* @group framework
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
use phpOMS\Localization\PhoneEnum;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Localization\PhoneEnumTest: Country phone codes
|
||||
* @internal
|
||||
*/
|
||||
final class PhoneEnumTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox The phone enum has the correct format of country phone numbers
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -19,15 +19,17 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
use phpOMS\Localization\TimeZoneEnumArray;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Localization\TimeZoneEnumArrayTest: Time zone enum array
|
||||
* @internal
|
||||
*/
|
||||
final class TimeZoneEnumArrayTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox The time zone enum array has only unique values
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
public function testEnums() : void
|
||||
public function testUnique() : void
|
||||
{
|
||||
self::assertEquals(\count(TimeZoneEnumArray::getConstants()), \count(\array_unique(TimeZoneEnumArray::getConstants())));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
use phpOMS\Log\LogLevel;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Log\LogLevelTest: Log level enum
|
||||
* @internal
|
||||
*/
|
||||
final class LogLevelTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox The log level enum has the correct number of log levels
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
@ -33,6 +35,7 @@ final class LogLevelTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox The log level enum has only unique values
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
@ -42,6 +45,7 @@ final class LogLevelTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox The log level enum has the correct values
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ use phpOMS\Module\InstallerAbstract;
|
|||
use phpOMS\Module\ModuleInfo;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Module\InstallerAbstractTest: Abstract module
|
||||
* @testdox phpOMS\tests\Module\InstallerAbstractTest: Abstract module installer
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
|
|
@ -42,6 +42,7 @@ final class InstallerAbstractTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox Invalid or missing module status file throws exception during installation
|
||||
* @covers phpOMS\Module\InstallerAbstract
|
||||
* @group framework
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
* @group framework
|
||||
*/
|
||||
|
|
@ -459,6 +459,11 @@ final class ModuleAbstractTest extends \PHPUnit\Framework\TestCase
|
|||
$this->dbTeardown();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The model CRUD functions can be called with a closure
|
||||
* @covers phpOMS\Module\ModuleAbstract<extended>
|
||||
* @group framework
|
||||
*/
|
||||
public function testModelFunctionsWithClosure() : void
|
||||
{
|
||||
$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
|
||||
* @group framework
|
||||
*/
|
||||
|
|
@ -251,6 +251,11 @@ final class ModuleManagerTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertTrue($this->moduleManager->isRunning('TestModule'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox Getting language files for an invalid module returns an empty array
|
||||
* @covers phpOMS\Module\ModuleManager
|
||||
* @group framework
|
||||
*/
|
||||
public function testGetLanguageForInvalidRequest() : void
|
||||
{
|
||||
$request = new HttpRequest(new HttpUri('http://127.0.0.1/en/error/invalid'));
|
||||
|
|
@ -261,12 +266,6 @@ final class ModuleManagerTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertEquals([], $this->moduleManager->getLanguageFiles($request));
|
||||
}
|
||||
|
||||
public function testGetActiveModulesWithInvalidBasePath() : void
|
||||
{
|
||||
$this->moduleManager = new ModuleManager($this->app, __DIR__ . '/invalid');
|
||||
self::assertEquals([], $this->moduleManager->getActiveModules(false));
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox Installed modules can be returned
|
||||
* @covers phpOMS\Module\ModuleManager
|
||||
|
|
@ -279,21 +278,26 @@ final class ModuleManagerTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertNotEmpty($installed);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox A module can be checked if it is installed
|
||||
* @covers phpOMS\Module\ModuleManager
|
||||
* @group framework
|
||||
*/
|
||||
public function testIsInstalled() : void
|
||||
{
|
||||
self::assertTrue($this->moduleManager->isInstalled('TestModule'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox Installing an already installed module doesn't perform anything
|
||||
* @covers phpOMS\Module\ModuleManager
|
||||
* @group framework
|
||||
*/
|
||||
public function testInstallingAlreadyInstalledModule() : void
|
||||
{
|
||||
self::assertTrue($this->moduleManager->install('TestModule'));
|
||||
}
|
||||
|
||||
public function testAvailableModules() : void
|
||||
{
|
||||
self::assertEquals([], $this->moduleManager->getAvailableModules());
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The valid module can be returned
|
||||
* @covers phpOMS\Module\ModuleManager
|
||||
|
|
@ -325,6 +329,7 @@ final class ModuleManagerTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox A empty or invalid module path returns an empty array on module getter functions.
|
||||
* @covers phpOMS\Module\ModuleManager
|
||||
* @group framework
|
||||
*/
|
||||
|
|
@ -334,9 +339,11 @@ final class ModuleManagerTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
self::assertEquals([], $moduleManager->getAllModules());
|
||||
self::assertEquals([], $moduleManager->getInstalledModules());
|
||||
self::assertEquals([], $moduleManager->getActiveModules(false));
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox A invalid module name cannot be installed
|
||||
* @covers phpOMS\Module\ModuleManager
|
||||
* @group framework
|
||||
*/
|
||||
|
|
@ -346,6 +353,7 @@ final class ModuleManagerTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox A invalid module name cannot be uninstalled
|
||||
* @covers phpOMS\Module\ModuleManager
|
||||
* @group framework
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -43,6 +43,8 @@ final class NullModuleTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox The null module is an instance of the module abstract
|
||||
* @covers phpOMS\Module\NullModule
|
||||
* @group framework
|
||||
*/
|
||||
public function testModule() : void
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ use phpOMS\Module\ModuleInfo;
|
|||
use phpOMS\Module\StatusAbstract;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Module\StatusAbstractTest: Abstract module
|
||||
* @testdox phpOMS\tests\Module\StatusAbstractTest: Abstract module status
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
|
|
@ -40,6 +40,7 @@ final class StatusAbstractTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* A invalid module path cannot be activated
|
||||
* @covers phpOMS\Module\StatusAbstract
|
||||
* @group framework
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ use phpOMS\Module\ModuleInfo;
|
|||
use phpOMS\Module\UninstallerAbstract;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Module\UninstallerAbstractTest: Abstract module
|
||||
* @testdox phpOMS\tests\Module\UninstallerAbstractTest: Abstract module uninstaller
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
|
|
@ -41,6 +41,7 @@ final class UninstallerAbstractTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox A missing database schema will not perform any database operations
|
||||
* @covers phpOMS\Module\UninstallerAbstract
|
||||
* @group framework
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
use phpOMS\Router\RouteVerb;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\WebRouter\RouteVerbTest: Route verb enum
|
||||
* @internal
|
||||
*/
|
||||
final class RouteVerbTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox The route verb enum has the correct values
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
@ -37,10 +39,11 @@ final class RouteVerbTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox The route verb enum has only unique values
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
public function testEnumUnique() : void
|
||||
public function testUnique() : void
|
||||
{
|
||||
$values = RouteVerb::getConstants();
|
||||
self::assertEquals(\count($values), \array_sum(\array_count_values($values)));
|
||||
|
|
|
|||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
use phpOMS\System\CharsetType;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\System\CharsetTypeTest: Character set type enum
|
||||
* @internal
|
||||
*/
|
||||
final class CharsetTypeTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox The character set type enum has the correct amount of values
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
@ -33,6 +35,7 @@ final class CharsetTypeTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox The character set type enum has only unique values
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
@ -42,6 +45,7 @@ final class CharsetTypeTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox The character set type enum has the correct values
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
use phpOMS\System\MimeType;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\System\MimeTypeTest: MimeType
|
||||
* @internal
|
||||
*/
|
||||
final class MimeTypeTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox The mime type enum vales have the correct format
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
@ -31,7 +33,7 @@ final class MimeTypeTest extends \PHPUnit\Framework\TestCase
|
|||
{
|
||||
$enums = MimeType::getConstants();
|
||||
|
||||
foreach ($enums as $key => $value) {
|
||||
foreach ($enums as $value) {
|
||||
if (\stripos($value, '/') === false) {
|
||||
self::assertFalse(true);
|
||||
}
|
||||
|
|
@ -41,6 +43,7 @@ final class MimeTypeTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox The mime type enum vales can be retreived by extension
|
||||
* @covers phpOMS\System\MimeType
|
||||
* @group framework
|
||||
*/
|
||||
|
|
@ -50,6 +53,7 @@ final class MimeTypeTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox A unknown extension returns application/octet-stream
|
||||
* @covers phpOMS\System\MimeType
|
||||
* @group framework
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -20,11 +20,13 @@ use phpOMS\System\OperatingSystem;
|
|||
use phpOMS\System\SystemType;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\System\OperatingSystemTest: Operating system
|
||||
* @internal
|
||||
*/
|
||||
final class OperatingSystemTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox The current operating system can be returned
|
||||
* @covers phpOMS\System\OperatingSystem
|
||||
* @group framework
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
use phpOMS\System\SystemType;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\System\SystemTypeTest: System type
|
||||
* @internal
|
||||
*/
|
||||
final class SystemTypeTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox The system type enum has the correct amount of values
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
@ -33,6 +35,7 @@ final class SystemTypeTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox The system type enum has only unique values
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
@ -42,6 +45,7 @@ final class SystemTypeTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox The system type enum has the correct values
|
||||
* @group framework
|
||||
* @coversNothing
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ final class ArgumentTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox The path can be set and returned
|
||||
* @covers phpOMS\Uri\Argument
|
||||
* @group framework
|
||||
*/
|
||||
|
|
@ -89,66 +90,6 @@ final class ArgumentTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertEquals('modules/admin/new/path', $obj->getPath());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers phpOMS\Uri\Argument
|
||||
* @group framework
|
||||
*/
|
||||
public function testSchemeInputOutput() : void
|
||||
{
|
||||
$obj = new Argument(':modules/admin/test/path.php ?para1=abc ?para2=2 #frag');
|
||||
|
||||
$obj->scheme = 'scheme';
|
||||
self::assertEquals('scheme', $obj->scheme);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers phpOMS\Uri\Argument
|
||||
* @group framework
|
||||
*/
|
||||
public function testUserInputOutput() : void
|
||||
{
|
||||
$obj = new Argument(':modules/admin/test/path.php ?para1=abc ?para2=2 #frag');
|
||||
|
||||
$obj->user = 'user';
|
||||
self::assertEquals('user', $obj->user);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers phpOMS\Uri\Argument
|
||||
* @group framework
|
||||
*/
|
||||
public function testPassInputOutput() : void
|
||||
{
|
||||
$obj = new Argument(':modules/admin/test/path.php ?para1=abc ?para2=2 #frag');
|
||||
|
||||
$obj->pass = 'pass';
|
||||
self::assertEquals('pass', $obj->pass);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers phpOMS\Uri\Argument
|
||||
* @group framework
|
||||
*/
|
||||
public function testHostInputOutput() : void
|
||||
{
|
||||
$obj = new Argument(':modules/admin/test/path.php ?para1=abc ?para2=2 #frag');
|
||||
|
||||
$obj->host = 'host';
|
||||
self::assertEquals('host', $obj->host);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers phpOMS\Uri\Argument
|
||||
* @group framework
|
||||
*/
|
||||
public function testPortInputOutput() : void
|
||||
{
|
||||
$obj = new Argument(':modules/admin/test/path.php ?para1=abc ?para2=2 #frag');
|
||||
|
||||
$obj->port = 123;
|
||||
self::assertEquals(123, $obj->port);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The path offset can be set and returned
|
||||
* @covers phpOMS\Uri\Argument
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ final class HttpUriTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox The url schema can be parsed correctly from a url
|
||||
* @testdox The url schema can be parsed correctly from a url and overwritten
|
||||
* @covers phpOMS\Uri\HttpUri
|
||||
* @group framework
|
||||
*/
|
||||
|
|
@ -71,6 +71,7 @@ final class HttpUriTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox The port can be parsed correctly from a url and overwritten
|
||||
* @covers phpOMS\Uri\HttpUri
|
||||
* @group framework
|
||||
*/
|
||||
|
|
@ -191,6 +192,7 @@ final class HttpUriTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox A path can be overwritten
|
||||
* @covers phpOMS\Uri\HttpUri
|
||||
* @group framework
|
||||
*/
|
||||
|
|
@ -203,6 +205,7 @@ final class HttpUriTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox The path elements can be parsed from a url and overwritten
|
||||
* @covers phpOMS\Uri\HttpUri
|
||||
* @group framework
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -19,11 +19,13 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
use phpOMS\Uri\InvalidUriException;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Uri\InvalidUriExceptionTest: Invalid uri exception
|
||||
* @internal
|
||||
*/
|
||||
final class InvalidUriExceptionTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox The invalid uri exception is an unexpected value exception
|
||||
* @covers phpOMS\Uri\InvalidUriException
|
||||
* @group framework
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -240,7 +240,7 @@ final class UriFactoryTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox In case of missing ? for query the builder automatically fixes it
|
||||
* @testdox A normal url will not be changed
|
||||
* @covers phpOMS\Uri\UriFactory
|
||||
* @group framework
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user