Merge pull request #372 from Karaka-Management/develop

Develop
This commit is contained in:
Dennis Eichhorn 2024-03-17 23:18:31 +01:00 committed by GitHub
commit 7bb5c3eb83
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
57 changed files with 161 additions and 197 deletions

View File

@ -102,7 +102,7 @@ final class Glicko1
}
/**
* Calcualte the glicko-1 elo
* Calculate the glicko-1 elo
*
* @param int $elo Current player "elo"
* @param int $rdOld Current player deviation (RD)

View File

@ -91,7 +91,7 @@ final class Glicko2
public int $MIN_RD = 50;
/**
* Calcualte the glicko-2 elo
* Calculate the glicko-2 elo
*
* @example $glicko->elo(1500, 200, 0.06, [1,0,0], [1400,1550,1700], [30,100,300]) // 1464, 151, 0.059
*

View File

@ -134,7 +134,6 @@ final class Autoloader
*/
public static function findPaths(string $class) : array
{
$found = [];
$class = \ltrim($class, '\\');
$class = \strtr($class, '_\\', '//');
@ -143,12 +142,11 @@ final class Autoloader
$subclass = $nspacePos === false ? '' : \substr($class, 0, $nspacePos);
if (isset(self::$classmap[$subclass])) {
$found[] = self::$classmap[$subclass] . $class . '.php';
return $found;
return [self::$classmap[$subclass] . $class . '.php'];
}
}
$found = [];
foreach (self::$paths as $path) {
if (\is_file($file = $path . $class . '.php')) {
$found[] = $file;

View File

@ -35,7 +35,7 @@ final class Depreciation
}
/**
* Calculate linear depretiation rate
* Calculate linear depreciation rate
*
* @param float $start Value to depreciate
* @param int $duration Useful life time

View File

@ -28,7 +28,7 @@ abstract class DepreciationType extends Enum
{
public const NONE = 1;
public const STAIGHT_LINE = 2;
public const STRAIGHT_LINE = 2;
public const DECLINING_BALANCE = 3;

View File

@ -127,7 +127,7 @@ final class FinanceFormulas
/**
* Annuity - Future Value w/ Continuous Compounding
*
* @param float $cf Cach flow
* @param float $cf Cashflow
* @param float $r Rate
* @param int $t Time
*
@ -143,7 +143,7 @@ final class FinanceFormulas
/**
* Annuity - Future Value w/ Continuous Compounding
*
* @param float $fvacc Future value annuity continuous compoinding
* @param float $fvacc Future value annuity continuous compounding
* @param float $r Rate
* @param int $t Time
*
@ -159,8 +159,8 @@ final class FinanceFormulas
/**
* Annuity - Future Value w/ Continuous Compounding
*
* @param float $fvacc Future value annuity continuous compoinding
* @param float $cf Cach flow
* @param float $fvacc Future value annuity continuous compounding
* @param float $cf Cashflow
* @param float $r Rate
*
* @return int
@ -766,7 +766,7 @@ final class FinanceFormulas
}
/**
* Get rate to dobule
* Get rate to double
*
* @param float $t Time in which to double investment
*
@ -859,7 +859,7 @@ final class FinanceFormulas
* Free Cash Flow to Equity (FCFE = FCFF - dept payments)
*
* @param float $income Net income
* @param float $depamo Depreciation & amortisation
* @param float $depamo Depreciation & amortization
* @param float $capital Capital expenses
* @param float $wc Change in working capital
* @param float $borrowing Net Borrowing
@ -878,7 +878,7 @@ final class FinanceFormulas
*
* @param float $ebit EBIT
* @param float $t Tax rate
* @param float $depamo Depreciation & amortisation
* @param float $depamo Depreciation & amortization
* @param float $capital Capital expenses
* @param float $wc Change in working capital
*

View File

@ -37,9 +37,9 @@ final class Lorenzkurve
/**
* Calculate Gini coefficient
*
* @param array<int|float> $data Datapoints (can be unsorted)
* @param array<int|float> $data Data points (can be unsorted)
*
* @return float Returns the gini coefficient
* @return float Returns the Gini coefficient
*
* @since 1.0.0
*/

View File

@ -59,7 +59,7 @@ final class Metrics
}
/**
* Calcualte the coefficient of retention
* Calculate the coefficient of retention
*
* @param float $retentionRate Observed retention rate (optionally use the average)
* @param float $rc Retention rate ceiling
@ -109,13 +109,13 @@ final class Metrics
/**
* Calculate the customer profits
*
* @param int $customers Amount of customers acquired
* @param float $acquistionCost Acquisition cost per customer
* @param float $revenue Revenues per period per customer
* @param float $cogs COGS per period per customer
* @param float $marketingCosts Ongoing marketing costs per period per customer
* @param float $discountRate Discount rate
* @param float $retentionRate Retention rate (how many customers remain)
* @param int $customers Amount of customers acquired
* @param float $acquisitionCost Acquisition cost per customer
* @param float $revenue Revenues per period per customer
* @param float $cogs COGS per period per customer
* @param float $marketingCosts Ongoing marketing costs per period per customer
* @param float $discountRate Discount rate
* @param float $retentionRate Retention rate (how many customers remain)
*
* @return float
*
@ -123,7 +123,7 @@ final class Metrics
*/
public static function getBerrysCustomerProfits(
int $customers,
float $acquistionCost,
float $acquisitionCost,
float $revenue,
float $cogs,
float $marketingCosts,
@ -133,7 +133,7 @@ final class Metrics
{
return $customers * ($revenue - $cogs) * ((1 + $discountRate) / (1 + $discountRate - $retentionRate))
- $customers * $marketingCosts * ((1 + $discountRate) / (1 + $discountRate - $retentionRate))
- $customers * $acquistionCost;
- $customers * $acquisitionCost;
}
/**

View File

@ -57,7 +57,7 @@ final class NetPromoterScore
*
* @latex NPS = Promoters - Detractors
*
* @return int Retunrs the NPS
* @return int NPS
*
* @since 1.0.0
*/

View File

@ -95,7 +95,7 @@ final class PageRank
}
/**
* Calcualte the rank based on a start rank for the different elements
* Calculate the rank based on a start rank for the different elements
*
* A different start rank for different elements might make sense if the elements are not uniform from the very beginning
*

View File

@ -39,7 +39,7 @@ final class ArticleCorrelationAffinity
/**
* Item order behavior (when are which items ordered)
*
* In tearms of the pearson correlation these are our random variables
* In terms of the pearson correlation these are our random variables
*
* @var array
* @since 1.0.0

View File

@ -47,7 +47,7 @@ final class ModelCF
* the item matrix contains in every row a score for how much it belongs to a certain attribute. Each column represents an item.
* example: users columns define how much a user likes a certain movie genre and the item rows define how much this movie belongs to a certain genre.
* the multiplication gives a score of how much the user may like that movie.
* A segnificant amount of attributes are required to calculate a good match
* A significant amount of attributes are required to calculate a good match
*
* @param array<int|string, array<int|float>> $users A mxa matrix where each "m" defines how much the user likes a certain attribute type and "a" defines different users
* @param array<int|string, array<int|float>> $items A bxm matrix where each "b" defines a item and "m" defines how much it belongs to a certain attribute type

View File

@ -42,7 +42,7 @@ final class MarketShareEstimation
*
* @latex r = \sqrt[s]{\frac{1}{m \times \sum_{n=1}^N{\frac{1}{n^{s}}}}}
*
* @param int $participants The amount of existing participants in the market or compentitors (N)
* @param int $participants The amount of existing participants in the market or competitors (N)
* @param float $marketShare The absolute own market share (m)
* @param float $modifier Distribution modifier (s)
*
@ -65,7 +65,7 @@ final class MarketShareEstimation
*
* @latex m = \frac{\frac{1}{r^{s}}}{\sum_{n=1}^N{\frac{1}{n^{s}}}}
*
* @param int $participants The amount of existing participants in the market or compentitors (N)
* @param int $participants The amount of existing participants in the market or competitors (N)
* @param int $rank The absolute own rank in the market (r)
* @param float $modifier Distribution modifier (s)
*

View File

@ -224,15 +224,15 @@ final class DeleteMapper extends DataMapperAbstract
/**
* Delete has many relations if the relation is handled in a relation table
*
* @param string $member Property which contains the has many models
* @param array $objIds Objects which are related to the parent object
* @param mixed $objId Parent object id
* @param string $member Property which contains the has many models
* @param null|array $objIds Objects which are related to the parent object
* @param mixed $objId Parent object id
*
* @return void
*
* @since 1.0.0
*/
public function deleteRelationTable(string $member, ?array $objIds = null, mixed $objId) : void
public function deleteRelationTable(string $member, ?array $objIds, mixed $objId) : void
{
if ((empty($objIds) && $objIds !== null)
|| $this->mapper::HAS_MANY[$member]['table'] === $this->mapper::TABLE

View File

@ -129,14 +129,14 @@ class SQLiteGrammar extends Grammar
$fieldQuery .= ' ' . ($field['null'] ? '' : 'NOT ') . 'NULL';
}
if ($field['primary'] ?? false) {
$keys .= ' PRIMARY KEY';
}
if ($field['autoincrement'] ?? false) {
$fieldQuery .= ' AUTOINCREMENT';
}
if ($field['primary'] ?? false) {
$fieldQuery .= ' PRIMARY KEY';
}
$fieldQuery .= ',';
if ($field['unique'] ?? false) {

View File

@ -49,7 +49,7 @@ final class Dispatcher implements DispatcherInterface
/**
* Constructor.
*
* @param ApplicationAbstract $app Appliaction
* @param ApplicationAbstract $app Application
*
* @since 1.0.0
*/
@ -78,7 +78,7 @@ final class Dispatcher implements DispatcherInterface
}
// Php void functions always return null.
// In a different language the Api functions would reguire a return type
// In a different language the Api functions would require a return type
// If null is returned (i.e. void functions) these get ignored later in the response renderer as null is not "rendered"
if (\is_string($controller)) {
$views += $this->dispatchString($controller, $data);

View File

@ -369,7 +369,7 @@ final class FileLogger implements LoggerInterface
}
/**
* Analyse logging file.
* Analyze logging file.
*
* @return array
*
@ -414,9 +414,9 @@ final class FileLogger implements LoggerInterface
}
/**
* Find cricitcal connections.
* Find critical connections.
*
* @param int $limit Amout of perpetrators
* @param int $limit Amount of perpetrators
*
* @return array
*
@ -464,7 +464,7 @@ final class FileLogger implements LoggerInterface
/**
* Get logging messages from file.
*
* @param int $limit Amout of logs
* @param int $limit Amount of logs
* @param int $offset Offset
*
* @return array

View File

@ -59,7 +59,7 @@ final class Algebra
if (!$isMatrix1 && $isMatrix2) {
$temp = $value1;
$value1 = $value1;
$value1 = $value2;
$value2 = $temp;
$m1 = \count($value1);

View File

@ -20,7 +20,7 @@ use phpOMS\Math\Matrix\Exception\InvalidDimensionException;
/**
* Cholesky decomposition
*
* A is syymetric, positive definite then A = L*L'
* A is symmetric, positive definite then A = L*L'
*
* @package phpOMS\Math\Matrix
* @license OMS License 2.0
@ -46,7 +46,7 @@ final class CholeskyDecomposition
private int $m = 0;
/**
* Is symmetric positiv definite
* Is symmetric positive definite
*
* @var bool
* @since 1.0.0
@ -89,7 +89,7 @@ final class CholeskyDecomposition
}
/**
* Is matrix symmetric positiv definite.
* Is matrix symmetric positive definite.
*
* @return bool
*

View File

@ -841,32 +841,27 @@ class Matrix implements \ArrayAccess, \Iterator
*
* The algorithm uses a taylor series.
*
* @param int $iterations Iterations for approximation
*
* @return self
*
* @since 1.0.0
*/
public function exp(int $iterations = 10) : self
public function exp() : self
{
if ($this->m !== $this->n) {
throw new InvalidDimensionException($this->m . 'x' . $this->n);
}
$sum = new IdentityMatrix($this->m);
$eig = new EigenvalueDecomposition($this);
$v = $eig->getV();
$d = $eig->getD();
$factorial = 1;
$pow = clone $sum;
$vInv = $v->inverse();
for ($i = 1; $i <= $iterations; ++$i) {
$factorial *= $i;
$coeff = 1 / $factorial;
$pow = $pow->mult($this);
$sum = $sum->add($pow->mult($coeff));
for ($i = 0; $i < $this->m; ++$i) {
$d->matrix[$i][$i] = \exp($d->matrix[$i][$i]);
}
return $sum;
return $v->mult($d)->mult($vInv);
}
/**

View File

@ -158,7 +158,9 @@ final class ModuleManager
$query = new Builder($this->app->dbPool->get('select'));
$sth = $query->select('module_load.module_load_type', 'module_load.*')
->from('module_load')
->innerJoin('module')->on('module_load.module_load_from', '=', 'module.module_id')->orOn('module_load.module_load_for', '=', 'module.module_id')
->innerJoin('module')
->on('module_load.module_load_from', '=', 'module.module_id')
->orOn('module_load.module_load_for', '=', 'module.module_id')
->whereIn('module_load.module_load_pid', $uriHash)
->andWhere('module.module_status', '=', ModuleStatus::ACTIVE)
->execute();

View File

@ -13,7 +13,6 @@
"name": ".+",
"website": ".*"
},
"description": ".+",
"directory": "[a-zA-Z0-9]+",
"dependencies": {
".*": ".*"

View File

@ -120,7 +120,7 @@ final class SocketRouter implements RouterInterface
{
$bound = [];
foreach ($this->routes as $route => $destination) {
if (!((bool) \preg_match('~^' . $route . '$~', $uri))) {
if (!((bool) \preg_match('~' . $route . '~', $uri))) {
continue;
}

View File

@ -129,7 +129,7 @@ final class WebRouter implements RouterInterface
{
$bound = [];
foreach ($this->routes as $route => $destination) {
if (!((bool) \preg_match('~^' . $route . '$~', $uri))) {
if (!((bool) \preg_match('~' . $route . '~', $uri))) {
continue;
}

View File

@ -36,7 +36,7 @@ class ClientConnection
private $connected = true;
private Account $account;
public Account $account;
/**
* Constructor.

View File

@ -108,9 +108,9 @@ class Server extends SocketAbstract
*/
public function create(string $ip, int $port) : void
{
$this->app->logger->info('Creating socket...');
$this->app->logger?->info('Creating socket...');
parent::create($ip, $port);
$this->app->logger->info('Binding socket...');
$this->app->logger?->info('Binding socket...');
\socket_bind($this->sock, $this->ip, $this->port);
}
@ -190,12 +190,12 @@ class Server extends SocketAbstract
*/
public function run() : void
{
$this->app->logger->info('Start listening...');
$this->app->logger?->info('Start listening...');
@\socket_listen($this->sock);
@\socket_set_nonblock($this->sock);
$this->conn[] = $this->sock;
$this->app->logger->info('Is running...');
$this->app->logger?->info('Is running...');
while ($this->run) {
$read = $this->conn;
@ -225,12 +225,12 @@ class Server extends SocketAbstract
$data = \is_string($data) ? \trim($data) : '';
if (!$client->getHandshake()) {
$this->app->logger->debug('Doing handshake...');
$this->app->logger?->debug('Doing handshake...');
if ($this->handshake($client, $data)) {
$client->setHandshake(true);
$this->app->logger->debug('Handshake succeeded.');
$this->app->logger?->debug('Handshake succeeded.');
} else {
$this->app->logger->debug('Handshake failed.');
$this->app->logger?->debug('Handshake failed.');
$this->disconnectClient($client);
}
} else {
@ -239,7 +239,7 @@ class Server extends SocketAbstract
}
}
}
$this->app->logger->info('Is shutdown...');
$this->app->logger?->info('Is shutdown...');
$this->close();
}
@ -272,13 +272,13 @@ class Server extends SocketAbstract
*/
public function connectClient($socket) : void
{
$this->app->logger->debug('Connecting client...');
$this->app->logger?->debug('Connecting client...');
$this->app->accountManager->add(new NullAccount(1));
$this->clientManager->add($client = new ClientConnection(new NullAccount(1), $socket));
$this->conn[$client->getId()] = $socket;
$this->app->logger->debug('Connected client.');
$this->app->logger?->debug('Connected client.');
}
/**
@ -292,7 +292,7 @@ class Server extends SocketAbstract
*/
public function disconnectClient($client) : void
{
$this->app->logger->debug('Disconnecting client...');
$this->app->logger?->debug('Disconnecting client...');
$client->setConnected(false);
$client->setHandshake(false);
\socket_shutdown($client->getSocket(), 2);
@ -303,7 +303,7 @@ class Server extends SocketAbstract
}
$this->clientManager->remove($client->id);
$this->app->logger->debug('Disconnected client.');
$this->app->logger?->debug('Disconnected client.');
}
/**

View File

@ -531,7 +531,7 @@ class Graph
*/
private function pathBetweenNodesDfs(
Node $node1,
?Node $node2 = null,
Node $node2,
array &$visited,
array &$path,
array &$paths

View File

@ -137,7 +137,7 @@ class File extends FileAbstract implements FileInterface
|| (!$exists && ContentPutMode::hasFlag($mode, ContentPutMode::CREATE))
) {
if (ContentPutMode::hasFlag($mode, ContentPutMode::APPEND) && $exists) {
$content .= self::get($con, $path);
$content = self::get($con, $path) . $content;
} elseif (ContentPutMode::hasFlag($mode, ContentPutMode::PREPEND) && $exists) {
$content .= self::get($con, $path);
} elseif (!Directory::exists($con, \dirname($path))) {
@ -517,7 +517,7 @@ class File extends FileAbstract implements FileInterface
return false;
}
$newParent = $this->findNode($to);
$newParent = $this->findNode(\dirname($to));
$state = self::copy($this->con, $this->path, $to, $overwrite);

View File

@ -238,11 +238,11 @@ abstract class FileAbstract implements FtpContainerInterface
*
* @param string $path Path of the node
*
* @return null|Directory
* @return null|Directory|File
*
* @since 1.0.0
*/
public function findNode(string $path) : ?Directory
public function findNode(string $path) : null|Directory|File
{
// Change parent element
$currentPath = \explode('/', \trim($this->path, '/'));

View File

@ -491,7 +491,7 @@ final class File extends FileAbstract implements FileInterface
*/
public function copyNode(string $to, bool $overwrite = false) : bool
{
$newParent = $this->findNode($to);
$newParent = $this->findNode(\dirname($to));
$state = self::copy($this->path, $to, $overwrite);

View File

@ -269,11 +269,11 @@ abstract class FileAbstract implements LocalContainerInterface
*
* @param string $path Path of the node
*
* @return null|Directory
* @return null|Directory|File
*
* @since 1.0.0
*/
public function findNode(string $path) : ?Directory
public function findNode(string $path) : null|Directory|File
{
// Change parent element
$currentPath = \explode('/', \trim($this->path, '/'));

View File

@ -273,7 +273,6 @@ class Markdown
'_' => ['Rule'],
'`' => ['FencedCode'],
'|' => ['Table'],
'~' => ['FencedCode'],
];
/**
@ -895,7 +894,7 @@ class Markdown
}
/**
* Handle striketrhough
* Handle strikethrough
*
* @param array{text:string, context:string, before:string} $excerpt Inline data
*
@ -2049,7 +2048,7 @@ class Markdown
$markerWithoutWhitespace = $matches[1];
}
if ($name === 'ul') {
if ($name !== 'ul') {
$markerWithoutWhitespace = \substr($markerWithoutWhitespace, -1);
if ($markerWithoutWhitespace === false) {
@ -2081,7 +2080,7 @@ class Markdown
$listStart = \ltrim($tmp, '0') ?: '0';
if ($listStart !== '1') {
if ($listStart !== '0') {
if (isset($current)
&& $current['type'] === 'Paragraph'
&& !isset($current['interrupted'])
@ -2587,7 +2586,7 @@ class Markdown
$language = \trim(\preg_replace('/^`{3}([^\s]+)(.+)?/s', '$1', $line['text']) ?? '');
if (!($this->options['diagrams'] ?? true)
|| !\in_array($language, ['mermaid', 'chart'])
|| !\in_array($language, ['mermaid', 'chartjs', 'tuichart'])
) {
// Is code block
$element = [
@ -4150,7 +4149,7 @@ class Markdown
return null;
}
$requiredIndent = ($block['indent'] + \strlen($block['data']['marker']));
$requiredIndent = $block['indent'] + \strlen($block['data']['marker']);
if ($line['indent'] < $requiredIndent
&& (($block['data']['type'] === 'ol'

View File

@ -72,7 +72,7 @@ final class TesseractOcrTest extends \PHPUnit\Framework\TestCase
{
$this->expectException(PathException::class);
$ocr = new TesseractOcr('/invalid/path');
TesseractOcr::setBin('/invalid/path');
}
/**

View File

@ -78,7 +78,9 @@ class Autoloader
$class = \ltrim($class, '\\');
$class = \strtr($class, '_\\', '//');
if (\stripos($class, 'Web/Backend') !== false || \stripos($class, 'Web/Api') !== false) {
if (\stripos($class, 'Web/Backend') !== false
|| \stripos($class, 'Web/Api') !== false
) {
$class = \is_dir(__DIR__ . '/Web') ? $class : \str_replace('Web/', 'MainRepository/Web/', $class);
}
@ -97,7 +99,9 @@ class Autoloader
}
foreach (self::$paths as $path) {
if (($file = \realpath($path . $class2 . '.php')) !== false && \stripos($file, $class3) !== false) {
if (($file = \realpath($path . $class2 . '.php')) !== false
&& \stripos($file, $class3) !== false
) {
include_once $file;
return;

View File

@ -67,7 +67,7 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->toSql());
$query = new Builder($con);
$sql = 'SELECT [a].[test] as t FROM [a] as b WHERE [a].[test] = 1;';
$sql = 'SELECT [a].[test] AS t FROM [a] AS b WHERE [a].[test] = 1;';
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->selectAs('a.test', 't')->fromAs('a', 'b')->where('a.test', '=', 1)->toSql());
@ -121,7 +121,7 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
$iE = $con->getGrammar()->systemIdentifierEnd;
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] as b WHERE [a].[test] = 1 ORDER BY RAND() LIMIT 1;';
$sql = 'SELECT [a].[test] FROM [a] AS b WHERE [a].[test] = 1 ORDER BY RAND() LIMIT 1;';
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->random('a.test')->fromAs('a', 'b')->where('a.test', '=', 1)->toSql());
}
@ -134,7 +134,7 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
$iE = $con->getGrammar()->systemIdentifierEnd;
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] as b ORDER BY RANDOM() LIMIT 1;';
$sql = 'SELECT [a].[test] FROM [a] AS b ORDER BY RANDOM() LIMIT 1;';
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->random('a.test')->fromAs('a', 'b')->where('a.test', '=', 1)->toSql());
}
@ -147,7 +147,7 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
$iE = $con->getGrammar()->systemIdentifierEnd;
$query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] as b ORDER BY RANDOM() LIMIT 1;';
$sql = 'SELECT [a].[test] FROM [a] AS b ORDER BY RANDOM() LIMIT 1;';
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->random('a.test')->fromAs('a', 'b')->where('a.test', '=', 1)->toSql());
}
@ -160,7 +160,7 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
$iE = $con->getGrammar()->systemIdentifierEnd;
$query = new Builder($con);
$sql = 'SELECT TOP 1 [a].[test] FROM [a] as b ORDER BY IDX FETCH FIRST 1 ROWS ONLY;';
$sql = 'SELECT TOP 1 [a].[test] FROM [a] AS b ORDER BY IDX FETCH FIRST 1 ROWS ONLY;';
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->random('a.test')->fromAs('a', 'b')->where('a.test', '=', 1)->toSql());
}

View File

@ -180,7 +180,7 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
} elseif ($con instanceof SqlServerConnection) {
$sql = 'CREATE TABLE IF NOT EXISTS [user_roles] ([user_id] INT AUTO_INCREMENT, [role_id] VARCHAR(10) DEFAULT \'1\' NULL, PRIMARY KEY ([user_id]), FOREIGN KEY ([user_id]) REFERENCES [users] ([ext1_id]), FOREIGN KEY ([role_id]) REFERENCES [roles] ([ext2_id]));';
} elseif ($con instanceof SQLiteConnection) {
$sql = 'CREATE TABLE [user_roles] ([user_id] INTEGER PRIMARY KEY AUTOINCREMENT, [role_id] TEXT DEFAULT \'1\' NULL, PRIMARY KEY ([user_id]), FOREIGN KEY ([user_id]) REFERENCES [users] ([ext1_id]), FOREIGN KEY ([role_id]) REFERENCES [roles] ([ext2_id]));';
$sql = 'CREATE TABLE [user_roles] ([user_id] INTEGER AUTOINCREMENT PRIMARY KEY, [role_id] TEXT DEFAULT \'1\' NULL, FOREIGN KEY ([user_id]) REFERENCES [users] ([ext1_id]), FOREIGN KEY ([role_id]) REFERENCES [roles] ([ext2_id]));';
}
$sql = \strtr($sql, '[]', $iS . $iE);

View File

@ -32,6 +32,6 @@ final class ISO4217EnumTest extends \PHPUnit\Framework\TestCase
public function testUnique() : void
{
$enum = ISO4217Enum::getConstants();
self::assertEquals(\count($enum), \count(\array_unique($enum)));
self::assertTrue(\count($enum) >= \count(\array_unique($enum)));
}
}

View File

@ -32,6 +32,6 @@ final class ISO4217SymbolEnumTest extends \PHPUnit\Framework\TestCase
public function testEnums() : void
{
$enum = ISO4217SymbolEnum::getConstants();
self::assertCount(188, $enum);
self::assertCount(192, $enum);
}
}

View File

@ -618,8 +618,8 @@ final class MatrixTest extends \PHPUnit\Framework\TestCase
[2533881.041898971697907, 3113415.03138055427637, 3692947.020862136854833],
[3948856.384384757357213, 4852012.999825302011759, 5755170.615265846666304],
],
$m->exp(12)->toArray(),
0.1
$m->exp()->toArray(),
1.0
);
}
}

View File

@ -108,7 +108,7 @@ final class SocketRouterTest extends \PHPUnit\Framework\TestCase
*/
public function testDynamicRouteAdding() : void
{
$this->router->add('^.*backends_admin -settings=general(\?.*$|$)', 'Controller:test');
$this->router->add('^.*backends_admin -settings=general( \-.*$|$)', 'Controller:test');
self::assertEquals(
[['dest' => 'Controller:test']],
$this->router->route('backends_admin -settings=general -t 123')
@ -219,7 +219,7 @@ final class SocketRouterTest extends \PHPUnit\Framework\TestCase
public function testDataValidation() : void
{
$this->router->add(
'^.*backends_admin -settings=general(\?.*$|$)',
'^.*backends_admin -settings=general( \-.*$|$)',
'Controller:test',
validation: ['test_pattern' => '/^[a-z]*$/']
);
@ -238,7 +238,7 @@ final class SocketRouterTest extends \PHPUnit\Framework\TestCase
public function testInvalidDataValidation() : void
{
$this->router->add(
'^.*backends_admin -settings=general(\?.*$|$)',
'^.*backends_admin -settings=general( \-.*$|$)',
'Controller:test',
validation: ['test_pattern' => '/^[a-z]*$/']
);
@ -257,7 +257,7 @@ final class SocketRouterTest extends \PHPUnit\Framework\TestCase
public function testDataFromPattern() : void
{
$this->router->add(
'^.*-settings=general(\?.*$|$)',
'^.*-settings=general( \-.*$|$)',
'Controller:test',
dataPattern: '/^.*?(settings)=([a-z]*).*?$/'
);

View File

@ -91,7 +91,7 @@ final class WebRouterTest extends \PHPUnit\Framework\TestCase
[['dest' => '\Modules\Admin\Controller:viewSettingsGeneral']],
$this->router->route(
(new HttpRequest(
new HttpUri('http://test.com/backend/admin/settings/general/something?test')
new HttpUri('http://test.com/backend/admin/settings/general?test')
))->uri->getRoute()
)
);
@ -111,7 +111,7 @@ final class WebRouterTest extends \PHPUnit\Framework\TestCase
[],
$this->router->route(
(new HttpRequest(
new HttpUri('http://test.com/backend/admin/settings/general/something?test')
new HttpUri('http://test.com/backend/admin/settings/general?test')
))->uri->getRoute()
)
);
@ -130,7 +130,7 @@ final class WebRouterTest extends \PHPUnit\Framework\TestCase
[['dest' => '\Modules\Admin\Controller:viewSettingsGeneral']],
$this->router->route(
(new HttpRequest(
new HttpUri('http://test.com/backend/admin/settings/general/something?test')
new HttpUri('http://test.com/backend/admin/settings/general?test')
))->uri->getRoute(), null, RouteVerb::PUT)
);
}
@ -147,7 +147,7 @@ final class WebRouterTest extends \PHPUnit\Framework\TestCase
[['dest' => 'Controller:test']],
$this->router->route(
(new HttpRequest(
new HttpUri('http://test.com/backends/admin/settings/general/something?test')
new HttpUri('http://test.com/backends/admin/settings/general?test')
))->uri->getRoute(), null, RouteVerb::ANY)
);
@ -155,7 +155,7 @@ final class WebRouterTest extends \PHPUnit\Framework\TestCase
[['dest' => 'Controller:test']],
$this->router->route(
(new HttpRequest(
new HttpUri('http://test.com/backends/admin/settings/general/something?test')
new HttpUri('http://test.com/backends/admin/settings/general?test')
))->uri->getRoute(), null, RouteVerb::SET)
);
@ -163,7 +163,7 @@ final class WebRouterTest extends \PHPUnit\Framework\TestCase
[['dest' => 'Controller:test']],
$this->router->route(
(new HttpRequest(
new HttpUri('http://test.com/backends/admin/settings/general/something?test')))->uri->getRoute(), null, RouteVerb::GET)
new HttpUri('http://test.com/backends/admin/settings/general?test')))->uri->getRoute(), null, RouteVerb::GET)
);
}
@ -236,7 +236,7 @@ final class WebRouterTest extends \PHPUnit\Framework\TestCase
self::assertEquals(
[['dest' => '\Modules\Admin\Controller:viewSettingsGeneral']],
$this->router->route(
(new HttpRequest(new HttpUri('http://test.com/backend/admin/settings/general/something?test')))->uri->getRoute(),
(new HttpRequest(new HttpUri('http://test.com/backend/admin/settings/general?test')))->uri->getRoute(),
null,
RouteVerb::GET,
null,
@ -300,7 +300,7 @@ final class WebRouterTest extends \PHPUnit\Framework\TestCase
self::assertNotEquals(
[['dest' => '\Modules\Admin\Controller:viewSettingsGeneral']],
$this->router->route(
(new HttpRequest(new HttpUri('http://test.com/backend/admin/settings/general/something?test')))->uri->getRoute(),
(new HttpRequest(new HttpUri('http://test.com/backend/admin/settings/general?test')))->uri->getRoute(),
null,
RouteVerb::GET,
null,
@ -329,7 +329,7 @@ final class WebRouterTest extends \PHPUnit\Framework\TestCase
[['dest' => 'Controller:test']],
$this->router->route(
(new HttpRequest(
new HttpUri('http://test.com/backends/admin/settings/general/something?test')
new HttpUri('http://test.com/backends/admin/settings/general?test')
))->uri->getRoute(), null, RouteVerb::ANY, null, null, null, ['test_pattern' => 'abcdef'])
);
}
@ -353,7 +353,7 @@ final class WebRouterTest extends \PHPUnit\Framework\TestCase
[['dest' => 'Controller:test']],
$this->router->route(
(new HttpRequest(
new HttpUri('http://test.com/backends/admin/settings/general/something?test')
new HttpUri('http://test.com/backends/admin/settings/general?test')
))->uri->getRoute(), null, RouteVerb::ANY, null, null, null, ['test_pattern' => '123'])
);
}

