cleanup tests and add new tests

This commit is contained in:
Dennis Eichhorn 2019-11-10 22:38:11 +01:00
parent 3e0a4f113f
commit 7fece66ef6
108 changed files with 1671 additions and 192 deletions

View File

@ -83,7 +83,7 @@ class Path
} }
/** /**
* Get the path length * Get the path length (euclidean)
* *
* @return float * @return float
* *
@ -183,12 +183,12 @@ class Path
$line = []; $line = [];
while (true) { while (true) {
$line[] = $node;
if ($node->getX() === $node2->getX() && $node->getY() === $node2->getY()) { if ($node->getX() === $node2->getX() && $node->getY() === $node2->getY()) {
break; break;
} }
$line[] = $node;
$e2 = 2 * $err; $e2 = 2 * $err;
if ($e2 > -$dy) { if ($e2 > -$dy) {

View File

@ -1094,7 +1094,7 @@ final class FinanceFormulas
$count = \count($C); $count = \count($C);
if ($count === 0) { if ($count === 0) {
throw new \UnexpectedValueException((string) $count); return 0.0;
} }
$npv = -$C[0]; $npv = -$C[0];

View File

@ -313,7 +313,7 @@ class FileCache extends ConnectionAbstract
$cacheExpire = \substr($raw, $expireStart + 1, $expireEnd - ($expireStart + 1)); $cacheExpire = \substr($raw, $expireStart + 1, $expireEnd - ($expireStart + 1));
$cacheExpire = ($cacheExpire === -1) ? $created : (int) $cacheExpire; $cacheExpire = ($cacheExpire === -1) ? $created : (int) $cacheExpire;
if ($cacheExpire >= 0 && $created + $cacheExpire < $now) { if ($cacheExpire >= 0 && $created + $cacheExpire + ($expire > 0 ? $expire : 0) < $now) {
$this->delete($key); $this->delete($key);
return null; return null;

View File

@ -143,6 +143,7 @@ final class CookieJar
throw new LockException('CookieJar'); throw new LockException('CookieJar');
} }
// @codeCoverageIgnoreStart
if (!\headers_sent()) { if (!\headers_sent()) {
\setcookie($id, '', \time() - 3600); \setcookie($id, '', \time() - 3600);
@ -150,6 +151,7 @@ final class CookieJar
} }
return false; return false;
// @codeCoverageIgnoreEnd
} }
return false; return false;
@ -190,8 +192,10 @@ final class CookieJar
throw new LockException('CookieJar'); throw new LockException('CookieJar');
} }
// @codeCoverageIgnoreStart
foreach ($this->cookies as $key => $cookie) { foreach ($this->cookies as $key => $cookie) {
\setcookie($key, $cookie['value'], $cookie['expiry'], $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httponly']); \setcookie($key, $cookie['value'], $cookie['expiry'], $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httponly']);
} }
// @codeCoverageIgnoreEnd
} }
} }

View File

@ -492,6 +492,7 @@ class DataMapperAbstract implements DataMapperInterface
// @todo: remove after debugging // @todo: remove after debugging
// @fix: really remove it // @fix: really remove it
// @critical: after we found the bug we MUST remove it! // @critical: after we found the bug we MUST remove it!
var_dump($t->getMessage());
var_dump($query->toSql()); var_dump($query->toSql());
} }
@ -941,7 +942,12 @@ class DataMapperAbstract implements DataMapperInterface
$relQuery->values($src, $objId); $relQuery->values($src, $objId);
} }
self::$db->con->prepare($relQuery->toSql())->execute(); try {
self::$db->con->prepare($relQuery->toSql())->execute();
} catch (\Throwable $e) {
var_dump($e->getMessage());
var_dump($relQuery->toSql());
}
} }
} }

View File

@ -77,7 +77,7 @@ class HttpSession implements SessionInterface
public function __construct(int $liftetime = 3600, $sid = false, int $inactivityInterval = 0) public function __construct(int $liftetime = 3600, $sid = false, int $inactivityInterval = 0)
{ {
if (\session_id()) { if (\session_id()) {
\session_write_close(); \session_write_close(); // @codeCoverageIgnore
} }
if (!\is_bool($sid)) { if (!\is_bool($sid)) {
@ -87,12 +87,12 @@ class HttpSession implements SessionInterface
$this->inactivityInterval = $inactivityInterval; $this->inactivityInterval = $inactivityInterval;
if (\session_status() !== \PHP_SESSION_ACTIVE && !\headers_sent()) { if (\session_status() !== \PHP_SESSION_ACTIVE && !\headers_sent()) {
\session_set_cookie_params($liftetime, '/', '', false, true); \session_set_cookie_params($liftetime, '/', '', false, true); // @codeCoverageIgnore
\session_start(); \session_start(); // @codeCoverageIgnore
} }
if ($this->inactivityInterval > 0 && ($this->inactivityInterval + ($_SESSION['lastActivity'] ?? 0) < \time())) { if ($this->inactivityInterval > 0 && ($this->inactivityInterval + ($_SESSION['lastActivity'] ?? 0) < \time())) {
$this->destroy(); $this->destroy(); // @codeCoverageIgnore
} }
$this->sessionData = $_SESSION ?? []; $this->sessionData = $_SESSION ?? [];
@ -211,6 +211,7 @@ class HttpSession implements SessionInterface
* @return void * @return void
* *
* @since 1.0.0 * @since 1.0.0
* @codeCoverageIgnore
*/ */
private function destroy() : void private function destroy() : void
{ {

View File

@ -102,7 +102,7 @@ final class PackageManager
*/ */
public function extract(string $path) : void public function extract(string $path) : void
{ {
$this->extractPath = $path; $this->extractPath = \rtrim($path, '\\/');
Zip::unpack($this->path, $this->extractPath); Zip::unpack($this->path, $this->extractPath);
} }
@ -135,6 +135,10 @@ final class PackageManager
*/ */
public function isValid() : bool public function isValid() : bool
{ {
if (!\file_exists($this->extractPath . '/package.cert')) {
return false;
}
$contents = \file_get_contents($this->extractPath . '/package.cert'); $contents = \file_get_contents($this->extractPath . '/package.cert');
return $this->authenticate($contents === false ? '' : $contents, $this->hashFiles()); return $this->authenticate($contents === false ? '' : $contents, $this->hashFiles());
} }
@ -184,7 +188,7 @@ final class PackageManager
foreach ($this->info['update'] as $steps) { foreach ($this->info['update'] as $steps) {
foreach ($steps as $key => $components) { foreach ($steps as $key => $components) {
if (\function_exists($this->{$key})) { if (\method_exists($this, $key)) {
$this->{$key}($components); $this->{$key}($components);
} }
} }
@ -206,8 +210,8 @@ final class PackageManager
$fp = \fopen($this->basePath . '/' . $to, 'w+'); $fp = \fopen($this->basePath . '/' . $to, 'w+');
$ch = \curl_init(\str_replace(' ','%20', $from)); $ch = \curl_init(\str_replace(' ','%20', $from));
if ($ch === false) { if ($ch === false || $fp === false) {
continue; continue; // @codeCoverageIgnore
} }
\curl_setopt($ch, \CURLOPT_TIMEOUT, 50); \curl_setopt($ch, \CURLOPT_TIMEOUT, 50);
@ -233,10 +237,10 @@ final class PackageManager
private function move(array $components) : void private function move(array $components) : void
{ {
foreach ($components as $from => $to) { foreach ($components as $from => $to) {
$fromPath = StringUtils::startsWith($from, '/Package/') ? $this->extractPath : $this->basePath; $fromPath = StringUtils::startsWith($from, '/Package/') ? $this->extractPath . '/' . \substr($from, 9) : $this->basePath . '/' . $from;
$toPath = StringUtils::startsWith($to, '/Package/') ? $this->extractPath : $this->basePath; $toPath = StringUtils::startsWith($to, '/Package/') ? $this->extractPath . '/' . \substr($to, 9) : $this->basePath . '/' . $to;
LocalStorage::move($fromPath . '/' . $from, $toPath . '/' . $to, true); LocalStorage::move($fromPath, $toPath, true);
} }
} }
@ -252,12 +256,12 @@ final class PackageManager
private function copy(array $components) : void private function copy(array $components) : void
{ {
foreach ($components as $from => $tos) { foreach ($components as $from => $tos) {
$fromPath = StringUtils::startsWith($from, '/Package/') ? $this->extractPath : $this->basePath; $fromPath = StringUtils::startsWith($from, '/Package/') ? $this->extractPath . '/' . \substr($from, 9) : $this->basePath . '/' . $from;
foreach ($tos as $to) { foreach ($tos as $to) {
$toPath = StringUtils::startsWith($to, '/Package/') ? $this->extractPath : $this->basePath; $toPath = StringUtils::startsWith($to, '/Package/') ? $this->extractPath . '/' . \substr($to, 9) : $this->basePath . '/' . $to;
LocalStorage::copy($fromPath . '/' . $from, $toPath . '/' . $to, true); LocalStorage::copy($fromPath, $toPath, true);
} }
} }
} }
@ -274,8 +278,8 @@ final class PackageManager
private function delete(array $components) : void private function delete(array $components) : void
{ {
foreach ($components as $component) { foreach ($components as $component) {
$path = StringUtils::startsWith($component, '/Package/') ? $this->extractPath : $this->basePath; $path = StringUtils::startsWith($component, '/Package/') ? $this->extractPath . '/' . \substr($component, 9) : $this->basePath . '/' . $component;
LocalStorage::delete($path . '/' . $component); LocalStorage::delete($path);
} }
} }
@ -291,19 +295,27 @@ final class PackageManager
private function cmd(array $components) : void private function cmd(array $components) : void
{ {
foreach ($components as $component) { foreach ($components as $component) {
$pipes = [];
$cmd = ''; $cmd = '';
$path = StringUtils::startsWith($component, '/Package/') ? $this->extractPath : $this->basePath; $path = StringUtils::startsWith($component, '/Package/') ? $this->extractPath . '/' . \substr($component, 9) : $this->basePath . '/' . $component;
if (StringUtils::endsWith($component, '.php')) { if (StringUtils::endsWith($component, '.php')) {
$cmd = 'php ' . $path . '/' . $component; // todo: maybe add a guessing method to find php path if it isn't available in the environment see Repository.php for git api
} elseif (StringUtils::endsWith($component, '.sh') && OperatingSystem::getSystem() === SystemType::LINUX) { $cmd = 'php ' . $path;
$cmd = '.' . $path . '/' . $component; } elseif (StringUtils::endsWith($component, '.sh') && OperatingSystem::getSystem() === SystemType::LINUX && \is_executable($path)) {
} elseif (StringUtils::endsWith($component, '.batch') && OperatingSystem::getSystem() === SystemType::WIN) { $cmd = $path;
$cmd = '.' . $path . '/' . $component; } elseif (StringUtils::endsWith($component, '.batch') && OperatingSystem::getSystem() === SystemType::WIN && \is_executable($path)) {
$cmd = $path;
} }
if ($cmd !== '') { if ($cmd !== '') {
\proc_open($cmd, [1 => ['pipe', 'w'], 2 => ['pipe', 'w']], $pipes, __DIR__); $pipes = [];
$resource = \proc_open($cmd, [1 => ['pipe', 'w'], 2 => ['pipe', 'w']], $pipes, $this->extractPath);
foreach ($pipes as $pipe) {
\fclose($pipe);
}
\proc_close($resource);
} }
} }
} }

View File

@ -110,7 +110,7 @@ final class PhpCode
$disabled = \ini_get('disable_functions'); $disabled = \ini_get('disable_functions');
if ($disabled === false) { if ($disabled === false) {
return true; return true; // @codeCoverageIgnore
} }
$disabled = \str_replace(' ', '', $disabled); $disabled = \str_replace(' ', '', $disabled);
@ -122,7 +122,7 @@ final class PhpCode
} }
} }
return true; return true; // @codeCoverageIgnore
} }
/** /**

View File

@ -44,25 +44,6 @@ abstract class ViewAbstract implements RenderableInterface
*/ */
protected array $views = []; protected array $views = [];
/**
* Sort views by order.
*
* @param array $a Array 1
* @param array $b Array 2
*
* @return int
*
* @since 1.0.0
*/
private static function viewSort(array $a, array $b) : int
{
if ($a['order'] === $b['order']) {
return 0;
}
return ($a['order'] < $b['order']) ? -1 : 1;
}
/** /**
* Get the template. * Get the template.
* *
@ -172,22 +153,17 @@ abstract class ViewAbstract implements RenderableInterface
* *
* @param string $id View ID * @param string $id View ID
* @param View $view View to add * @param View $view View to add
* @param int $order Order of view
* @param bool $overwrite Overwrite existing view * @param bool $overwrite Overwrite existing view
* *
* @return bool * @return bool
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function addView(string $id, View $view, int $order = 0, bool $overwrite = false) : bool public function addView(string $id, View $view, bool $overwrite = false) : bool
{ {
if ($overwrite || !isset($this->views[$id])) { if ($overwrite || !isset($this->views[$id])) {
$this->views[$id] = $view; $this->views[$id] = $view;
if ($order !== 0) {
\uasort($this->views, ['\phpOMS\Views\View', 'viewSort']);
}
return true; return true;
} }

View File

@ -39,6 +39,7 @@ class AccountManagerTest extends \PHPUnit\Framework\TestCase
/** /**
* @testdox The manager has the expected member variables * @testdox The manager has the expected member variables
* @covers phpOMS\Account\AccountManager<extended>
*/ */
public function testAttributes() : void public function testAttributes() : void
{ {
@ -50,6 +51,7 @@ class AccountManagerTest extends \PHPUnit\Framework\TestCase
/** /**
* @testdox The manager has the expected default values after initialization * @testdox The manager has the expected default values after initialization
* @covers phpOMS\Account\AccountManager<extended>
*/ */
public function testDefault() : void public function testDefault() : void
{ {
@ -60,6 +62,7 @@ class AccountManagerTest extends \PHPUnit\Framework\TestCase
/** /**
* @testdox An account can be added to the manager * @testdox An account can be added to the manager
* @covers phpOMS\Account\AccountManager<extended>
*/ */
public function testAddAccount() : void public function testAddAccount() : void
{ {
@ -70,6 +73,7 @@ class AccountManagerTest extends \PHPUnit\Framework\TestCase
/** /**
* @testdox An account can be retrieved from the manager * @testdox An account can be retrieved from the manager
* @covers phpOMS\Account\AccountManager<extended>
*/ */
public function testRetrieveAccount() : void public function testRetrieveAccount() : void
{ {
@ -79,6 +83,7 @@ class AccountManagerTest extends \PHPUnit\Framework\TestCase
/** /**
* @testdox An account can only be added once to the account manager (no duplication) * @testdox An account can only be added once to the account manager (no duplication)
* @covers phpOMS\Account\AccountManager<extended>
*/ */
public function testNoAccountDuplication() : void public function testNoAccountDuplication() : void
{ {
@ -93,6 +98,7 @@ class AccountManagerTest extends \PHPUnit\Framework\TestCase
/** /**
* @testdox An account can be removed from the account manager * @testdox An account can be removed from the account manager
* @covers phpOMS\Account\AccountManager<extended>
*/ */
public function testRemoveAccount() : void public function testRemoveAccount() : void
{ {
@ -104,6 +110,7 @@ class AccountManagerTest extends \PHPUnit\Framework\TestCase
/** /**
* @testdox Only a valid account can be removed from the manager * @testdox Only a valid account can be removed from the manager
* @covers phpOMS\Account\AccountManager<extended>
*/ */
public function testRemoveOnlyValidAccount() : void public function testRemoveOnlyValidAccount() : void
{ {

View File

@ -23,6 +23,9 @@ use phpOMS\Account\AccountStatus;
*/ */
class AccountStatusTest extends \PHPUnit\Framework\TestCase class AccountStatusTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(4, AccountStatus::getConstants()); self::assertCount(4, AccountStatus::getConstants());

View File

@ -41,6 +41,7 @@ class AccountTest extends \PHPUnit\Framework\TestCase
/** /**
* @testdox The account has the expected member variables * @testdox The account has the expected member variables
* @covers phpOMS\Account\Account<extended>
*/ */
public function testAttributes() : void public function testAttributes() : void
{ {
@ -66,6 +67,7 @@ class AccountTest extends \PHPUnit\Framework\TestCase
/** /**
* @testdox The account has the expected default values after initialization * @testdox The account has the expected default values after initialization
* @covers phpOMS\Account\Account<extended>
*/ */
public function testDefault() : void public function testDefault() : void
{ {
@ -113,6 +115,7 @@ class AccountTest extends \PHPUnit\Framework\TestCase
/** /**
* @testdox The account names can be set and retrieved correctly * @testdox The account names can be set and retrieved correctly
* @covers phpOMS\Account\Account<extended>
*/ */
public function testSetAndGetAccountNames() : void public function testSetAndGetAccountNames() : void
{ {
@ -137,6 +140,7 @@ class AccountTest extends \PHPUnit\Framework\TestCase
/** /**
* @testdox Groups can be added to an account * @testdox Groups can be added to an account
* @covers phpOMS\Account\Account<extended>
*/ */
public function testAddAndGetGroup() : void public function testAddAndGetGroup() : void
{ {
@ -149,6 +153,7 @@ class AccountTest extends \PHPUnit\Framework\TestCase
/** /**
* @testdox An account can have a valid email address * @testdox An account can have a valid email address
* @covers phpOMS\Account\Account<extended>
*/ */
public function testSetAndGetAccountEmail() : void public function testSetAndGetAccountEmail() : void
{ {
@ -161,6 +166,7 @@ class AccountTest extends \PHPUnit\Framework\TestCase
/** /**
* @testdox The default status of the account can be changed to a different valid status * @testdox The default status of the account can be changed to a different valid status
* @covers phpOMS\Account\Account<extended>
*/ */
public function testChangeStatus() : void public function testChangeStatus() : void
{ {
@ -173,6 +179,7 @@ class AccountTest extends \PHPUnit\Framework\TestCase
/** /**
* @testdox The default type of the account can be changed to a different valid type * @testdox The default type of the account can be changed to a different valid type
* @covers phpOMS\Account\Account<extended>
*/ */
public function testChangeType() : void public function testChangeType() : void
{ {
@ -185,6 +192,7 @@ class AccountTest extends \PHPUnit\Framework\TestCase
/** /**
* @testdox Account permissions can be added and checked for existence * @testdox Account permissions can be added and checked for existence
* @covers phpOMS\Account\Account<extended>
*/ */
public function testPermissionHandling() : void public function testPermissionHandling() : void
{ {
@ -218,6 +226,7 @@ class AccountTest extends \PHPUnit\Framework\TestCase
/** /**
* @testdox An account can have it's own localization * @testdox An account can have it's own localization
* @covers phpOMS\Account\Account<extended>
*/ */
public function testLocalization() : void public function testLocalization() : void
{ {

View File

@ -23,6 +23,9 @@ use phpOMS\Account\AccountType;
*/ */
class AccountTypeTest extends \PHPUnit\Framework\TestCase class AccountTypeTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(2, AccountType::getConstants()); self::assertCount(2, AccountType::getConstants());

View File

@ -23,6 +23,9 @@ use phpOMS\Account\GroupStatus;
*/ */
class GroupStatusTest extends \PHPUnit\Framework\TestCase class GroupStatusTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(3, GroupStatus::getConstants()); self::assertCount(3, GroupStatus::getConstants());

View File

@ -30,6 +30,7 @@ class GroupTest extends \PHPUnit\Framework\TestCase
{ {
/** /**
* @testdox The group has the expected member variables * @testdox The group has the expected member variables
* @covers phpOMS\Account\Group<extended>
*/ */
public function testAttributes() : void public function testAttributes() : void
{ {
@ -48,6 +49,7 @@ class GroupTest extends \PHPUnit\Framework\TestCase
/** /**
* @testdox The group has the expected default values after initialization * @testdox The group has the expected default values after initialization
* @covers phpOMS\Account\Group<extended>
*/ */
public function testDefault() : void public function testDefault() : void
{ {
@ -75,6 +77,7 @@ class GroupTest extends \PHPUnit\Framework\TestCase
/** /**
* @testdox The group name and description can be set and retrieved correctly * @testdox The group name and description can be set and retrieved correctly
* @covers phpOMS\Account\Group<extended>
*/ */
public function testSetAndGetGroupNameDescription() : void public function testSetAndGetGroupNameDescription() : void
{ {
@ -89,6 +92,7 @@ class GroupTest extends \PHPUnit\Framework\TestCase
/** /**
* @testdox Group permissions can be added and checked for existence * @testdox Group permissions can be added and checked for existence
* @covers phpOMS\Account\Group<extended>
*/ */
public function testPermissionHandling() : void public function testPermissionHandling() : void
{ {
@ -120,6 +124,7 @@ class GroupTest extends \PHPUnit\Framework\TestCase
/** /**
* @testdox The default status of the group can be changed to a different valid status * @testdox The default status of the group can be changed to a different valid status
* @covers phpOMS\Account\Group<extended>
*/ */
public function testChangeStatus() : void public function testChangeStatus() : void
{ {
@ -131,6 +136,7 @@ class GroupTest extends \PHPUnit\Framework\TestCase
/** /**
* @testdox A group can only have valid group status * @testdox A group can only have valid group status
* @covers phpOMS\Account\Group<extended>
*/ */
public function testStatusException() : void public function testStatusException() : void
{ {

View File

@ -20,10 +20,16 @@ use phpOMS\Account\PermissionAbstract;
use phpOMS\Account\PermissionType; use phpOMS\Account\PermissionType;
/** /**
* @testdox phpOMS\tests\Account\PermissionAbstract: Base permission representation
*
* @internal * @internal
*/ */
class PermissionAbstractTest extends \PHPUnit\Framework\TestCase class PermissionAbstractTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @testdox The permission has the expected default values after initialization
* @covers phpOMS\Account\PermissionAbstract
*/
public function testAbstractDefault() : void public function testAbstractDefault() : void
{ {
$perm = new class() extends PermissionAbstract {}; $perm = new class() extends PermissionAbstract {};
@ -58,41 +64,153 @@ class PermissionAbstractTest extends \PHPUnit\Framework\TestCase
); );
} }
public function testAbstractGetSet() : void /**
* @testdox The unit can be set and returned correctly
* @covers phpOMS\Account\PermissionAbstract
*/
public function testUnitInputOutput() : void
{ {
$perm = new class() extends PermissionAbstract {}; $perm = new class() extends PermissionAbstract {};
$perm->setUnit(1); $perm->setUnit(1);
self::assertEquals(1, $perm->getUnit()); self::assertEquals(1, $perm->getUnit());
}
/**
* @testdox The app can be set and returned correctly
* @covers phpOMS\Account\PermissionAbstract
*/
public function testAppInputOutput() : void
{
$perm = new class() extends PermissionAbstract {};
$perm->setApp('Test'); $perm->setApp('Test');
self::assertEquals('Test', $perm->getApp()); self::assertEquals('Test', $perm->getApp());
}
/**
* @testdox The module can be set and returned correctly
* @covers phpOMS\Account\PermissionAbstract
*/
public function testModuleInputOutput() : void
{
$perm = new class() extends PermissionAbstract {};
$perm->setModule('2'); $perm->setModule('2');
self::assertEquals('2', $perm->getModule()); self::assertEquals('2', $perm->getModule());
}
/**
* @testdox The from can be set and returned correctly
* @covers phpOMS\Account\PermissionAbstract
*/
public function testFromInputOutput() : void
{
$perm = new class() extends PermissionAbstract {};
$perm->setFrom(3); $perm->setFrom(3);
self::assertEquals(3, $perm->getFrom()); self::assertEquals(3, $perm->getFrom());
}
/**
* @testdox The type can be set and returned correctly
* @covers phpOMS\Account\PermissionAbstract
*/
public function testTypeInputOutput() : void
{
$perm = new class() extends PermissionAbstract {};
$perm->setType(4); $perm->setType(4);
self::assertEquals(4, $perm->getType()); self::assertEquals(4, $perm->getType());
}
/**
* @testdox The element can be set and returned correctly
* @covers phpOMS\Account\PermissionAbstract
*/
public function testElementInputOutput() : void
{
$perm = new class() extends PermissionAbstract {};
$perm->setElement(5); $perm->setElement(5);
self::assertEquals(5, $perm->getElement()); self::assertEquals(5, $perm->getElement());
}
/**
* @testdox The component can be set and returned correctly
* @covers phpOMS\Account\PermissionAbstract
*/
public function testComponentInputOutput() : void
{
$perm = new class() extends PermissionAbstract {};
$perm->setComponent(6); $perm->setComponent(6);
self::assertEquals(6, $perm->getComponent()); self::assertEquals(6, $perm->getComponent());
}
/**
* @testdox The permission can be set and returned correctly
* @covers phpOMS\Account\PermissionAbstract
*/
public function testPermissionInputOutput() : void
{
$perm = new class() extends PermissionAbstract {};
$perm->setPermission(PermissionType::READ); $perm->setPermission(PermissionType::READ);
self::assertEquals(PermissionType::READ, $perm->getPermission()); self::assertEquals(PermissionType::READ, $perm->getPermission());
}
/**
* @testdox Correct permissions are validated
* @covers phpOMS\Account\PermissionAbstract
*/
public function testValidPermission() : void
{
$perm = new class() extends PermissionAbstract {};
$perm->setPermission(PermissionType::READ);
$perm->addPermission(PermissionType::CREATE); $perm->addPermission(PermissionType::CREATE);
self::assertTrue($perm->hasPermission(PermissionType::CREATE)); self::assertTrue($perm->hasPermission(PermissionType::CREATE));
self::assertTrue($perm->hasPermission(PermissionType::READ)); self::assertTrue($perm->hasPermission(PermissionType::READ));
self::assertFalse($perm->hasPermission(PermissionType::MODIFY)); }
/**
* @testdox Invalid permissions are not validted
* @covers phpOMS\Account\PermissionAbstract
*/
public function testInvalidPermission() : void
{
$perm = new class() extends PermissionAbstract {};
$perm->setPermission(PermissionType::READ);
$perm->addPermission(PermissionType::CREATE);
self::assertFalse($perm->hasPermission(PermissionType::MODIFY));
}
/**
* @testdox Correct permission flags are validated
* @covers phpOMS\Account\PermissionAbstract
*/
public function testValidPermissionFlag() : void
{
$perm = new class() extends PermissionAbstract {};
$perm->setPermission(PermissionType::READ);
$perm->addPermission(PermissionType::CREATE);
self::assertTrue($perm->hasPermissionFlags(PermissionType::READ)); self::assertTrue($perm->hasPermissionFlags(PermissionType::READ));
self::assertTrue($perm->hasPermissionFlags(PermissionType::READ & PermissionType::CREATE)); self::assertTrue($perm->hasPermissionFlags(PermissionType::READ & PermissionType::CREATE));
}
/**
* @testdox Invalid permission flags are not validated
* @covers phpOMS\Account\PermissionAbstract
*/
public function testInvalidPermissionFlag() : void
{
$perm = new class() extends PermissionAbstract {};
$perm->setPermission(PermissionType::READ);
$perm->addPermission(PermissionType::CREATE);
self::assertFalse($perm->hasPermissionFlags(PermissionType::MODIFY)); self::assertFalse($perm->hasPermissionFlags(PermissionType::MODIFY));
} }
} }

View File

@ -23,6 +23,9 @@ use phpOMS\Account\PermissionType;
*/ */
class PermissionTypeTest extends \PHPUnit\Framework\TestCase class PermissionTypeTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(6, PermissionType::getConstants()); self::assertCount(6, PermissionType::getConstants());

View File

@ -26,6 +26,7 @@ class KmeansTest extends \PHPUnit\Framework\TestCase
{ {
/** /**
* @testdox The clustering of points and dynamic check of new points works as expected * @testdox The clustering of points and dynamic check of new points works as expected
* @covers phpOMS\Algorithm\Clustering\Kmeans
*/ */
public function testKmeans() : void public function testKmeans() : void
{ {

View File

@ -25,6 +25,7 @@ class PointTest extends \PHPUnit\Framework\TestCase
{ {
/** /**
* @testdox The point has the expected default values after initialization * @testdox The point has the expected default values after initialization
* @covers phpOMS\Algorithm\Clustering\Point
*/ */
public function testDefault() : void public function testDefault() : void
{ {
@ -38,9 +39,10 @@ class PointTest extends \PHPUnit\Framework\TestCase
} }
/** /**
* @testdox Coordinates of a point can be changed * @testdox Coordinates of a point can be set and returned
* @covers phpOMS\Algorithm\Clustering\Point
*/ */
public function testChangeCoordinates() : void public function testCoordinateInputOutput() : void
{ {
$point = new Point([3.0, 2.0], 'abc'); $point = new Point([3.0, 2.0], 'abc');
@ -53,13 +55,26 @@ class PointTest extends \PHPUnit\Framework\TestCase
} }
/** /**
* @testdox The group/cluster of a point can be changed * @testdox The group/cluster of a point can be set and returned
* @covers phpOMS\Algorithm\Clustering\Point
*/ */
public function testChangeGroup() : void public function testGroupInputOutput() : void
{ {
$point = new Point([3.0, 2.0], 'abc'); $point = new Point([3.0, 2.0], 'abc');
$point->setGroup(2); $point->setGroup(2);
self::assertEquals(2, $point->getGroup()); self::assertEquals(2, $point->getGroup());
} }
/**
* @testdox The name of a point can be set and returned
* @covers phpOMS\Algorithm\Clustering\Point
*/
public function testNameInputOutput() : void
{
$point = new Point([3.0, 2.0], 'abc');
$point->setName('xyz');
self::assertEquals('xyz', $point->getName());
}
} }

View File

@ -27,6 +27,7 @@ class MinimumCoinProblemTest extends \PHPUnit\Framework\TestCase
{ {
/** /**
* @testdox A value is matched with the minimum quantity of avialable coins. * @testdox A value is matched with the minimum quantity of avialable coins.
* @covers phpOMS\Algorithm\CoinMatching\MinimumCoinProblem
*/ */
public function testMinimumCoins() : void public function testMinimumCoins() : void
{ {

View File

@ -25,6 +25,7 @@ class JobTest extends \PHPUnit\Framework\TestCase
{ {
/** /**
* @testdox The job has the expected values after initialization * @testdox The job has the expected values after initialization
* @covers phpOMS\Algorithm\JobScheduling\Job
*/ */
public function testDefault() : void public function testDefault() : void
{ {

View File

@ -26,6 +26,7 @@ class WeightedTest extends \PHPUnit\Framework\TestCase
{ {
/** /**
* @testdox The optimal job combination is selected to maximize the value/profit without overlapping jobs * @testdox The optimal job combination is selected to maximize the value/profit without overlapping jobs
* @covers phpOMS\Algorithm\JobScheduling\Weighted
*/ */
public function testNoOverlappingScheduling() : void public function testNoOverlappingScheduling() : void
{ {
@ -56,6 +57,7 @@ class WeightedTest extends \PHPUnit\Framework\TestCase
/** /**
* @testdox A job list with only one job simply returns one job * @testdox A job list with only one job simply returns one job
* @covers phpOMS\Algorithm\JobScheduling\Weighted
*/ */
public function testSmallList() : void public function testSmallList() : void
{ {

View File

@ -26,6 +26,7 @@ class BackpackTest extends \PHPUnit\Framework\TestCase
{ {
/** /**
* @testdox The backpack has the expected values after initialization * @testdox The backpack has the expected values after initialization
* @covers phpOMS\Algorithm\Knapsack\Backpack
*/ */
public function testDefault() : void public function testDefault() : void
{ {
@ -39,6 +40,7 @@ class BackpackTest extends \PHPUnit\Framework\TestCase
/** /**
* @testdox Items can be added to the backpack and automatically change the value and cost the backpack contains * @testdox Items can be added to the backpack and automatically change the value and cost the backpack contains
* @covers phpOMS\Algorithm\Knapsack\Backpack
*/ */
public function testAddItems() : void public function testAddItems() : void
{ {

View File

@ -27,6 +27,7 @@ class BoundedTest extends \PHPUnit\Framework\TestCase
{ {
/** /**
* @testdox The optimal item selection in a backpack is calculated in order to optimize the value/profit while considering the available capacity/cost limit * @testdox The optimal item selection in a backpack is calculated in order to optimize the value/profit while considering the available capacity/cost limit
* @covers phpOMS\Algorithm\Knapsack\Bounded
*/ */
public function testBackpacking() : void public function testBackpacking() : void
{ {

View File

@ -27,6 +27,7 @@ class ContinuousTest extends \PHPUnit\Framework\TestCase
{ {
/** /**
* @testdox The optimal item selection in a backpack is calculated in order to optimize the value/profit while considering the available capacity/cost limit [discrete quantities] * @testdox The optimal item selection in a backpack is calculated in order to optimize the value/profit while considering the available capacity/cost limit [discrete quantities]
* @covers phpOMS\Algorithm\Knapsack\Continuous
*/ */
public function testBackpacking() : void public function testBackpacking() : void
{ {
@ -67,6 +68,7 @@ class ContinuousTest extends \PHPUnit\Framework\TestCase
/** /**
* @testdox The optimal item selection in a backpack is calculated in order to optimize the value/profit while considering the available capacity/cost limit [continuous quantities] * @testdox The optimal item selection in a backpack is calculated in order to optimize the value/profit while considering the available capacity/cost limit [continuous quantities]
* @covers phpOMS\Algorithm\Knapsack\Continuous
*/ */
public function testBackpackingAlternative() : void public function testBackpackingAlternative() : void
{ {

View File

@ -25,6 +25,7 @@ class ItemTest extends \PHPUnit\Framework\TestCase
{ {
/** /**
* @testdox The item has the expected values after initialization * @testdox The item has the expected values after initialization
* @covers phpOMS\Algorithm\Knapsack\Item
*/ */
public function testDefault() : void public function testDefault() : void
{ {

View File

@ -0,0 +1,108 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace phpOMS\tests\Algorithm\PathFinding;
use phpOMS\Algorithm\PathFinding\AStarNode;
require_once __DIR__ . '/../../Autoloader.php';
/**
* @testdox phpOMS\tests\Algorithm\PathFinding\AStarNode: AStarNode on grid for path finding
*
* @internal
*/
class AStarNodeTest extends \PHPUnit\Framework\TestCase
{
protected $node;
protected function setUp() : void
{
$this->node = new AStarNode(1, 2, 3.0, false);
}
/**
* @testdox The node has the expected values after initialization
* @covers phpOMS\Algorithm\PathFinding\AStarNode
*/
public function testDefault() : void
{
self::assertFalse($this->node->isClosed());
self::assertFalse($this->node->isOpened());
self::assertFalse($this->node->isTested());
self::assertEquals(0.0, $this->node->getG());
self::assertEquals(null, $this->node->getH());
self::assertEquals(0.0, $this->node->getF());
}
/**
* @testdox The node can be set closed and checked
* @covers phpOMS\Algorithm\PathFinding\AStarNode
*/
public function testClosedInputOutput() : void
{
$this->node->setClosed(true);
self::assertTrue($this->node->isClosed());
}
/**
* @testdox The node can be set opened and checked
* @covers phpOMS\Algorithm\PathFinding\AStarNode
*/
public function testOpenedInputOutput() : void
{
$this->node->setOpened(true);
self::assertTrue($this->node->isOpened());
}
/**
* @testdox The node can be set tested and checked
* @covers phpOMS\Algorithm\PathFinding\AStarNode
*/
public function testTestedInputOutput() : void
{
$this->node->setTested(true);
self::assertTrue($this->node->isTested());
}
/**
* @testdox The g value cen be set and returned
* @covers phpOMS\Algorithm\PathFinding\AStarNode
*/
public function testGInputOutput() : void
{
$this->node->setG(2.0);
self::assertEquals(2.0, $this->node->getG());
}
/**
* @testdox The h value cen be set and returned
* @covers phpOMS\Algorithm\PathFinding\AStarNode
*/
public function testHInputOutput() : void
{
$this->node->setH(2.0);
self::assertEquals(2.0, $this->node->getH());
}
/**
* @testdox The f value cen be set and returned
* @covers phpOMS\Algorithm\PathFinding\AStarNode
*/
public function testFInputOutput() : void
{
$this->node->setF(2.0);
self::assertEquals(2.0, $this->node->getF());
}
}

View File

@ -69,6 +69,7 @@ class AStarTest extends \PHPUnit\Framework\TestCase
/** /**
* @testdox The correct path is found for diagonal movement * @testdox The correct path is found for diagonal movement
* @covers phpOMS\Algorithm\PathFinding\AStar
*/ */
public function testPathFindingDiagonal() : void public function testPathFindingDiagonal() : void
{ {
@ -111,6 +112,7 @@ class AStarTest extends \PHPUnit\Framework\TestCase
/** /**
* @testdox The correct path is found for straight movement * @testdox The correct path is found for straight movement
* @covers phpOMS\Algorithm\PathFinding\AStar
*/ */
public function testPathFindingStraight() : void public function testPathFindingStraight() : void
{ {
@ -153,6 +155,7 @@ class AStarTest extends \PHPUnit\Framework\TestCase
/** /**
* @testdox The correct path is found for diagonal movement [one obstacle] * @testdox The correct path is found for diagonal movement [one obstacle]
* @covers phpOMS\Algorithm\PathFinding\AStar
*/ */
public function testPathFindingDiagonalOneObstacle() : void public function testPathFindingDiagonalOneObstacle() : void
{ {
@ -195,6 +198,7 @@ class AStarTest extends \PHPUnit\Framework\TestCase
/** /**
* @testdox The correct path is found for diagonal movement [no obstacle] * @testdox The correct path is found for diagonal movement [no obstacle]
* @covers phpOMS\Algorithm\PathFinding\AStar
*/ */
public function testPathFindingDiagonalNoObstacle() : void public function testPathFindingDiagonalNoObstacle() : void
{ {

View File

@ -0,0 +1,417 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace phpOMS\tests\Algorithm\PathFinding;
use phpOMS\Algorithm\PathFinding\Grid;
use phpOMS\Algorithm\PathFinding\MovementType;
use phpOMS\Algorithm\PathFinding\Node;
require_once __DIR__ . '/../../Autoloader.php';
/**
* @testdox phpOMS\tests\Algorithm\PathFinding\GridTest: Grid for path finding
*
* @internal
*/
class GridTest extends \PHPUnit\Framework\TestCase
{
/**
* @testdox By default a grid is empty
* @covers phpOMS\Algorithm\PathFinding\Grid
*/
public function testDefault() : void
{
$grid = new Grid();
self::assertEquals(null, $grid->getNode(0, 0));
}
/**
* @testdox A grid can be created from an array
* @covers phpOMS\Algorithm\PathFinding\Grid
*/
public function testGridFromArray() : void
{
$grid = Grid::createGridFromArray([
[0, 9, 0],
[0, 9, 0],
[0, 9, 0],
], Node::class);
self::assertTrue($grid->isWalkable(0, 0));
self::assertFalse($grid->isWalkable(1, 0));
self::assertTrue($grid->isWalkable(2, 0));
self::assertTrue($grid->isWalkable(0, 1));
self::assertFalse($grid->isWalkable(1, 1));
self::assertTrue($grid->isWalkable(2, 1));
self::assertTrue($grid->isWalkable(0, 2));
self::assertFalse($grid->isWalkable(1, 2));
self::assertTrue($grid->isWalkable(2, 2));
}
/**
* @testdox A node can be set and returned from the grid
* @covers phpOMS\Algorithm\PathFinding\Grid
*/
public function testNodeInputOutput() : void
{
$grid = Grid::createGridFromArray([
[0, 9, 0],
[0, 9, 0],
[0, 9, 0],
], Node::class);
$grid->setNode(0, 0, new Node(0, 0, 1.0, false));
self::assertFalse($grid->getNode(0, 0)->isWalkable());
self::assertFalse($grid->isWalkable(0, 0));
}
/**
* @testdox Out of bounds nodes cannot be returned
* @covers phpOMS\Algorithm\PathFinding\Grid::getNode
*/
public function testOutOfBoundsNode() : void
{
$grid = Grid::createGridFromArray([
[0, 9, 0],
[0, 9, 0],
[0, 9, 0],
], Node::class);
self::assertEquals(null, $grid->getNode(-1, 0));
self::assertEquals(null, $grid->getNode(0, -1));
self::assertEquals(null, $grid->getNode(3, 0));
self::assertEquals(null, $grid->getNode(0, 3));
}
/**
* @testdox All hoirzontal neighbors can be found correctly
* @covers phpOMS\Algorithm\PathFinding\Grid::getNeighbors
*/
public function testStraightHorizontalNeighbors() : void
{
$grid = Grid::createGridFromArray([
[0, 9, 0],
[0, 0, 0],
[0, 9, 0],
], Node::class);
$node = $grid->getNode(1, 1);
$neighbors = $grid->getNeighbors($node, MovementType::STRAIGHT);
self::assertEquals(2, \count($neighbors));
self::assertTrue($grid->getNode(0, 1)->isEqual($neighbors[1]));
self::assertTrue($grid->getNode(2, 1)->isEqual($neighbors[0]));
}
/**
* @testdox All vertical neighbors can be found correctly
* @covers phpOMS\Algorithm\PathFinding\Grid::getNeighbors
*/
public function testStraightVerticalNeighbors() : void
{
$grid = Grid::createGridFromArray([
[0, 0, 0],
[9, 0, 9],
[0, 0, 0],
], Node::class);
$node = $grid->getNode(1, 1);
$neighbors = $grid->getNeighbors($node, MovementType::STRAIGHT);
self::assertEquals(2, \count($neighbors));
self::assertTrue($grid->getNode(1, 0)->isEqual($neighbors[0]));
self::assertTrue($grid->getNode(1, 2)->isEqual($neighbors[1]));
}
/**
* @testdox No straight neighbors are found if no straight neighbors exist
* @covers phpOMS\Algorithm\PathFinding\Grid::getNeighbors
*/
public function testStraightNoneNeighbors() : void
{
$grid = Grid::createGridFromArray([
[0, 9, 0],
[9, 0, 9],
[0, 9, 0],
], Node::class);
$node = $grid->getNode(1, 1);
$neighbors = $grid->getNeighbors($node, MovementType::STRAIGHT);
self::assertEquals(0, \count($neighbors));
}
/**
* @testdox All straight neighbors can be found correctly
* @covers phpOMS\Algorithm\PathFinding\Grid::getNeighbors
*/
public function testStraightAllNeighbors() : void
{
$grid = Grid::createGridFromArray([
[9, 0, 9],
[0, 0, 0],
[9, 0, 9],
], Node::class);
$node = $grid->getNode(1, 1);
$neighbors = $grid->getNeighbors($node, MovementType::STRAIGHT);
self::assertEquals(4, \count($neighbors));
self::assertTrue($grid->getNode(0, 1)->isEqual($neighbors[3]));
self::assertTrue($grid->getNode(2, 1)->isEqual($neighbors[1]));
self::assertTrue($grid->getNode(1, 0)->isEqual($neighbors[0]));
self::assertTrue($grid->getNode(1, 2)->isEqual($neighbors[2]));
}
/**
* @testdox All neighbors except blocked diagonal neighbors can be found correctly
* @covers phpOMS\Algorithm\PathFinding\Grid::getNeighbors
*/
public function testDiagonalLRNeighbors() : void
{
$grid = Grid::createGridFromArray([
[0, 0, 9],
[0, 0, 0],
[9, 0, 0],
], Node::class);
$node = $grid->getNode(1, 1);
$neighbors = $grid->getNeighbors($node, MovementType::DIAGONAL);
self::assertEquals(6, \count($neighbors));
self::assertTrue($grid->getNode(0, 0)->isEqual($neighbors[4]));
self::assertTrue($grid->getNode(1, 0)->isEqual($neighbors[0]));
self::assertTrue($grid->getNode(0, 1)->isEqual($neighbors[3]));
self::assertTrue($grid->getNode(2, 1)->isEqual($neighbors[1]));
self::assertTrue($grid->getNode(1, 2)->isEqual($neighbors[2]));
self::assertTrue($grid->getNode(2, 2)->isEqual($neighbors[5]));
}
/**
* @testdox All neighbors except blocked diagonal neighbors can be found correctly
* @covers phpOMS\Algorithm\PathFinding\Grid::getNeighbors
*/
public function testDiagonalURNeighbors() : void
{
$grid = Grid::createGridFromArray([
[9, 0, 0],
[0, 0, 0],
[0, 0, 9],
], Node::class);
$node = $grid->getNode(1, 1);
$neighbors = $grid->getNeighbors($node, MovementType::DIAGONAL);
self::assertEquals(6, \count($neighbors));
self::assertTrue($grid->getNode(1, 0)->isEqual($neighbors[0]));
self::assertTrue($grid->getNode(2, 0)->isEqual($neighbors[4]));
self::assertTrue($grid->getNode(0, 1)->isEqual($neighbors[3]));
self::assertTrue($grid->getNode(2, 1)->isEqual($neighbors[1]));
self::assertTrue($grid->getNode(1, 2)->isEqual($neighbors[2]));
self::assertTrue($grid->getNode(0, 2)->isEqual($neighbors[5]));
}
/**
* @testdox No diagonal neighbors are found if no neighbors exist
* @covers phpOMS\Algorithm\PathFinding\Grid::getNeighbors
*/
public function testDiagonalNoneNeighbors() : void
{
$grid = Grid::createGridFromArray([
[9, 9, 9],
[9, 0, 9],
[9, 9, 9],
], Node::class);
$node = $grid->getNode(1, 1);
$neighbors = $grid->getNeighbors($node, MovementType::DIAGONAL);
self::assertEquals(0, \count($neighbors));
}
/**
* @testdox All diagonal neighbors can be found correctly
* @covers phpOMS\Algorithm\PathFinding\Grid::getNeighbors
*/
public function testDiagonalOnlyNeighbors() : void
{
$grid = Grid::createGridFromArray([
[0, 9, 0],
[9, 0, 9],
[0, 9, 0],
], Node::class);
$node = $grid->getNode(1, 1);
$neighbors = $grid->getNeighbors($node, MovementType::DIAGONAL);
self::assertEquals(4, \count($neighbors));
self::assertTrue($grid->getNode(0, 0)->isEqual($neighbors[0]));
self::assertTrue($grid->getNode(2, 0)->isEqual($neighbors[1]));
self::assertTrue($grid->getNode(0, 2)->isEqual($neighbors[3]));
self::assertTrue($grid->getNode(2, 2)->isEqual($neighbors[2]));
}
/**
* @testdox All neighbors can be found correctly
* @covers phpOMS\Algorithm\PathFinding\Grid::getNeighbors
*/
public function testDiagonalAllNeighbors() : void
{
$grid = Grid::createGridFromArray([
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
], Node::class);
$node = $grid->getNode(1, 1);
$neighbors = $grid->getNeighbors($node, MovementType::DIAGONAL);
self::assertEquals(8, \count($neighbors));
self::assertTrue($grid->getNode(0, 0)->isEqual($neighbors[4]));
self::assertTrue($grid->getNode(1, 0)->isEqual($neighbors[0]));
self::assertTrue($grid->getNode(2, 0)->isEqual($neighbors[5]));
self::assertTrue($grid->getNode(0, 1)->isEqual($neighbors[3]));
self::assertTrue($grid->getNode(2, 1)->isEqual($neighbors[1]));
self::assertTrue($grid->getNode(0, 2)->isEqual($neighbors[7]));
self::assertTrue($grid->getNode(1, 2)->isEqual($neighbors[2]));
self::assertTrue($grid->getNode(2, 2)->isEqual($neighbors[6]));
}
/**
* @testdox All neighbors can be found correctly even if one obstacle exists
* @covers phpOMS\Algorithm\PathFinding\Grid::getNeighbors
*/
public function testDiagonalOneObstacleNoBlockNeighbors() : void
{
$grid = Grid::createGridFromArray([
[0, 9, 0],
[0, 0, 0],
[0, 0, 0],
], Node::class);
$node = $grid->getNode(1, 1);
$neighbors = $grid->getNeighbors($node, MovementType::DIAGONAL_ONE_OBSTACLE);
self::assertEquals(7, \count($neighbors));
self::assertTrue($grid->getNode(0, 0)->isEqual($neighbors[3]));
self::assertTrue($grid->getNode(2, 0)->isEqual($neighbors[4]));
self::assertTrue($grid->getNode(0, 1)->isEqual($neighbors[2]));
self::assertTrue($grid->getNode(2, 1)->isEqual($neighbors[0]));
self::assertTrue($grid->getNode(0, 2)->isEqual($neighbors[6]));
self::assertTrue($grid->getNode(1, 2)->isEqual($neighbors[1]));
self::assertTrue($grid->getNode(2, 2)->isEqual($neighbors[5]));
}
/**
* @testdox No diagonal neighbors are found if they are blocked on two sides
* @covers phpOMS\Algorithm\PathFinding\Grid::getNeighbors
*/
public function testDiagonalOneObstacleBlockNeighbors() : void
{
$grid = Grid::createGridFromArray([
[0, 9, 0],
[0, 0, 9],
[0, 0, 0],
], Node::class);
$node = $grid->getNode(1, 1);
$neighbors = $grid->getNeighbors($node, MovementType::DIAGONAL_ONE_OBSTACLE);
self::assertEquals(5, \count($neighbors));
self::assertTrue($grid->getNode(0, 0)->isEqual($neighbors[2]));
self::assertTrue($grid->getNode(0, 1)->isEqual($neighbors[1]));
self::assertTrue($grid->getNode(0, 2)->isEqual($neighbors[4]));
self::assertTrue($grid->getNode(1, 2)->isEqual($neighbors[0]));
self::assertTrue($grid->getNode(2, 2)->isEqual($neighbors[3]));
}
/**
* @testdox All neighbors can be found correctly if no obstacles exists
* @covers phpOMS\Algorithm\PathFinding\Grid::getNeighbors
*/
public function testDiagonalOneObstacleAllNeighbors() : void
{
$grid = Grid::createGridFromArray([
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
], Node::class);
$node = $grid->getNode(1, 1);
$neighbors = $grid->getNeighbors($node, MovementType::DIAGONAL_ONE_OBSTACLE);
self::assertEquals(8, \count($neighbors));
self::assertTrue($grid->getNode(0, 0)->isEqual($neighbors[4]));
self::assertTrue($grid->getNode(1, 0)->isEqual($neighbors[0]));
self::assertTrue($grid->getNode(2, 0)->isEqual($neighbors[5]));
self::assertTrue($grid->getNode(0, 1)->isEqual($neighbors[3]));
self::assertTrue($grid->getNode(2, 1)->isEqual($neighbors[1]));
self::assertTrue($grid->getNode(0, 2)->isEqual($neighbors[7]));
self::assertTrue($grid->getNode(1, 2)->isEqual($neighbors[2]));
self::assertTrue($grid->getNode(2, 2)->isEqual($neighbors[6]));
}
/**
* @testdox No diagonal neighbors are found if one obstacle exists
* @covers phpOMS\Algorithm\PathFinding\Grid::getNeighbors
*/
public function testDiagonalNoObstacleBlockNeighbors() : void
{
$grid = Grid::createGridFromArray([
[0, 9, 0],
[0, 0, 0],
[0, 0, 0],
], Node::class);
$node = $grid->getNode(1, 1);
$neighbors = $grid->getNeighbors($node, MovementType::DIAGONAL_NO_OBSTACLE);
self::assertEquals(5, \count($neighbors));
self::assertTrue($grid->getNode(0, 1)->isEqual($neighbors[2]));
self::assertTrue($grid->getNode(2, 1)->isEqual($neighbors[0]));
self::assertTrue($grid->getNode(0, 2)->isEqual($neighbors[4]));
self::assertTrue($grid->getNode(1, 2)->isEqual($neighbors[1]));
self::assertTrue($grid->getNode(2, 2)->isEqual($neighbors[3]));
}
/**
* @testdox All neighbors can be found correctly if no obstacles exist
* @covers phpOMS\Algorithm\PathFinding\Grid::getNeighbors
*/
public function testDiagonalNoObstacleAllNeighbors() : void
{
$grid = Grid::createGridFromArray([
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
], Node::class);
$node = $grid->getNode(1, 1);
$neighbors = $grid->getNeighbors($node, MovementType::DIAGONAL_NO_OBSTACLE);
self::assertEquals(8, \count($neighbors));
self::assertTrue($grid->getNode(0, 0)->isEqual($neighbors[4]));
self::assertTrue($grid->getNode(1, 0)->isEqual($neighbors[0]));
self::assertTrue($grid->getNode(2, 0)->isEqual($neighbors[5]));
self::assertTrue($grid->getNode(0, 1)->isEqual($neighbors[3]));
self::assertTrue($grid->getNode(2, 1)->isEqual($neighbors[1]));
self::assertTrue($grid->getNode(0, 2)->isEqual($neighbors[7]));
self::assertTrue($grid->getNode(1, 2)->isEqual($neighbors[2]));
self::assertTrue($grid->getNode(2, 2)->isEqual($neighbors[6]));
}
}

View File

@ -0,0 +1,108 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace phpOMS\tests\Algorithm\PathFinding;
use phpOMS\Algorithm\PathFinding\JumpPointNode;
require_once __DIR__ . '/../../Autoloader.php';
/**
* @testdox phpOMS\tests\Algorithm\PathFinding\JumpPointNode: JumpPointNode on grid for path finding
*
* @internal
*/
class JumpPointNodeTest extends \PHPUnit\Framework\TestCase
{
protected $node;
protected function setUp() : void
{
$this->node = new JumpPointNode(1, 2, 3.0, false);
}
/**
* @testdox The node has the expected values after initialization
* @covers phpOMS\Algorithm\PathFinding\JumpPointNode
*/
public function testDefault() : void
{
self::assertFalse($this->node->isClosed());
self::assertFalse($this->node->isOpened());
self::assertFalse($this->node->isTested());
self::assertEquals(0.0, $this->node->getG());
self::assertEquals(null, $this->node->getH());
self::assertEquals(0.0, $this->node->getF());
}
/**
* @testdox The node can be set closed and checked
* @covers phpOMS\Algorithm\PathFinding\JumpPointNode
*/
public function testClosedInputOutput() : void
{
$this->node->setClosed(true);
self::assertTrue($this->node->isClosed());
}
/**
* @testdox The node can be set opened and checked
* @covers phpOMS\Algorithm\PathFinding\JumpPointNode
*/
public function testOpenedInputOutput() : void
{
$this->node->setOpened(true);
self::assertTrue($this->node->isOpened());
}
/**
* @testdox The node can be set tested and checked
* @covers phpOMS\Algorithm\PathFinding\JumpPointNode
*/
public function testTestedInputOutput() : void
{
$this->node->setTested(true);
self::assertTrue($this->node->isTested());
}
/**
* @testdox The g value cen be set and returned
* @covers phpOMS\Algorithm\PathFinding\JumpPointNode
*/
public function testGInputOutput() : void
{
$this->node->setG(2.0);
self::assertEquals(2.0, $this->node->getG());
}
/**
* @testdox The h value cen be set and returned
* @covers phpOMS\Algorithm\PathFinding\JumpPointNode
*/
public function testHInputOutput() : void
{
$this->node->setH(2.0);
self::assertEquals(2.0, $this->node->getH());
}
/**
* @testdox The f value cen be set and returned
* @covers phpOMS\Algorithm\PathFinding\JumpPointNode
*/
public function testFInputOutput() : void
{
$this->node->setF(2.0);
self::assertEquals(2.0, $this->node->getF());
}
}

View File

@ -69,6 +69,7 @@ class JumpPointSearchTest extends \PHPUnit\Framework\TestCase
/** /**
* @testdox The correct path is found for diagonal movement * @testdox The correct path is found for diagonal movement
* @covers phpOMS\Algorithm\PathFinding\JumpPointSearch
*/ */
public function testPathFindingDiagonal() : void public function testPathFindingDiagonal() : void
{ {
@ -111,6 +112,7 @@ class JumpPointSearchTest extends \PHPUnit\Framework\TestCase
/** /**
* @testdox The correct path is found for straight movement * @testdox The correct path is found for straight movement
* @covers phpOMS\Algorithm\PathFinding\JumpPointSearch
*/ */
public function testPathFindingStraight() : void public function testPathFindingStraight() : void
{ {
@ -153,6 +155,7 @@ class JumpPointSearchTest extends \PHPUnit\Framework\TestCase
/** /**
* @testdox The correct path is found for diagonal movement [one obstacle] * @testdox The correct path is found for diagonal movement [one obstacle]
* @covers phpOMS\Algorithm\PathFinding\JumpPointSearch
*/ */
public function testPathFindingDiagonalOneObstacle() : void public function testPathFindingDiagonalOneObstacle() : void
{ {
@ -195,6 +198,7 @@ class JumpPointSearchTest extends \PHPUnit\Framework\TestCase
/** /**
* @testdox The correct path is found for diagonal movement [no obstacle] * @testdox The correct path is found for diagonal movement [no obstacle]
* @covers phpOMS\Algorithm\PathFinding\JumpPointSearch
*/ */
public function testPathFindingDiagonalNoObstacle() : void public function testPathFindingDiagonalNoObstacle() : void
{ {

View File

@ -0,0 +1,81 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace phpOMS\tests\Algorithm\PathFinding;
use phpOMS\Algorithm\PathFinding\Node;
require_once __DIR__ . '/../../Autoloader.php';
/**
* @testdox phpOMS\tests\Algorithm\PathFinding\NodeTest: Node on grid for path finding
*
* @internal
*/
class NodeTest extends \PHPUnit\Framework\TestCase
{
/**
* @testdox The node has the expected values after initialization
* @covers phpOMS\Algorithm\PathFinding\Node
*/
public function testDefault() : void
{
$node = new Node(1, 2, 3.0, false);
self::assertEquals(1, $node->getX());
self::assertEquals(2, $node->getY());
self::assertEquals(['x' => 1, 'y' => 2], $node->getCoordinates());
self::assertEquals(3.0, $node->getWeight());
self::assertEquals(null, $node->getParent());
self::assertFalse($node->isWalkable());
}
/**
* @testdox Nodes with equal coordinates are equal
* @covers phpOMS\Algorithm\PathFinding\Node
*/
public function testNodesWithEqualCoordinatesAreEqual() : void
{
$node = new Node(1, 2, 3.0, false);
$node2 = new Node(1, 2, 2.0, true);
self::assertTrue($node->isEqual($node2));
}
/**
* @testdox Nodes with different coordinates are not equal
* @covers phpOMS\Algorithm\PathFinding\Node
*/
public function testNodesWithDifferentCoordinatesAreNotEqual() : void
{
$node = new Node(1, 2, 3.0, false);
$node2 = new Node(2, 2, 3.0, false);
self::assertFalse($node->isEqual($node2));
}
/**
* @testdox A parent node can be set and returned
* @covers phpOMS\Algorithm\PathFinding\Node
*/
public function testParentInputOutput() : void
{
$node = new Node(1, 2, 3.0, false);
$node2 = new Node(2, 2, 3.0, false);
$node->setParent($node2);
self::assertTrue($node2->isEqual($node->getParent()));
}
}

View File

@ -0,0 +1,112 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace phpOMS\tests\Algorithm\PathFinding;
use phpOMS\Algorithm\PathFinding\Grid;
use phpOMS\Algorithm\PathFinding\Node;
use phpOMS\Algorithm\PathFinding\Path;
require_once __DIR__ . '/../../Autoloader.php';
/**
* @testdox phpOMS\tests\Algorithm\PathFinding\PathTest: Path on grid
*
* @internal
*/
class PathTest extends \PHPUnit\Framework\TestCase
{
/**
* @testdox The path has the expected values after initialization
* @covers phpOMS\Algorithm\PathFinding\Path
*/
public function testDefault() : void
{
$path = new Path(new Grid());
self::assertEquals(0, $path->getLength());
self::assertEquals([], $path->getPath());
self::assertEquals([], $path->expandPath());
}
/**
* @testdox The diagonal euclidean path length is calculated correctly
* @covers phpOMS\Algorithm\PathFinding\Path
*/
public function testDiagonalPathLength() : void
{
$grid = Grid::createGridFromArray([
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
], Node::class);
$path = new Path($grid);
$path->addNode(new Node(1, 3));
$path->addNode(new Node(3, 1));
$path->addNode(new Node(4, 0));
self::assertEqualsWithDelta(4.2426, $path->getLength(), 0.001);
}
/**
* @testdox The straight euclidean path length is calculated correctly
* @covers phpOMS\Algorithm\PathFinding\Path
*/
public function testStraightPathLength() : void
{
$grid = Grid::createGridFromArray([
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
], Node::class);
$path = new Path($grid);
$path->addNode(new Node(1, 3));
$path->addNode(new Node(1, 1));
$path->addNode(new Node(3, 1));
self::assertEqualsWithDelta(4.0, $path->getLength(), 0.001);
}
/**
* @testdox The path is correctly expanded in case only jump points are defined
* @covers phpOMS\Algorithm\PathFinding\Path
*/
public function testPathExpansion() : void
{
$grid = Grid::createGridFromArray([
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
], Node::class);
$path = new Path($grid);
$path->addNode(new Node(1, 3));
$path->addNode(new Node(3, 1));
$path->addNode(new Node(4, 0));
self::assertEquals(3, \count($path->getPath()));
self::assertEquals(4, \count($path->expandPath()));
}
}

View File

@ -23,6 +23,9 @@ use phpOMS\Asset\AssetType;
*/ */
class AssetTypeTest extends \PHPUnit\Framework\TestCase class AssetTypeTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(3, AssetType::getConstants()); self::assertCount(3, AssetType::getConstants());

View File

@ -23,6 +23,9 @@ use phpOMS\Auth\LoginReturnType;
*/ */
class LoginReturnTypeTest extends \PHPUnit\Framework\TestCase class LoginReturnTypeTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(11, LoginReturnType::getConstants()); self::assertCount(11, LoginReturnType::getConstants());

View File

@ -437,6 +437,9 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase
self::assertEqualsWithDelta(0.04123, FinanceFormulas::getGeometricMeanReturn($r), 0.01); self::assertEqualsWithDelta(0.04123, FinanceFormulas::getGeometricMeanReturn($r), 0.01);
} }
/**
* @testdox The calculation of the future value of the growing annuity is correct
*/
public function testGrowingAnnuityFV() : void public function testGrowingAnnuityFV() : void
{ {
$p = 1000; $p = 1000;
@ -447,6 +450,9 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase
self::assertEqualsWithDelta(14226.06, FinanceFormulas::getGrowingAnnuityFV($p, $r, $g, $n), 0.01); self::assertEqualsWithDelta(14226.06, FinanceFormulas::getGrowingAnnuityFV($p, $r, $g, $n), 0.01);
} }
/**
* @testdox The calculation of the payment based on the present value of the growing annuity is correct
*/
public function testGrowingAnnuityPaymentPV() : void public function testGrowingAnnuityPaymentPV() : void
{ {
$p = 1000; $p = 1000;
@ -457,6 +463,9 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase
self::assertEqualsWithDelta(186.98, FinanceFormulas::getGrowingAnnuityPaymentPV($p, $r, $g, $n), 0.01); self::assertEqualsWithDelta(186.98, FinanceFormulas::getGrowingAnnuityPaymentPV($p, $r, $g, $n), 0.01);
} }
/**
* @testdox The calculation of the payment based on the future value of the growing annuity is correct
*/
public function testGrowingAnnuityPaymentFV() : void public function testGrowingAnnuityPaymentFV() : void
{ {
$fv = 1000; $fv = 1000;
@ -467,6 +476,9 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase
self::assertEqualsWithDelta(70.29, FinanceFormulas::getGrowingAnnuityPaymentFV($fv, $r, $g, $n), 0.01); self::assertEqualsWithDelta(70.29, FinanceFormulas::getGrowingAnnuityPaymentFV($fv, $r, $g, $n), 0.01);
} }
/**
* @testdox The calculation of the present value of the growing annuity is correct
*/
public function testGrowingAnnuityPV() : void public function testGrowingAnnuityPV() : void
{ {
$p = 1000; $p = 1000;
@ -477,6 +489,9 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase
self::assertEqualsWithDelta(5348.1, FinanceFormulas::getGrowingAnnuityPV($p, $r, $g, $n), 0.01); self::assertEqualsWithDelta(5348.1, FinanceFormulas::getGrowingAnnuityPV($p, $r, $g, $n), 0.01);
} }
/**
* @testdox The calculation of the present value of the growing perpetuity is correct
*/
public function testGrowingPerpetuityPV() : void public function testGrowingPerpetuityPV() : void
{ {
$d = 1000; $d = 1000;
@ -486,6 +501,9 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase
self::assertEqualsWithDelta(20000, FinanceFormulas::getGrowingPerpetuityPV($d, $r, $g), 0.01); self::assertEqualsWithDelta(20000, FinanceFormulas::getGrowingPerpetuityPV($d, $r, $g), 0.01);
} }
/**
* @testdox The calculation of the net present value is correct
*/
public function testNetPresentValue() : void public function testNetPresentValue() : void
{ {
$c = [1000, 100, 200, 300, 400, 500, 600]; $c = [1000, 100, 200, 300, 400, 500, 600];
@ -494,13 +512,17 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase
self::assertEqualsWithDelta(172.13, FinanceFormulas::getNetPresentValue($c, $r), 0.01); self::assertEqualsWithDelta(172.13, FinanceFormulas::getNetPresentValue($c, $r), 0.01);
} }
public function testInvalidNetPresentValue() : void /**
* @testdox No cash flows in the net prsent value calculation result in 0
*/
public function testEmptyNetPresentValue() : void
{ {
self::expectException(\UnexpectedValueException::class); self::assertEquals(0.0, FinanceFormulas::getNetPresentValue([], 0.1));
FinanceFormulas::getNetPresentValue([], 0.1);
} }
/**
* @testdox The calculation of the real rate of return is correct
*/
public function testRealRateOfReturn() : void public function testRealRateOfReturn() : void
{ {
$nominal = 0.15; $nominal = 0.15;
@ -509,11 +531,17 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase
self::assertEqualsWithDelta(0.09524, FinanceFormulas::getRealRateOfReturn($nominal, $inflation), 0.01); self::assertEqualsWithDelta(0.09524, FinanceFormulas::getRealRateOfReturn($nominal, $inflation), 0.01);
} }
/**
* @testdox The calculation of the net working capital is correct
*/
public function testNetWorkingCapital() : void public function testNetWorkingCapital() : void
{ {
self::assertEqualsWithDelta(1000 - 600, FinanceFormulas::getNetWorkingCapital(1000, 600), 0.01); self::assertEqualsWithDelta(1000 - 600, FinanceFormulas::getNetWorkingCapital(1000, 600), 0.01);
} }
/**
* @testdox The periods to reach a future value based on the present value is calculated correctly
*/
public function testNumberOfPeriodsPVFV() : void public function testNumberOfPeriodsPVFV() : void
{ {
$fv = 1200; $fv = 1200;
@ -523,6 +551,9 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase
self::assertEqualsWithDelta(6.1681, FinanceFormulas::getNumberOfPeriodsPVFV($fv, $pv, $r), 0.01); self::assertEqualsWithDelta(6.1681, FinanceFormulas::getNumberOfPeriodsPVFV($fv, $pv, $r), 0.01);
} }
/**
* @testdox The calculation of the present value is correct
*/
public function testPresentValue() : void public function testPresentValue() : void
{ {
$c = 1000; $c = 1000;
@ -532,6 +563,9 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase
self::assertEqualsWithDelta(375.94, FinanceFormulas::getPresentValue($c, $r, $n), 0.01); self::assertEqualsWithDelta(375.94, FinanceFormulas::getPresentValue($c, $r, $n), 0.01);
} }
/**
* @testdox The calculation of the present value using continuous compounding is correct
*/
public function testPresentValueContinuousCompounding() : void public function testPresentValueContinuousCompounding() : void
{ {
$c = 1000; $c = 1000;

View File

@ -17,10 +17,15 @@ namespace phpOMS\tests\Business\Finance;
use phpOMS\Business\Finance\StockBonds; use phpOMS\Business\Finance\StockBonds;
/** /**
* @testdox phpOMS\tests\Business\Finance\FinanceFormulasTest: Stock & bond related formulas
*
* @internal * @internal
*/ */
class StockBondsTest extends \PHPUnit\Framework\TestCase class StockBondsTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @testdox The calculation of various stock/bond related ratios/yields is correct
*/
public function testRatios() : void public function testRatios() : void
{ {
self::assertEquals(100 / 50, StockBonds::getBookValuePerShare(100, 50)); self::assertEquals(100 / 50, StockBonds::getBookValuePerShare(100, 50));
@ -35,26 +40,41 @@ class StockBondsTest extends \PHPUnit\Framework\TestCase
self::assertEquals(100 / 50, StockBonds::getPriceToSalesRatio(100, 50)); self::assertEquals(100 / 50, StockBonds::getPriceToSalesRatio(100, 50));
} }
/**
* @testdox The calculation of the bond yield based on face value and price is correct
*/
public function testBondEquivalentYield() : void public function testBondEquivalentYield() : void
{ {
self::assertEqualsWithDelta(0.40556, StockBonds::getBondEquivalentYield(100, 90, 100), 0.01); self::assertEqualsWithDelta(0.40556, StockBonds::getBondEquivalentYield(100, 90, 100), 0.01);
} }
/**
* @testdox The calculation of the return of the capital asset pricing model is correct
*/
public function testExpectedReturnCAPM() : void public function testExpectedReturnCAPM() : void
{ {
self::assertEqualsWithDelta(7, StockBonds::getExpectedReturnCAPM(3, 2, 5), 0.01); self::assertEqualsWithDelta(7, StockBonds::getExpectedReturnCAPM(3, 2, 5), 0.01);
} }
/**
* @testdox The capital gains yield calculation is correct
*/
public function testCapitalGainsYield() : void public function testCapitalGainsYield() : void
{ {
self::assertEqualsWithDelta(0.1, StockBonds::getCapitalGainsYield(100, 110), 0.01); self::assertEqualsWithDelta(0.1, StockBonds::getCapitalGainsYield(100, 110), 0.01);
} }
/**
* @testdox The diluted earnings per share calculation is correct
*/
public function testDilutedEarningsPerShare() : void public function testDilutedEarningsPerShare() : void
{ {
self::assertEqualsWithDelta(9.09, StockBonds::getDilutedEarningsPerShare(1000, 100, 10), 0.1); self::assertEqualsWithDelta(9.09, StockBonds::getDilutedEarningsPerShare(1000, 100, 10), 0.1);
} }
/**
* @testdox The calculation of the absolute return for multiple holding periods is correct
*/
public function testHoldingPeriodReturn() : void public function testHoldingPeriodReturn() : void
{ {
$r = [0.01, 0.02, 0.03, 0.04]; $r = [0.01, 0.02, 0.03, 0.04];
@ -62,6 +82,9 @@ class StockBondsTest extends \PHPUnit\Framework\TestCase
self::assertEqualsWithDelta(0.10355, StockBonds::getHoldingPeriodReturn($r), 0.01); self::assertEqualsWithDelta(0.10355, StockBonds::getHoldingPeriodReturn($r), 0.01);
} }
/**
* @testdox The tax equivalent yield is calculated correctly
*/
public function testTaxEquivalentYield() : void public function testTaxEquivalentYield() : void
{ {
$free = 0.15; $free = 0.15;
@ -70,6 +93,9 @@ class StockBondsTest extends \PHPUnit\Framework\TestCase
self::assertEqualsWithDelta(0.15789, StockBonds::getTaxEquivalentYield($free, $rate), 0.01); self::assertEqualsWithDelta(0.15789, StockBonds::getTaxEquivalentYield($free, $rate), 0.01);
} }
/**
* @testdox The net asset value is calculated correctly
*/
public function testNetAssetValue() : void public function testNetAssetValue() : void
{ {
$assets = 1000; $assets = 1000;
@ -79,6 +105,9 @@ class StockBondsTest extends \PHPUnit\Framework\TestCase
self::assertEqualsWithDelta(1.75, StockBonds::getNetAssetValue($assets, $liabilities, $shares), 0.01); self::assertEqualsWithDelta(1.75, StockBonds::getNetAssetValue($assets, $liabilities, $shares), 0.01);
} }
/**
* @testdox The calculation of the present value of a stock with constant growth rate is correct
*/
public function testPresentValueOfStockConstantGrowth() : void public function testPresentValueOfStockConstantGrowth() : void
{ {
$div = 500; $div = 500;
@ -88,6 +117,9 @@ class StockBondsTest extends \PHPUnit\Framework\TestCase
self::assertEqualsWithDelta(5000, StockBonds::getPresentValueOfStockConstantGrowth($div, $r, $g), 0.01); self::assertEqualsWithDelta(5000, StockBonds::getPresentValueOfStockConstantGrowth($div, $r, $g), 0.01);
} }
/**
* @testdox The total stock return including dividends and sales price is correct
*/
public function testTotalStockReturn() : void public function testTotalStockReturn() : void
{ {
$p0 = 1000; $p0 = 1000;
@ -97,6 +129,9 @@ class StockBondsTest extends \PHPUnit\Framework\TestCase
self::assertEqualsWithDelta(0.3, StockBonds::getTotalStockReturn($p0, $p1, $d), 0.01); self::assertEqualsWithDelta(0.3, StockBonds::getTotalStockReturn($p0, $p1, $d), 0.01);
} }
/**
* @testdox The calculation of the yield of a bond is correct
*/
public function testYieldToMaturity() : void public function testYieldToMaturity() : void
{ {
$c = 100; $c = 100;
@ -107,6 +142,9 @@ class StockBondsTest extends \PHPUnit\Framework\TestCase
self::assertEqualsWithDelta(0.1138, StockBonds::getYieldToMaturity($c, $f, $p, $n), 0.01); self::assertEqualsWithDelta(0.1138, StockBonds::getYieldToMaturity($c, $f, $p, $n), 0.01);
} }
/**
* @testdox The calculation of value of the zero coupon bond is correct
*/
public function testZeroCouponBondValue() : void public function testZeroCouponBondValue() : void
{ {
$f = 100; $f = 100;
@ -116,6 +154,9 @@ class StockBondsTest extends \PHPUnit\Framework\TestCase
self::assertEqualsWithDelta(74.73, StockBonds::getZeroCouponBondValue($f, $r, $t), 0.01); self::assertEqualsWithDelta(74.73, StockBonds::getZeroCouponBondValue($f, $r, $t), 0.01);
} }
/**
* @testdox The calculation of the yield of a zero coupon bond is correct
*/
public function testZeroCouponBondEffectiveYield() : void public function testZeroCouponBondEffectiveYield() : void
{ {
$f = 100; $f = 100;

View File

@ -21,6 +21,9 @@ use phpOMS\DataStorage\Cache\CacheStatus;
*/ */
class CacheStatusTest extends \PHPUnit\Framework\TestCase class CacheStatusTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(4, CacheStatus::getConstants()); self::assertCount(4, CacheStatus::getConstants());

View File

@ -21,6 +21,9 @@ use phpOMS\DataStorage\Cache\CacheType;
*/ */
class CacheTypeTest extends \PHPUnit\Framework\TestCase class CacheTypeTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(4, CacheType::getConstants()); self::assertCount(4, CacheType::getConstants());

View File

@ -21,6 +21,9 @@ use phpOMS\DataStorage\Cache\Connection\CacheValueType;
*/ */
class CacheValueTypeTest extends \PHPUnit\Framework\TestCase class CacheValueTypeTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(8, CacheValueType::getConstants()); self::assertCount(8, CacheValueType::getConstants());

View File

@ -26,104 +26,170 @@ use phpOMS\Utils\TestUtils;
*/ */
class FileCacheTest extends \PHPUnit\Framework\TestCase class FileCacheTest extends \PHPUnit\Framework\TestCase
{ {
/** protected FileCache $cache;
* @testdox The file cache connection has the expected default values after initialization
*/ protected function setUp() : void
public function testDefault() : void
{ {
if (\file_exists(__DIR__ . '/Cache')) { if (\file_exists(__DIR__ . '/Cache')) {
\rmdir(__DIR__ . '/Cache'); \rmdir(__DIR__ . '/Cache');
} }
$cache = new FileCache(__DIR__ . '/Cache'); $this->cache = new FileCache(__DIR__ . '/Cache');
}
self::assertEquals('', $cache->getPrefix()); protected function tearDown() : void
self::assertEquals(CacheType::FILE, $cache->getType()); {
self::assertTrue(\is_dir(__DIR__ . '/Cache')); $this->cache->flushAll();
self::assertTrue($cache->flushAll());
self::assertEquals(50, $cache->getThreshold());
self::assertNull($cache->get('test'));
if (\file_exists(__DIR__ . '/Cache')) { if (\file_exists(__DIR__ . '/Cache')) {
\rmdir(__DIR__ . '/Cache'); \rmdir(__DIR__ . '/Cache');
} }
} }
/**
* @testdox The file cache connection has the expected default values after initialization
*/
public function testDefault() : void
{
self::assertEquals('', $this->cache->getPrefix());
self::assertEquals(CacheType::FILE, $this->cache->getType());
self::assertTrue(\is_dir(__DIR__ . '/Cache'));
self::assertTrue($this->cache->flushAll());
self::assertEquals(50, $this->cache->getThreshold());
self::assertNull($this->cache->get('test'));
self::assertEquals(
[
'status' => CacheStatus::OK,
'count' => 0,
'size' => 0,
],
$this->cache->stats()
);
}
/** /**
* @testdox The connection to a dedicated cache directory can be established (none-exising directories get created) * @testdox The connection to a dedicated cache directory can be established (none-exising directories get created)
*/ */
public function testConnect() : void public function testConnect() : void
{ {
if (\file_exists(__DIR__ . '/Cache')) { self::assertEquals(CacheStatus::OK, $this->cache->getStatus());
\rmdir(__DIR__ . '/Cache');
}
$cache = new FileCache(__DIR__ . '/Cache');
self::assertEquals(CacheStatus::OK, $cache->getStatus());
if (\file_exists(__DIR__ . '/Cache')) {
\rmdir(__DIR__ . '/Cache');
}
} }
public function testGetSet() : void /**
* @testdox Different cache data (types) can be set and returned
*/
public function testSetInputOutput() : void
{ {
if (\file_exists(__DIR__ . '/Cache')) { $this->cache->set('key1', 'testVal');
\rmdir(__DIR__ . '/Cache'); self::assertEquals('testVal', $this->cache->get('key1'));
}
$cache = new FileCache(__DIR__ . '/Cache'); $this->cache->set('key2', false);
self::assertFalse($this->cache->get('key2'));
$cache->flushAll(); $this->cache->set('key3', null);
self::assertNull($this->cache->get('key3'));
$cache->set('key1', 'testVal'); // 1 $this->cache->set('key4', 4);
self::assertEquals('testVal', $cache->get('key1')); self::assertEquals(4, $this->cache->get('key4'));
self::assertTrue($cache->add('addKey', 'testValAdd')); // 2 $this->cache->set('key5', 5.12);
self::assertFalse($cache->add('addKey', 'testValAdd2')); self::assertEquals(5.12, $this->cache->get('key5'));
self::assertEquals('testValAdd', $cache->get('addKey'));
$cache->set('key2', false); // 3 $this->cache->set('key6', ['asdf', 1, true, 2.3]);
self::assertFalse($cache->get('key2')); self::assertEquals(['asdf', 1, true, 2.3], $this->cache->get('key6'));
$cache->set('key3', null); // 4 $this->cache->set('key7', new FileCacheSerializable());
self::assertNull($cache->get('key3')); self::assertEquals('abc', $this->cache->get('key7')->val);
$cache->set('key4', 4); // 5 $this->cache->set('key8', new FileCacheJsonSerializable());
self::assertEquals(4, $cache->get('key4')); self::assertEquals('abc', $this->cache->get('key8')->val);
}
$cache->set('key5', 5.12); // 6 /**
self::assertEquals(5.12, $cache->get('key5')); * @testdox Cache data can bet added and returned
*/
public function testAddInputOutput() : void
{
self::assertTrue($this->cache->add('addKey', 'testValAdd'));
self::assertEquals('testValAdd', $this->cache->get('addKey'));
}
$cache->set('key6', ['asdf', 1, true, 2.3]); // 7 /**
self::assertEquals(['asdf', 1, true, 2.3], $cache->get('key6')); * @testdox Cache data cannot be added if it already exists
*/
public function testInvalidOverwrite() : void
{
self::assertTrue($this->cache->add('addKey', 'testValAdd'));
self::assertFalse($this->cache->add('addKey', 'testValAdd2'));
self::assertEquals('testValAdd', $this->cache->get('addKey'));
}
$cache->set('key7', new FileCacheSerializable()); // 8 /**
self::assertEquals('abc', $cache->get('key7')->val); * @testdox Existing cache data can be replaced
*/
public function testReplace() : void
{
$this->cache->set('key4', 4);
self::assertEquals(4, $this->cache->get('key4'));
$cache->set('key8', new FileCacheJsonSerializable()); // 9 self::assertTrue($this->cache->replace('key4', 5));
self::assertEquals('abc', $cache->get('key8')->val); self::assertEquals(5, $this->cache->get('key4'));
}
self::assertTrue($cache->replace('key4', 5)); /**
self::assertFalse($cache->replace('keyInvalid', 5)); * @testdox None-existing cache data cannot be replaced
self::assertEquals(5, $cache->get('key4')); */
public function testInvalidReplace() : void
{
self::assertFalse($this->cache->replace('keyInvalid', 5));
}
self::assertTrue($cache->delete('key4')); // 8 /**
self::assertTrue($cache->delete('keyInvalid')); * @testdox Existing cache data can be deleted
self::assertNull($cache->get('key4')); */
public function testDelete() : void
{
$this->cache->set('key4', 4);
self::assertEquals(4, $this->cache->get('key4'));
self::assertTrue($this->cache->delete('key4'));
self::assertNull($this->cache->get('key4'));
}
/**
* @testdox The cache correctly handles general cache information
*/
public function testStats() : void
{
$this->cache->set('key1', 'testVal');
self::assertEquals('testVal', $this->cache->get('key1'));
$this->cache->set('key2', false);
self::assertFalse($this->cache->get('key2'));
self::assertEquals( self::assertEquals(
[ [
'status' => CacheStatus::OK, 'status' => CacheStatus::OK,
'count' => 8, 'count' => 2,
'size' => 220, 'size' => 17,
], ],
$cache->stats() $this->cache->stats()
); );
}
self::assertTrue($cache->flushAll()); /**
self::assertNull($cache->get('key5')); * @testdox The cache can be flushed
*/
public function testFlush() : void
{
$this->cache->set('key1', 'testVal');
self::assertEquals('testVal', $this->cache->get('key1'));
$this->cache->set('key2', false);
self::assertFalse($this->cache->get('key2'));
self::assertTrue($this->cache->flushAll());
self::assertNull($this->cache->get('key5'));
self::assertEquals( self::assertEquals(
[ [
@ -131,82 +197,103 @@ class FileCacheTest extends \PHPUnit\Framework\TestCase
'count' => 0, 'count' => 0,
'size' => 0, 'size' => 0,
], ],
$cache->stats() $this->cache->stats()
); );
if (\file_exists(__DIR__ . '/Cache')) {
\rmdir(__DIR__ . '/Cache');
}
} }
public function testExpire() : void /**
* @testdox Cache data can be set and returned with expiration limits
*/
public function testUnexpiredInputOutput() : void
{ {
if (\file_exists(__DIR__ . '/Cache')) { $this->cache->set('key1', 'testVal', 1);
\rmdir(__DIR__ . '/Cache'); self::assertEquals('testVal', $this->cache->get('key1'));
} }
$cache = new FileCache(__DIR__ . '/Cache'); /**
* @testdox Expired cache data cannot be returned
*/
public function testExpiredInputOutput() : void
{
$this->cache->set('key2', 'testVal2', 1);
self::assertEquals('testVal2', $this->cache->get('key2', 1));
\sleep(2);
self::assertNull($this->cache->get('key2', 1));
self::assertNull($this->cache->get('key2')); // this causes a side effect of deleting the outdated cache element!!!
}
$cache->flushAll(); /**
* @testdox Expired cache data can be forced to return
*/
public function testForceExpiredInputOutput() : void
{
$this->cache->set('key2', 'testVal2', 1);
\sleep(2);
self::assertEquals('testVal2', $this->cache->get('key2', 10));
}
$cache->set('key1', 'testVal', 1); /**
self::assertEquals('testVal', $cache->get('key1')); * @testdox Unexpired cache data connot be delete if lower expiration is defined
*/
public function testInvalidDeleteUnexpired() : void
{
$this->cache->set('key4', 'testVal4', 1);
self::assertFalse($this->cache->delete('key4', 0));
}
$cache->set('key2', 'testVal2', 1); /**
self::assertEquals('testVal2', $cache->get('key2', 1)); * @testdox Expired cache data can be deleted if equal expiration is defined
\sleep(3); */
self::assertNull($cache->get('key2', 1)); public function testDeleteExpired() : void
{
$this->cache->set('key4', 'testVal4', 1);
\sleep(2);
self::assertTrue($this->cache->delete('key4', 1));
}
$cache->set('key3', 'testVal3', 1); /**
self::assertEquals('testVal3', $cache->get('key3', 1)); * @testdox Unexpired data can be force deleted with lower expiration date
\sleep(3); */
self::assertNull($cache->get('key3', 1)); public function testForceDeleteUnexpired() : void
{
$this->cache->set('key5', 'testVal5', 10000);
\sleep(2);
self::assertFalse($this->cache->delete('key5', 1000000));
self::assertTrue($this->cache->delete('key5', 1));
}
$cache->set('key4', 'testVal4', 1); /**
self::assertFalse($cache->delete('key4', 0)); * @testdox Cach data can be flushed by expiration date
\sleep(3); */
self::assertTrue($cache->delete('key4', 1)); public function testFlushExpired() : void
{
$cache->set('key5', 'testVal5', 10000); $this->cache->set('key6', 'testVal6', 1);
\sleep(3);
self::assertFalse($cache->delete('key5', 1000000));
self::assertTrue($cache->delete('key5', 1));
$cache->set('key6', 'testVal6', 1);
\sleep(2); \sleep(2);
$cache->flush(0); $this->cache->flush(0);
self::assertNull($this->cache->get('key6', 0));
if (\file_exists(__DIR__ . '/Cache')) {
\rmdir(__DIR__ . '/Cache');
}
} }
/**
* @testdox A bad cache status will prevent all cache actions
*/
public function testBadCacheStatus() : void public function testBadCacheStatus() : void
{ {
if (\file_exists(__DIR__ . '/Cache')) { TestUtils::setMember($this->cache, 'status', CacheStatus::FAILURE);
\rmdir(__DIR__ . '/Cache');
}
$cache = new FileCache(__DIR__ . '/Cache'); $this->cache->set('key1', 'testVal');
$cache->flushAll(); self::assertFalse($this->cache->add('key2', 'testVal2'));
self::assertNull($this->cache->get('key1'));
TestUtils::setMember($cache, 'status', CacheStatus::FAILURE); self::assertFalse($this->cache->replace('key1', 5));
self::assertFalse($this->cache->delete('key1'));
$cache->set('key1', 'testVal'); self::assertFalse($this->cache->flushAll());
self::assertFalse($cache->add('key2', 'testVal2')); self::assertFalse($this->cache->flush());
self::assertNull($cache->get('key1')); self::assertEquals([], $this->cache->stats());
self::assertFalse($cache->replace('key1', 5));
self::assertFalse($cache->delete('key1'));
self::assertFalse($cache->flushAll());
self::assertFalse($cache->flush());
self::assertEquals([], $cache->stats());
if (\file_exists(__DIR__ . '/Cache')) {
\rmdir(__DIR__ . '/Cache');
}
} }
/**
* @testdox A invalid cache connection will throw an InvalidConnectionConfigException
*/
public function testInvalidCachePath() : void public function testInvalidCachePath() : void
{ {
self::expectException(\phpOMS\DataStorage\Cache\Exception\InvalidConnectionConfigException::class); self::expectException(\phpOMS\DataStorage\Cache\Exception\InvalidConnectionConfigException::class);
@ -214,11 +301,14 @@ class FileCacheTest extends \PHPUnit\Framework\TestCase
$cache = new FileCache('/etc/invalidPathOrPermission^$:?><'); $cache = new FileCache('/etc/invalidPathOrPermission^$:?><');
} }
/**
* @testdox A invalid data type will throw an InvalidArgumentException
*/
public function testInvalidDataType() : void public function testInvalidDataType() : void
{ {
self::expectException(\InvalidArgumentException::class); self::expectException(\InvalidArgumentException::class);
$cache = new FileCache(__DIR__ . '/Cache'); $this->cache->add('invalid', $this->cache);
$cache->add('invalid', $cache);
} }
} }

View File

@ -147,6 +147,9 @@ class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase
$GLOBALS['dbpool']->get()->con->prepare('DROP TABLE oms_test_has_many_rel_relations')->execute(); $GLOBALS['dbpool']->get()->con->prepare('DROP TABLE oms_test_has_many_rel_relations')->execute();
} }
/**
* @covers phpOMS\DataStorage\Database\DataMapperAbstract
*/
public function testDefault() : void public function testDefault() : void
{ {
self::assertEquals('test_base_id', BaseModelMapper::getPrimaryField()); self::assertEquals('test_base_id', BaseModelMapper::getPrimaryField());
@ -154,18 +157,27 @@ class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase
self::assertEquals('test_base_datetime', BaseModelMapper::getCreatedAt()); self::assertEquals('test_base_datetime', BaseModelMapper::getCreatedAt());
} }
/**
* @covers phpOMS\DataStorage\Database\DataMapperAbstract
*/
public function testCreate() : void public function testCreate() : void
{ {
self::assertGreaterThan(0, BaseModelMapper::create($this->model)); self::assertGreaterThan(0, BaseModelMapper::create($this->model));
self::assertGreaterThan(0, $this->model->id); self::assertGreaterThan(0, $this->model->id);
} }
/**
* @covers phpOMS\DataStorage\Database\DataMapperAbstract
*/
public function testCreateArray() : void public function testCreateArray() : void
{ {
self::assertGreaterThan(0, BaseModelMapper::createArray($this->modelArray)); self::assertGreaterThan(0, BaseModelMapper::createArray($this->modelArray));
self::assertGreaterThan(0, $this->modelArray['id']); self::assertGreaterThan(0, $this->modelArray['id']);
} }
/**
* @covers phpOMS\DataStorage\Database\DataMapperAbstract
*/
public function testRead() : void public function testRead() : void
{ {
$id = BaseModelMapper::create($this->model); $id = BaseModelMapper::create($this->model);
@ -198,6 +210,9 @@ class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase
self::assertCount(1, BaseModelMapper::getAll()); self::assertCount(1, BaseModelMapper::getAll());
} }
/**
* @covers phpOMS\DataStorage\Database\DataMapperAbstract
*/
public function testReadArray() : void public function testReadArray() : void
{ {
$id = BaseModelMapper::createArray($this->modelArray); $id = BaseModelMapper::createArray($this->modelArray);
@ -225,6 +240,9 @@ class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase
self::assertCount(1, BaseModelMapper::getAllArray()); self::assertCount(1, BaseModelMapper::getAllArray());
} }
/**
* @covers phpOMS\DataStorage\Database\DataMapperAbstract
*/
public function testUpdate() : void public function testUpdate() : void
{ {
$id = BaseModelMapper::create($this->model); $id = BaseModelMapper::create($this->model);
@ -252,6 +270,9 @@ class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase
// todo test update relations // todo test update relations
} }
/**
* @covers phpOMS\DataStorage\Database\DataMapperAbstract
*/
public function testUpdateArray() : void public function testUpdateArray() : void
{ {
$id = BaseModelMapper::createArray($this->modelArray); $id = BaseModelMapper::createArray($this->modelArray);
@ -279,6 +300,9 @@ class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase
// todo test update relations // todo test update relations
} }
/**
* @covers phpOMS\DataStorage\Database\DataMapperAbstract
*/
public function testDelete() : void public function testDelete() : void
{ {
$id = BaseModelMapper::create($this->model); $id = BaseModelMapper::create($this->model);

View File

@ -21,6 +21,9 @@ use phpOMS\DataStorage\Database\DatabaseStatus;
*/ */
class DatabaseStatusTest extends \PHPUnit\Framework\TestCase class DatabaseStatusTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(6, DatabaseStatus::getConstants()); self::assertCount(6, DatabaseStatus::getConstants());

View File

@ -21,6 +21,9 @@ use phpOMS\DataStorage\Database\DatabaseType;
*/ */
class DatabaseTypeTest extends \PHPUnit\Framework\TestCase class DatabaseTypeTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(5, DatabaseType::getConstants()); self::assertCount(5, DatabaseType::getConstants());

View File

@ -21,6 +21,9 @@ use phpOMS\DataStorage\Database\Query\JoinType;
*/ */
class JoinTypeTest extends \PHPUnit\Framework\TestCase class JoinTypeTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(12, JoinType::getConstants()); self::assertCount(12, JoinType::getConstants());

View File

@ -21,6 +21,9 @@ use phpOMS\DataStorage\Database\Query\QueryType;
*/ */
class QueryTypeTest extends \PHPUnit\Framework\TestCase class QueryTypeTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(7, QueryType::getConstants()); self::assertCount(7, QueryType::getConstants());

View File

@ -21,6 +21,9 @@ use phpOMS\DataStorage\Database\RelationType;
*/ */
class RelationTypeTest extends \PHPUnit\Framework\TestCase class RelationTypeTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(7, RelationType::getConstants()); self::assertCount(7, RelationType::getConstants());

View File

@ -21,6 +21,9 @@ use phpOMS\DataStorage\Database\Schema\QueryType;
*/ */
class QueryTypeTest extends \PHPUnit\Framework\TestCase class QueryTypeTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(13, QueryType::getConstants()); self::assertCount(13, QueryType::getConstants());

View File

@ -23,6 +23,9 @@ use phpOMS\Localization\ISO3166CharEnum;
*/ */
class ISO3166CharEnumTest extends \PHPUnit\Framework\TestCase class ISO3166CharEnumTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
$ok = true; $ok = true;

View File

@ -23,6 +23,9 @@ use phpOMS\Localization\ISO3166NameEnum;
*/ */
class ISO3166NameEnumTest extends \PHPUnit\Framework\TestCase class ISO3166NameEnumTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
$enum = ISO3166NameEnum::getConstants(); $enum = ISO3166NameEnum::getConstants();

View File

@ -23,6 +23,9 @@ use phpOMS\Localization\ISO3166NumEnum;
*/ */
class ISO3166NumEnumTest extends \PHPUnit\Framework\TestCase class ISO3166NumEnumTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
$ok = true; $ok = true;

View File

@ -23,6 +23,9 @@ use phpOMS\Localization\ISO3166TwoEnum;
*/ */
class ISO3166TwoEnumTest extends \PHPUnit\Framework\TestCase class ISO3166TwoEnumTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
$ok = true; $ok = true;

View File

@ -23,6 +23,9 @@ use phpOMS\Localization\ISO4217CharEnum;
*/ */
class ISO4217CharEnumTest extends \PHPUnit\Framework\TestCase class ISO4217CharEnumTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
$ok = true; $ok = true;

View File

@ -23,6 +23,9 @@ use phpOMS\Localization\ISO4217DecimalEnum;
*/ */
class ISO4217DecimalEnumTest extends \PHPUnit\Framework\TestCase class ISO4217DecimalEnumTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
$ok = true; $ok = true;

View File

@ -23,6 +23,9 @@ use phpOMS\Localization\ISO4217Enum;
*/ */
class ISO4217EnumTest extends \PHPUnit\Framework\TestCase class ISO4217EnumTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
$enum = ISO4217Enum::getConstants(); $enum = ISO4217Enum::getConstants();

View File

@ -23,6 +23,9 @@ use phpOMS\Localization\ISO4217NumEnum;
*/ */
class ISO4217NumEnumTest extends \PHPUnit\Framework\TestCase class ISO4217NumEnumTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
$ok = true; $ok = true;

View File

@ -23,6 +23,9 @@ use phpOMS\Localization\ISO4217SubUnitEnum;
*/ */
class ISO4217SubUnitEnumTest extends \PHPUnit\Framework\TestCase class ISO4217SubUnitEnumTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
$ok = true; $ok = true;

View File

@ -23,6 +23,9 @@ use phpOMS\Localization\ISO639Enum;
*/ */
class ISO639EnumTest extends \PHPUnit\Framework\TestCase class ISO639EnumTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
$enum = ISO639Enum::getConstants(); $enum = ISO639Enum::getConstants();

View File

@ -23,6 +23,9 @@ use phpOMS\Localization\ISO639x1Enum;
*/ */
class ISO639x1EnumTest extends \PHPUnit\Framework\TestCase class ISO639x1EnumTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
$ok = true; $ok = true;

View File

@ -23,6 +23,9 @@ use phpOMS\Localization\ISO639x2Enum;
*/ */
class ISO639x2EnumTest extends \PHPUnit\Framework\TestCase class ISO639x2EnumTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
$ok = true; $ok = true;

View File

@ -23,6 +23,9 @@ use phpOMS\Localization\ISO8601EnumArray;
*/ */
class ISO8601EnumArrayTest extends \PHPUnit\Framework\TestCase class ISO8601EnumArrayTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(4, ISO8601EnumArray::getConstants()); self::assertCount(4, ISO8601EnumArray::getConstants());

View File

@ -23,6 +23,9 @@ use phpOMS\Localization\PhoneEnum;
*/ */
class PhoneEnumTest extends \PHPUnit\Framework\TestCase class PhoneEnumTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
$ok = true; $ok = true;

View File

@ -23,6 +23,9 @@ use phpOMS\Localization\TimeZoneEnumArray;
*/ */
class TimeZoneEnumArrayTest extends \PHPUnit\Framework\TestCase class TimeZoneEnumArrayTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertEquals(\count(TimeZoneEnumArray::getConstants()), \count(\array_unique(TimeZoneEnumArray::getConstants()))); self::assertEquals(\count(TimeZoneEnumArray::getConstants()), \count(\array_unique(TimeZoneEnumArray::getConstants())));

View File

@ -23,6 +23,9 @@ use phpOMS\Log\LogLevel;
*/ */
class LogLevelTest extends \PHPUnit\Framework\TestCase class LogLevelTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(8, LogLevel::getConstants()); self::assertCount(8, LogLevel::getConstants());

View File

@ -21,6 +21,9 @@ use phpOMS\Math\Number\NumberType;
*/ */
class NumberTypeTest extends \PHPUnit\Framework\TestCase class NumberTypeTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(9, NumberType::getConstants()); self::assertCount(9, NumberType::getConstants());

View File

@ -21,6 +21,9 @@ use phpOMS\Message\Http\BrowserType;
*/ */
class BrowserTypeTest extends \PHPUnit\Framework\TestCase class BrowserTypeTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertEquals(12, BrowserType::count()); self::assertEquals(12, BrowserType::count());

View File

@ -21,6 +21,9 @@ use phpOMS\Message\Http\OSType;
*/ */
class OSTypeTest extends \PHPUnit\Framework\TestCase class OSTypeTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(24, OSType::getConstants()); self::assertCount(24, OSType::getConstants());

View File

@ -21,6 +21,9 @@ use phpOMS\Message\Http\RequestMethod;
*/ */
class RequestMethodTest extends \PHPUnit\Framework\TestCase class RequestMethodTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(6, RequestMethod::getConstants()); self::assertCount(6, RequestMethod::getConstants());

View File

@ -21,6 +21,9 @@ use phpOMS\Message\Http\RequestStatusCode;
*/ */
class RequestStatusCodeTest extends \PHPUnit\Framework\TestCase class RequestStatusCodeTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(55, RequestStatusCode::getConstants()); self::assertCount(55, RequestStatusCode::getConstants());

View File

@ -21,6 +21,9 @@ use phpOMS\Message\Http\RequestStatus;
*/ */
class RequestStatusTest extends \PHPUnit\Framework\TestCase class RequestStatusTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(55, RequestStatus::getConstants()); self::assertCount(55, RequestStatus::getConstants());

View File

@ -21,6 +21,9 @@ use phpOMS\Message\Socket\PacketType;
*/ */
class PacketTypeTest extends \PHPUnit\Framework\TestCase class PacketTypeTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(11, PacketType::getConstants()); self::assertCount(11, PacketType::getConstants());

View File

@ -21,6 +21,9 @@ use phpOMS\Model\Message\DomAction;
*/ */
class DomActionTest extends \PHPUnit\Framework\TestCase class DomActionTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(9, DomAction::getConstants()); self::assertCount(9, DomAction::getConstants());

View File

@ -21,6 +21,9 @@ use phpOMS\Model\Message\NotifyType;
*/ */
class NotifyTypeTest extends \PHPUnit\Framework\TestCase class NotifyTypeTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(5, NotifyType::getConstants()); self::assertCount(5, NotifyType::getConstants());

View File

@ -90,7 +90,7 @@ class PackageManagerTest extends \PHPUnit\Framework\TestCase
$package = new PackageManager( $package = new PackageManager(
__DIR__ . '/testPackage.zip', __DIR__ . '/testPackage.zip',
__DIR__ . 'dummyModule/', __DIR__ . '/dummyModule/',
\file_get_contents(__DIR__ . '/public.key') \file_get_contents(__DIR__ . '/public.key')
); );
@ -101,6 +101,33 @@ class PackageManagerTest extends \PHPUnit\Framework\TestCase
$package->load(); $package->load();
$package->install(); $package->install();
self::assertGreaterThan(100, \filesize(__DIR__ . '/dummyModule/README.md'));
self::assertEquals('To copy!', \file_get_contents(__DIR__ . '/dummyModule/Replace.md'));
self::assertFalse(\file_exists(__DIR__ . '/dummyModule/toMove'));
self::assertTrue(\file_exists(__DIR__ . '/dummyModule/moveHere'));
self::assertTrue(\file_exists(__DIR__ . '/dummyModule/moveHere/a.md'));
self::assertTrue(\file_exists(__DIR__ . '/dummyModule/moveHere/sub/b.txt'));
self::assertTrue(\file_exists(__DIR__ . '/dummyModule/externalCopy.md'));
self::assertTrue(\file_exists(__DIR__ . '/dummyModule/toCopy'));
self::assertTrue(\file_exists(__DIR__ . '/dummyModule/copyHere'));
self::assertTrue(\file_exists(__DIR__ . '/dummyModule/copyHere/a.md'));
self::assertTrue(\file_exists(__DIR__ . '/dummyModule/copyHere/sub/b.txt'));
self::assertFalse(\file_exists(__DIR__ . '/dummyModule/Remove'));
\sleep(1);
self::assertEquals('php script', \file_get_contents(__DIR__ . '/dummyModule/phpscript.md'));
if (\is_executable(__DIR__ . '/testPackageExtracted/testSubPackage/run.sh')
&& \is_executable(__DIR__ . '/testPackageExtracted/testSubPackage/run.batch')
) {
self::assertEquals('cmd script', \file_get_contents(__DIR__ . '/dummyModule/cmdscript.md'));
}
if (\file_exists(__DIR__ . '/dummyModule')) { if (\file_exists(__DIR__ . '/dummyModule')) {
Directory::delete(__DIR__ . '/dummyModule'); Directory::delete(__DIR__ . '/dummyModule');
} }
@ -119,6 +146,19 @@ class PackageManagerTest extends \PHPUnit\Framework\TestCase
$package->load(); $package->load();
} }
public function testInvalidInstall() : void
{
self::expectException(\Exception::class);
$package = new PackageManager(
__DIR__ . '/testPackage.zip',
'/invalid',
\file_get_contents(__DIR__ . '/public.key') . ' '
);
$package->install();
}
public function testPackageInvalidKey() : void public function testPackageInvalidKey() : void
{ {
$package = new PackageManager( $package = new PackageManager(

View File

@ -13,15 +13,19 @@
"copy": { "copy": {
"toCopy": [ "toCopy": [
"copyHere" "copyHere"
],
"/Package/testSubPackage/externalCopy.md": [
"externalCopy.md",
"Replace.md"
] ]
}, },
"delete": [ "delete": [
"Remove" "Remove"
], ],
"cmd": [ "cmd": [
"/Package/run.php", "/Package/testSubPackage/run.php",
"/Package/run.sh", "/Package/testSubPackage/run.sh",
"/Package/run.batch" "/Package/testSubPackage/run.batch"
] ]
} }
] ]

View File

@ -0,0 +1 @@
To copy!

View File

@ -0,0 +1 @@
<?php \file_put_contents(__DIR__ . '/../../dummyModule/phpscript.md', 'php script');

View File

@ -0,0 +1,5 @@
#!/bin/bash
BASEDIR=$(dirname "$0")
echo "cmd script" > $BASEDIR/../../dummyModule/cmdscript.md

View File

@ -103,5 +103,11 @@ class ClientTest extends \PHPUnit\Framework\TestCase
. 'Is shutdown...' . "\n", . 'Is shutdown...' . "\n",
\file_get_contents(__DIR__ . '/server.log') \file_get_contents(__DIR__ . '/server.log')
); );
foreach ($pipes as $pipe) {
\fclose($pipe);
}
\proc_close($process);
} }
} }

View File

@ -103,5 +103,11 @@ class ServerTest extends \PHPUnit\Framework\TestCase
self::assertStringContainsString('Sending: handshake', $client); self::assertStringContainsString('Sending: handshake', $client);
self::assertStringContainsString('Sending: help', $client); self::assertStringContainsString('Sending: help', $client);
self::assertStringContainsString('Sending: shutdown', $client); self::assertStringContainsString('Sending: shutdown', $client);
foreach ($pipes as $pipe) {
\fclose($pipe);
}
\proc_close($process);
} }
} }

View File

@ -21,6 +21,9 @@ use phpOMS\Stdlib\Base\AddressType;
*/ */
class AddressTypeTest extends \PHPUnit\Framework\TestCase class AddressTypeTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(7, AddressType::getconstants()); self::assertCount(7, AddressType::getconstants());

View File

@ -21,6 +21,9 @@ use phpOMS\Stdlib\Base\PhoneType;
*/ */
class PhoneTypeTest extends \PHPUnit\Framework\TestCase class PhoneTypeTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(4, PhoneType::getConstants()); self::assertCount(4, PhoneType::getConstants());

View File

@ -21,6 +21,9 @@ use phpOMS\Stdlib\Map\KeyType;
*/ */
class KeyTypeTest extends \PHPUnit\Framework\TestCase class KeyTypeTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(2, KeyType::getConstants()); self::assertCount(2, KeyType::getConstants());

View File

@ -21,6 +21,9 @@ use phpOMS\Stdlib\Map\OrderType;
*/ */
class OrderTypeTest extends \PHPUnit\Framework\TestCase class OrderTypeTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(2, OrderType::getConstants()); self::assertCount(2, OrderType::getConstants());

View File

@ -21,6 +21,9 @@ use phpOMS\Stdlib\Queue\PriorityMode;
*/ */
class PriorityModeTest extends \PHPUnit\Framework\TestCase class PriorityModeTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(4, PriorityMode::getConstants()); self::assertCount(4, PriorityMode::getConstants());

View File

@ -21,6 +21,9 @@ use phpOMS\System\File\ContentPutMode;
*/ */
class ContentPutModeTest extends \PHPUnit\Framework\TestCase class ContentPutModeTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(4, ContentPutMode::getConstants()); self::assertCount(4, ContentPutMode::getConstants());

View File

@ -21,6 +21,9 @@ use phpOMS\System\File\ExtensionType;
*/ */
class ExtensionTypeTest extends \PHPUnit\Framework\TestCase class ExtensionTypeTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(13, ExtensionType::getConstants()); self::assertCount(13, ExtensionType::getConstants());

View File

@ -23,6 +23,9 @@ use phpOMS\System\SystemType;
*/ */
class SystemTypeTest extends \PHPUnit\Framework\TestCase class SystemTypeTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(4, SystemType::getConstants()); self::assertCount(4, SystemType::getConstants());

View File

@ -21,6 +21,9 @@ use phpOMS\Utils\Barcode\OrientationType;
*/ */
class OrientationTypeTest extends \PHPUnit\Framework\TestCase class OrientationTypeTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(2, OrientationType::getConstants()); self::assertCount(2, OrientationType::getConstants());

View File

@ -21,6 +21,9 @@ use phpOMS\Utils\Converter\AngleType;
*/ */
class AngleTypeTest extends \PHPUnit\Framework\TestCase class AngleTypeTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(10, AngleType::getConstants()); self::assertCount(10, AngleType::getConstants());

View File

@ -21,6 +21,9 @@ use phpOMS\Utils\Converter\AreaType;
*/ */
class AreaTypeTest extends \PHPUnit\Framework\TestCase class AreaTypeTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(13, AreaType::getConstants()); self::assertCount(13, AreaType::getConstants());

View File

@ -21,6 +21,9 @@ use phpOMS\Utils\Converter\EnergyPowerType;
*/ */
class EnergyPowerTypeTest extends \PHPUnit\Framework\TestCase class EnergyPowerTypeTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(9, EnergyPowerType::getConstants()); self::assertCount(9, EnergyPowerType::getConstants());

View File

@ -21,6 +21,9 @@ use phpOMS\Utils\Converter\FileSizeType;
*/ */
class FileSizeTypeTest extends \PHPUnit\Framework\TestCase class FileSizeTypeTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(10, FileSizeType::getConstants()); self::assertCount(10, FileSizeType::getConstants());

View File

@ -21,6 +21,9 @@ use phpOMS\Utils\Converter\LengthType;
*/ */
class LengthTypeTest extends \PHPUnit\Framework\TestCase class LengthTypeTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(21, LengthType::getConstants()); self::assertCount(21, LengthType::getConstants());

View File

@ -21,6 +21,9 @@ use phpOMS\Utils\Converter\PressureType;
*/ */
class PressureTypeTest extends \PHPUnit\Framework\TestCase class PressureTypeTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(13, PressureType::getConstants()); self::assertCount(13, PressureType::getConstants());

View File

@ -21,6 +21,9 @@ use phpOMS\Utils\Converter\SpeedType;
*/ */
class SpeedTypeTest extends \PHPUnit\Framework\TestCase class SpeedTypeTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(34, SpeedType::getConstants()); self::assertCount(34, SpeedType::getConstants());

View File

@ -21,6 +21,9 @@ use phpOMS\Utils\Converter\TemperatureType;
*/ */
class TemperatureTypeTest extends \PHPUnit\Framework\TestCase class TemperatureTypeTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(8, TemperatureType::getConstants()); self::assertCount(8, TemperatureType::getConstants());

View File

@ -21,6 +21,9 @@ use phpOMS\Utils\Converter\TimeType;
*/ */
class TimeTypeTest extends \PHPUnit\Framework\TestCase class TimeTypeTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(9, TimeType::getConstants()); self::assertCount(9, TimeType::getConstants());

View File

@ -21,6 +21,9 @@ use phpOMS\Utils\Converter\VolumeType;
*/ */
class VolumeTypeTest extends \PHPUnit\Framework\TestCase class VolumeTypeTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(38, VolumeType::getConstants()); self::assertCount(38, VolumeType::getConstants());

View File

@ -21,6 +21,9 @@ use phpOMS\Utils\Converter\WeightType;
*/ */
class WeightTypeTest extends \PHPUnit\Framework\TestCase class WeightTypeTest extends \PHPUnit\Framework\TestCase
{ {
/**
* @coversNothing
*/
public function testEnums() : void public function testEnums() : void
{ {
self::assertCount(14, WeightType::getConstants()); self::assertCount(14, WeightType::getConstants());

Some files were not shown because too many files have changed in this diff Show More