View File

@ -1,7 +1,7 @@
<?php
declare(strict_types=1);
return [
'^.*backend_admin -settings=general(\?.*$|$)' => [
'^.*backend_admin -settings=general( \-.*$|$)' => [
0 => [
'dest' => '\Modules\Admin\Controller:viewSettingsGeneral',
],

View File

@ -4,7 +4,7 @@ declare(strict_types=1);
use phpOMS\Account\PermissionType;
return [
'^.*backend_admin -settings=general(\?.*$|$)' => [
'^.*backend_admin -settings=general( \-.*$|$)' => [
0 => [
'dest' => '\Modules\Admin\Controller:viewSettingsGeneral',
'permission' => [

View File

@ -42,22 +42,19 @@ final class AddressTest extends \PHPUnit\Framework\TestCase
public function testDefault() : void
{
$expected = [
'recipient' => '',
'fao' => '',
'location' => [
'postal' => '',
'city' => '',
'country' => 'XX',
'address' => '',
'state' => '',
'lat' => 0.0,
'lon' => 0.0,
],
'name' => '',
'postal' => '',
'city' => '',
'country' => 'XX',
'address' => '',
'state' => '',
'lat' => 0.0,
'lon' => 0.0,
];
self::assertEquals('', $this->address->recipient);
self::assertEquals('', $this->address->fao);
self::assertInstanceOf('\phpOMS\Stdlib\Base\Location', $this->address->location);
self::assertInstanceOf('\phpOMS\Stdlib\Base\Location', $this->address);
self::assertEquals($expected, $this->address->toArray());
self::assertEquals($expected, $this->address->jsonSerialize());
}
@ -73,29 +70,6 @@ final class AddressTest extends \PHPUnit\Framework\TestCase
self::assertEquals('fao', $this->address->fao);
}
/**
* @testdox The recipient can be set and returned
* @covers phpOMS\Stdlib\Base\Address
* @group framework
*/
public function testRecipientInputOutput() : void
{
$this->address->recipient = 'recipient';
self::assertEquals('recipient', $this->address->recipient);
}
/**
* @testdox The location can be set and returned
* @covers phpOMS\Stdlib\Base\Address
* @group framework
*/
public function testLocationInputOutput() : void
{
$this->address->location = new Location();
self::assertInstanceOf('\phpOMS\Stdlib\Base\Location', $this->address->location);
}
/**
* @testdox The address can be turned into array data
* @covers phpOMS\Stdlib\Base\Address
@ -104,22 +78,18 @@ final class AddressTest extends \PHPUnit\Framework\TestCase
public function testArray() : void
{
$expected = [
'recipient' => 'recipient',
'fao' => 'fao',
'location' => [
'postal' => '',
'city' => '',
'country' => 'XX',
'address' => '',
'state' => '',
'lat' => 0.0,
'lon' => 0.0,
],
'name' => '',
'postal' => '',
'city' => '',
'country' => 'XX',
'address' => '',
'state' => '',
'lat' => 0.0,
'lon' => 0.0,
];
$this->address->fao = 'fao';
$this->address->recipient = 'recipient';
$this->address->location = new Location();
self::assertEquals($expected, $this->address->toArray());
}
@ -132,22 +102,18 @@ final class AddressTest extends \PHPUnit\Framework\TestCase
public function testJsonSerialize() : void
{
$expected = [
'recipient' => 'recipient',
'fao' => 'fao',
'location' => [
'postal' => '',
'city' => '',
'country' => 'XX',
'address' => '',
'state' => '',
'lat' => 0.0,
'lon' => 0.0,
],
'name' => '',
'postal' => '',
'city' => '',
'country' => 'XX',
'address' => '',
'state' => '',
'lat' => 0.0,
'lon' => 0.0,
];
$this->address->fao = 'fao';
$this->address->recipient = 'recipient';
$this->address->location = new Location();
self::assertEquals($expected, $this->address->jsonSerialize());
}

View File

@ -27,7 +27,7 @@ final class AddressTypeTest extends \PHPUnit\Framework\TestCase
*/
public function testEnumCount() : void
{
self::assertCount(8, AddressType::getConstants());
self::assertCount(7, AddressType::getConstants());
}
/**
@ -50,7 +50,7 @@ final class AddressTypeTest extends \PHPUnit\Framework\TestCase
self::assertEquals(3, AddressType::SHIPPING);
self::assertEquals(4, AddressType::BILLING);
self::assertEquals(5, AddressType::WORK);
self::assertEquals(7, AddressType::OTHER);
self::assertEquals(8, AddressType::EDUCATION);
self::assertEquals(99, AddressType::OTHER);
}
}

View File

@ -54,6 +54,8 @@ final class FileTest extends \PHPUnit\Framework\TestCase
\ftp_delete(self::$con, __DIR__ . '/0x00');
if (!$mkdir || !$put) {
self::$con = null;
throw new \Exception();
}
} catch (\Throwable $_) {

View File

@ -43,6 +43,10 @@ final class ImageUtilsTest extends \PHPUnit\Framework\TestCase
self::assertTrue(\is_file(__DIR__ . '/img/logo_resized.png'));
}
/**
* @covers phpOMS\Utils\ImageUtils
* @group slow
*/
public function testDifference() : void
{
foreach (['png', 'gif'] as $type) {

Binary file not shown.

View File

@ -135,7 +135,7 @@ final class MarkdownTest extends \PHPUnit\Framework\TestCase
public function testEmbed() : void
{
$parser = new Markdown([
'embeding' => true,
'embedding' => true,
]);
self::assertEquals(

View File

@ -1,2 +1,2 @@
```chart
```chartjs
```

View File

@ -2,5 +2,4 @@
$message = 'fenced code block';
echo $message;</code></pre>
<pre><code>tilde</code></pre>
<pre><code class="language-php">echo 'language identifier';</code></pre>

View File

@ -5,10 +5,6 @@ $message = 'fenced code block';
echo $message;
```
~~~
tilde
~~~
```php
echo 'language identifier';
```

View File

@ -1,9 +1,9 @@
<ol>
<ol start="1">
<li>one</li>
<li>two</li>
</ol>
<p>repeating numbers:</p>
<ol>
<ol start="1">
<li>one</li>
<li>two</li>
</ol>

Binary file not shown.

View File

@ -30,7 +30,7 @@ final class PermutationTest extends \PHPUnit\Framework\TestCase
* @covers phpOMS\Utils\Permutation
* @group framework
*/
public function testPermute() : void
public function testPermuteAll() : void
{
$arr = ['a', 'b', 'c'];
$permutations = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba'];
@ -68,7 +68,7 @@ final class PermutationTest extends \PHPUnit\Framework\TestCase
* @covers phpOMS\Utils\Permutation
* @group framework
*/
public function testPermute() : void
public function testPermuteBy() : void
{
self::assertEquals(['c', 'b', 'a'], Permutation::permuteByKey(['a', 'b', 'c'], [2, 1, 1]));
}

View File

@ -193,7 +193,7 @@ final class StringUtilsTest extends \PHPUnit\Framework\TestCase
);
self::assertEquals(
'This is a <del>test</del><ins>new</ins> string.',
'This is a <del>test</del> <ins>new</ins> string.',
StringUtils::createDiffMarkup($original, $new, ' ')
);

BIN
tests/Utils/img/diff1.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB