diff --git a/Ai/Ocr/BasicOcr.php b/Ai/Ocr/BasicOcr.php index 65f74b620..31cf13ef0 100644 --- a/Ai/Ocr/BasicOcr.php +++ b/Ai/Ocr/BasicOcr.php @@ -81,7 +81,7 @@ final class BasicOcr */ private function readImages(string $path, int $limit = 0) : array { - if (!\file_exists($path)) { + if (!\is_file($path)) { throw new PathException($path); } @@ -144,7 +144,7 @@ final class BasicOcr */ private function readLabels(string $path, int $limit = 0) : array { - if (!\file_exists($path)) { + if (!\is_file($path)) { throw new PathException($path); } diff --git a/Application/ApplicationInfo.php b/Application/ApplicationInfo.php index 9a7e6207b..8430fe7c0 100644 --- a/Application/ApplicationInfo.php +++ b/Application/ApplicationInfo.php @@ -80,7 +80,7 @@ final class ApplicationInfo */ public function load() : void { - if (!\file_exists($this->path)) { + if (!\is_file($this->path)) { throw new PathException($this->path); } @@ -100,7 +100,7 @@ final class ApplicationInfo */ public function update() : void { - if (!\file_exists($this->path)) { + if (!\is_file($this->path)) { throw new PathException($this->path); } diff --git a/Application/ApplicationManager.php b/Application/ApplicationManager.php index 9c86e6938..76c817b26 100644 --- a/Application/ApplicationManager.php +++ b/Application/ApplicationManager.php @@ -97,7 +97,7 @@ final class ApplicationManager public function install(string $source, string $destination, string $theme = 'Default') : bool { $destination = \rtrim($destination, '\\/'); - if (!\file_exists($source) || \file_exists($destination)) { + if (!\is_dir($source) || \is_dir($destination)) { return false; } @@ -152,11 +152,11 @@ final class ApplicationManager */ private function installTheme(string $destination, string $theme) : void { - if (\file_exists($destination . '/css')) { + if (\is_dir($destination . '/css')) { Directory::delete($destination . '/css'); } - if (\file_exists($destination . '/Themes/' . $theme . '/css')) { + if (\is_dir($destination . '/Themes/' . $theme . '/css')) { Directory::copy( $destination . '/Themes/' . $theme . '/css', $destination . '/css', diff --git a/Autoloader.php b/Autoloader.php index f98f5275a..513720503 100644 --- a/Autoloader.php +++ b/Autoloader.php @@ -80,7 +80,7 @@ final class Autoloader $class = \str_replace(['_', '\\'], '/', $class); foreach (self::$paths as $path) { - if (\file_exists($file = $path . $class . '.php')) { + if (\is_file($file = $path . $class . '.php')) { include $file; return; @@ -105,7 +105,7 @@ final class Autoloader $class = \str_replace(['_', '\\'], '/', $class); foreach (self::$paths as $path) { - if (\file_exists($path . $class . '.php')) { + if (\is_file($path . $class . '.php')) { return true; } } diff --git a/DataStorage/Session/FileSessionHandler.php b/DataStorage/Session/FileSessionHandler.php index 647cb6813..466037379 100644 --- a/DataStorage/Session/FileSessionHandler.php +++ b/DataStorage/Session/FileSessionHandler.php @@ -102,7 +102,7 @@ final class FileSessionHandler implements \SessionHandlerInterface, \SessionIdIn */ public function read($id) { - if (!\file_exists($this->savePath . '/sess_' . $id)) { + if (!\is_file($this->savePath . '/sess_' . $id)) { return ''; } @@ -136,7 +136,7 @@ final class FileSessionHandler implements \SessionHandlerInterface, \SessionIdIn public function destroy($id) { $file = $this->savePath . '/sess_' . $id; - if (\file_exists($file)) { + if (\is_file($file)) { \unlink($file); } @@ -161,7 +161,7 @@ final class FileSessionHandler implements \SessionHandlerInterface, \SessionIdIn } foreach ($files as $file) { - if (\filemtime($file) + $maxlifetime < \time() && \file_exists($file)) { + if (\filemtime($file) + $maxlifetime < \time() && \is_file($file)) { \unlink($file); } } diff --git a/Event/EventManager.php b/Event/EventManager.php index 0e9cabb18..b55967b78 100644 --- a/Event/EventManager.php +++ b/Event/EventManager.php @@ -104,7 +104,7 @@ final class EventManager implements \Countable */ public function importFromFile(string $path) : bool { - if (!\file_exists($path)) { + if (!\is_file($path)) { return false; } diff --git a/Localization/L11nManager.php b/Localization/L11nManager.php index a36495d6a..60db9a210 100644 --- a/Localization/L11nManager.php +++ b/Localization/L11nManager.php @@ -114,7 +114,7 @@ final class L11nManager public function loadLanguageFromFile(string $language, string $from, string $file) : void { $lang = []; - if (\file_exists($file)) { + if (\is_file($file)) { /** @noinspection PhpIncludeInspection */ $lang = include $file; } diff --git a/Localization/Localization.php b/Localization/Localization.php index f59915d71..4a5f18b04 100644 --- a/Localization/Localization.php +++ b/Localization/Localization.php @@ -248,7 +248,7 @@ class Localization implements \JsonSerializable } if ($countryCode !== '*' - && !\file_exists(__DIR__ . '/../Localization/Defaults/Definitions/' . $langCode . '_' . $countryCode . '.json') + && !\is_file(__DIR__ . '/../Localization/Defaults/Definitions/' . $langCode . '_' . $countryCode . '.json') ) { $countryCode = ''; } diff --git a/Log/FileLogger.php b/Log/FileLogger.php index b460cc181..697443e6f 100644 --- a/Log/FileLogger.php +++ b/Log/FileLogger.php @@ -117,7 +117,7 @@ final class FileLogger implements LoggerInterface */ private function createFile() : void { - if (!$this->created && !\file_exists($this->path)) { + if (!$this->created && !\is_file($this->path)) { File::create($this->path); $this->created = true; } @@ -380,7 +380,7 @@ final class FileLogger implements LoggerInterface { $levels = []; - if (!\file_exists($this->path)) { + if (!\is_file($this->path)) { return $levels; } @@ -427,7 +427,7 @@ final class FileLogger implements LoggerInterface { $connection = []; - if (!\file_exists($this->path)) { + if (!\is_file($this->path)) { return $connection; } @@ -477,7 +477,7 @@ final class FileLogger implements LoggerInterface $logs = []; $id = 0; - if (!\file_exists($this->path)) { + if (!\is_file($this->path)) { return $logs; } @@ -535,7 +535,7 @@ final class FileLogger implements LoggerInterface $log = []; $current = 0; - if (!\file_exists($this->path)) { + if (!\is_file($this->path)) { return $log; } diff --git a/Message/Console/ConsoleRequest.php b/Message/Console/ConsoleRequest.php index ebe652882..1fab1883d 100644 --- a/Message/Console/ConsoleRequest.php +++ b/Message/Console/ConsoleRequest.php @@ -146,6 +146,18 @@ final class ConsoleRequest extends RequestAbstract $this->method = $method; } + /** + * Get request method. + * + * @return string + * + * @since 1.0.0 + */ + public function getMethod() : string + { + return $this->method; + } + /** * Determine request OS. * diff --git a/Model/Message/DynamicList.php b/Model/Message/DynamicList.php new file mode 100644 index 000000000..e69de29bb diff --git a/Module/InstallerAbstract.php b/Module/InstallerAbstract.php index 3ffab67a3..c5cbf557e 100644 --- a/Module/InstallerAbstract.php +++ b/Module/InstallerAbstract.php @@ -110,8 +110,7 @@ abstract class InstallerAbstract public static function installSettings(DatabasePool $dbPool, ModuleInfo $info, SettingsInterface $cfgHandler) : void { $path = \dirname($info->getPath()) . '/Admin/Install/Settings.install.php'; - - if (!\file_exists($path)) { + if (!\is_file($path)) { return; } @@ -135,8 +134,7 @@ abstract class InstallerAbstract protected static function createTables(DatabasePool $dbPool, ModuleInfo $info) : void { $path = \dirname($info->getPath()) . '/Admin/Install/db.json'; - - if (!\file_exists($path)) { + if (!\is_file($path)) { return; } @@ -203,7 +201,7 @@ abstract class InstallerAbstract foreach ($directories as $child) { if ($child instanceof Directory) { foreach ($child as $file) { - if (!\file_exists(__DIR__ . '/../../' . $child->getName() . '/' . \basename($file->getName(), '.php')) + if (!\is_dir(__DIR__ . '/../../' . $child->getName() . '/' . \basename($file->getName(), '.php')) || ($appInfo !== null && \basename($file->getName(), '.php') !== $appInfo->getInternalName()) ) { continue; @@ -212,7 +210,7 @@ abstract class InstallerAbstract self::installRoutes(__DIR__ . '/../../' . $child->getName() . '/' . \basename($file->getName(), '.php') . '/Routes.php', $file->getPath()); } } elseif ($child instanceof File) { - if (!\file_exists(__DIR__ . '/../../' . $child->getName()) + if (!\is_dir(__DIR__ . '/../../' . $child->getName()) || ($appInfo !== null && \basename($child->getName(), '.php') !== $appInfo->getInternalName()) ) { continue; @@ -237,15 +235,15 @@ abstract class InstallerAbstract */ protected static function installRoutes(string $destRoutePath, string $srcRoutePath) : void { - if (!\file_exists($destRoutePath)) { + if (!\is_file($destRoutePath)) { \file_put_contents($destRoutePath, 'getPath()) . '/Admin/Hooks'); - foreach ($directories as $key => $child) { + foreach ($directories as $child) { if ($child instanceof Directory) { - foreach ($child as $key2 => $file) { - if (!\file_exists(__DIR__ . '/../../' . $child->getName() . '/' . \basename($file->getName(), '.php')) + foreach ($child as $file) { + if (!\is_file(__DIR__ . '/../../' . $child->getName() . '/' . \basename($file->getName(), '.php')) || ($appInfo !== null && \basename($file->getName(), '.php') !== $appInfo->getInternalName()) ) { continue; @@ -291,7 +289,7 @@ abstract class InstallerAbstract self::installHooks(__DIR__ . '/../../' . $child->getName() . '/' . \basename($file->getName(), '.php') . '/Hooks.php', $file->getPath()); } } elseif ($child instanceof File) { - if (!\file_exists(__DIR__ . '/../../' . $child->getName()) + if (!\is_file(__DIR__ . '/../../' . $child->getName()) || ($appInfo !== null && \basename($child->getName(), '.php') !== $appInfo->getInternalName()) ) { continue; @@ -317,15 +315,15 @@ abstract class InstallerAbstract */ protected static function installHooks(string $destHookPath, string $srcHookPath) : void { - if (!\file_exists($destHookPath)) { + if (!\is_file($destHookPath)) { \file_put_contents($destHookPath, 'path)) { + if (!\is_file($this->path)) { throw new PathException($this->path); } @@ -100,7 +100,7 @@ final class ModuleInfo */ public function update() : void { - if (!\file_exists($this->path)) { + if (!\is_file($this->path)) { throw new PathException($this->path); } diff --git a/Module/ModuleManager.php b/Module/ModuleManager.php index 22504a45a..f28ec1d3e 100644 --- a/Module/ModuleManager.php +++ b/Module/ModuleManager.php @@ -191,6 +191,7 @@ final class ModuleManager public function getActiveModules(bool $useCache = true) : array { if (empty($this->active) || !$useCache) { + // @todo: use ModuleMapper and return objects $query = new Builder($this->app->dbPool->get('select')); $sth = $query->select('module.module_path') ->from('module') @@ -202,9 +203,8 @@ final class ModuleManager foreach ($active as $module) { $path = $this->modulePath . '/' . $module . '/info.json'; - if (!\file_exists($path)) { + if (!\is_file($path)) { continue; - // throw new PathException($path); } $content = \file_get_contents($path); @@ -257,6 +257,8 @@ final class ModuleManager public function getAllModules() : array { if (empty($this->all)) { + // @todo: return objects + \chdir($this->modulePath); $files = \glob('*', \GLOB_ONLYDIR); @@ -268,9 +270,8 @@ final class ModuleManager for ($i = 0; $i < $c; ++$i) { $path = $this->modulePath . '/' . $files[$i] . '/info.json'; - if (!\file_exists($path)) { + if (!\is_file($path)) { continue; - // throw new PathException($path); } $content = \file_get_contents($path); @@ -307,6 +308,7 @@ final class ModuleManager public function getInstalledModules(bool $useCache = true) : array { if (empty($this->installed) || !$useCache) { + // @todo: use ModuleMapper and return objects $query = new Builder($this->app->dbPool->get('select')); $sth = $query->select('module.module_path') ->from('module') @@ -317,9 +319,8 @@ final class ModuleManager foreach ($installed as $module) { $path = $this->modulePath . '/' . $module . '/info.json'; - if (!\file_exists($path)) { + if (!\is_file($path)) { continue; - // throw new PathException($path); } $this->installed[$module] = $this->loadInfo($module); @@ -500,7 +501,7 @@ final class ModuleManager * @todo Orange-Management/Modules#193 * Implement online database and downloading api for modules and updates */ - if (!\file_exists($this->modulePath . '/' . $module . '/Admin/Installer.php')) { + if (!\is_file($this->modulePath . '/' . $module . '/Admin/Installer.php')) { return false; } @@ -550,7 +551,7 @@ final class ModuleManager return false; } - if (!\file_exists($this->modulePath . '/' . $module . '/Admin/Uninstaller.php')) { + if (!\is_file($this->modulePath . '/' . $module . '/Admin/Uninstaller.php')) { return false; } @@ -643,7 +644,7 @@ final class ModuleManager */ public function installProviding(string $from, string $for) : void { - if (\file_exists($this->modulePath . '/' . $from . '/Admin/Install/' . $for . '.php')) { + if (\is_file($this->modulePath . '/' . $from . '/Admin/Install/' . $for . '.php')) { $class = '\\Modules\\' . $from . '\\Admin\\Install\\' . $for; $class::install($this->modulePath, $this->app->dbPool); } diff --git a/Module/PackageManager.php b/Module/PackageManager.php index bac88111a..303403178 100644 --- a/Module/PackageManager.php +++ b/Module/PackageManager.php @@ -117,7 +117,7 @@ final class PackageManager */ public function load() : void { - if (!\file_exists($this->extractPath)) { + if (!\is_dir($this->extractPath)) { throw new PathException($this->extractPath); } @@ -135,7 +135,7 @@ final class PackageManager */ public function isValid() : bool { - if (!\file_exists($this->extractPath . '/package.cert')) { + if (!\is_dir($this->extractPath . '/package.cert')) { return false; } diff --git a/Module/UninstallerAbstract.php b/Module/UninstallerAbstract.php index 3e42b1196..577300282 100644 --- a/Module/UninstallerAbstract.php +++ b/Module/UninstallerAbstract.php @@ -62,7 +62,7 @@ abstract class UninstallerAbstract { $path = \dirname($info->getPath()) . '/Admin/Install/db.json'; - if (!\file_exists($path)) { + if (!\is_file($path)) { return; } diff --git a/Router/SocketRouter.php b/Router/SocketRouter.php index ae2b5b849..4806eb98d 100644 --- a/Router/SocketRouter.php +++ b/Router/SocketRouter.php @@ -57,7 +57,7 @@ final class SocketRouter implements RouterInterface */ public function importFromFile(string $path) : bool { - if (!\file_exists($path)) { + if (!\is_file($path)) { return false; } diff --git a/Router/WebRouter.php b/Router/WebRouter.php index e81bf4f97..312f04ed9 100644 --- a/Router/WebRouter.php +++ b/Router/WebRouter.php @@ -59,7 +59,7 @@ final class WebRouter implements RouterInterface */ public function importFromFile(string $path) : bool { - if (!\file_exists($path)) { + if (!\is_file($path)) { return false; } diff --git a/System/File/Ftp/Directory.php b/System/File/Ftp/Directory.php index a8aaf98d9..08299724f 100644 --- a/System/File/Ftp/Directory.php +++ b/System/File/Ftp/Directory.php @@ -439,7 +439,7 @@ class Directory extends FileAbstract implements DirectoryInterface, FtpContainer return false; } - if (!\file_exists($to)) { + if (!\is_dir($to)) { \mkdir($to); } @@ -452,7 +452,7 @@ class Directory extends FileAbstract implements DirectoryInterface, FtpContainer } } - return \file_exists($to); + return \is_dir($to); } /** @@ -468,7 +468,7 @@ class Directory extends FileAbstract implements DirectoryInterface, FtpContainer */ public static function put($con, string $from, string $to) : bool { - if (!\file_exists($from)) { + if (!\is_dir($from)) { return false; } @@ -760,7 +760,7 @@ class Directory extends FileAbstract implements DirectoryInterface, FtpContainer public function isExisting(string $name = null) : bool { if ($name === null) { - return \file_exists($this->path); + return \is_dir($this->path); } $name = isset($this->nodes[$name]) ? $name : $this->path . '/' . $name; @@ -801,7 +801,7 @@ class Directory extends FileAbstract implements DirectoryInterface, FtpContainer $list = []; $path = \rtrim($path, '\\/'); - if (!\file_exists($path)) { + if (!\is_dir($path)) { return $list; } diff --git a/System/File/Local/Directory.php b/System/File/Local/Directory.php index 4bbee8f5e..4ad35c27b 100644 --- a/System/File/Local/Directory.php +++ b/System/File/Local/Directory.php @@ -61,7 +61,7 @@ final class Directory extends FileAbstract implements DirectoryInterface, LocalC $this->filter = \ltrim($filter, '\\/'); parent::__construct($path); - if ($initialize && \file_exists($this->path)) { + if ($initialize && \is_dir($this->path)) { $this->index(); } } @@ -79,7 +79,7 @@ final class Directory extends FileAbstract implements DirectoryInterface, LocalC */ public static function list(string $path, string $filter = '*', bool $recursive = false) : array { - if (!\file_exists($path)) { + if (!\is_dir($path)) { return []; } @@ -125,7 +125,7 @@ final class Directory extends FileAbstract implements DirectoryInterface, LocalC $list = []; $path = \rtrim($path, '\\/'); - if (!\file_exists($path)) { + if (!\is_dir($path)) { return $list; } @@ -203,7 +203,7 @@ final class Directory extends FileAbstract implements DirectoryInterface, LocalC */ public static function size(string $dir, bool $recursive = true) : int { - if (!\file_exists($dir) || !\is_readable($dir)) { + if (!\is_dir($dir) || !\is_readable($dir)) { return -1; } @@ -245,7 +245,7 @@ final class Directory extends FileAbstract implements DirectoryInterface, LocalC */ public static function count(string $path, bool $recursive = true, array $ignore = []) : int { - if (!\file_exists($path)) { + if (!\is_dir($path)) { return -1; } @@ -279,7 +279,7 @@ final class Directory extends FileAbstract implements DirectoryInterface, LocalC */ public static function delete(string $path) : bool { - if (empty($path) || !\file_exists($path)) { + if (empty($path) || !\is_dir($path)) { return false; } @@ -325,7 +325,7 @@ final class Directory extends FileAbstract implements DirectoryInterface, LocalC */ public static function created(string $path) : \DateTime { - if (!\file_exists($path)) { + if (!\is_dir($path)) { throw new PathException($path); } @@ -342,7 +342,7 @@ final class Directory extends FileAbstract implements DirectoryInterface, LocalC */ public static function changed(string $path) : \DateTime { - if (!\file_exists($path)) { + if (!\is_dir($path)) { throw new PathException($path); } @@ -359,7 +359,7 @@ final class Directory extends FileAbstract implements DirectoryInterface, LocalC */ public static function owner(string $path) : int { - if (!\file_exists($path)) { + if (!\is_dir($path)) { throw new PathException($path); } @@ -371,7 +371,7 @@ final class Directory extends FileAbstract implements DirectoryInterface, LocalC */ public static function permission(string $path) : int { - if (!\file_exists($path)) { + if (!\is_dir($path)) { return -1; } @@ -384,14 +384,14 @@ final class Directory extends FileAbstract implements DirectoryInterface, LocalC public static function copy(string $from, string $to, bool $overwrite = false) : bool { if (!\is_dir($from) - || (!$overwrite && \file_exists($to)) + || (!$overwrite && \is_dir($to)) ) { return false; } - if (!\file_exists($to)) { + if (!\is_dir($to)) { self::create($to, 0755, true); - } elseif ($overwrite && \file_exists($to)) { + } elseif ($overwrite && \is_dir($to)) { self::delete($to); self::create($to, 0755, true); } @@ -418,12 +418,12 @@ final class Directory extends FileAbstract implements DirectoryInterface, LocalC public static function move(string $from, string $to, bool $overwrite = false) : bool { if (!\is_dir($from) - || (!$overwrite && \file_exists($to)) + || (!$overwrite && \is_dir($to)) ) { return false; } - if ($overwrite && \file_exists($to)) { + if ($overwrite && \is_dir($to)) { self::delete($to); } @@ -441,7 +441,7 @@ final class Directory extends FileAbstract implements DirectoryInterface, LocalC */ public static function exists(string $path) : bool { - return \file_exists($path); + return \is_dir($path); } /** @@ -478,7 +478,7 @@ final class Directory extends FileAbstract implements DirectoryInterface, LocalC public function isExisting(string $name = null) : bool { if ($name === null) { - return \file_exists($this->path); + return \is_dir($this->path); } $name = isset($this->nodes[$name]) ? $name : $this->path . '/' . $name; @@ -499,8 +499,8 @@ final class Directory extends FileAbstract implements DirectoryInterface, LocalC */ public static function create(string $path, int $permission = 0755, bool $recursive = false) : bool { - if (!\file_exists($path)) { - if (!$recursive && !\file_exists(self::parent($path))) { + if (!\is_dir($path)) { + if (!$recursive && !\is_dir(self::parent($path))) { return false; } diff --git a/System/File/Local/File.php b/System/File/Local/File.php index e6e4e1959..adf44c2ea 100644 --- a/System/File/Local/File.php +++ b/System/File/Local/File.php @@ -43,7 +43,7 @@ final class File extends FileAbstract implements FileInterface, LocalContainerIn parent::__construct($path); $this->count = 1; - if (\file_exists($this->path)) { + if (\is_file($this->path)) { $this->index(); } } @@ -71,7 +71,7 @@ final class File extends FileAbstract implements FileInterface, LocalContainerIn */ public static function put(string $path, string $content, int $mode = ContentPutMode::REPLACE | ContentPutMode::CREATE) : bool { - $exists = \file_exists($path); + $exists = \is_file($path); try { if (($exists && ContentPutMode::hasFlag($mode, ContentPutMode::APPEND)) @@ -111,7 +111,7 @@ final class File extends FileAbstract implements FileInterface, LocalContainerIn */ public static function get(string $path) : string { - if (!\file_exists($path)) { + if (!\is_file($path)) { throw new PathException($path); } @@ -184,7 +184,7 @@ final class File extends FileAbstract implements FileInterface, LocalContainerIn */ public static function exists(string $path) : bool { - return \file_exists($path); + return \is_file($path); } /** @@ -208,7 +208,7 @@ final class File extends FileAbstract implements FileInterface, LocalContainerIn */ public static function created(string $path) : \DateTime { - if (!\file_exists($path)) { + if (!\is_file($path)) { throw new PathException($path); } @@ -222,7 +222,7 @@ final class File extends FileAbstract implements FileInterface, LocalContainerIn */ public static function changed(string $path) : \DateTime { - if (!\file_exists($path)) { + if (!\is_file($path)) { throw new PathException($path); } @@ -253,7 +253,7 @@ final class File extends FileAbstract implements FileInterface, LocalContainerIn */ public static function size(string $path, bool $recursive = true) : int { - if (!\file_exists($path)) { + if (!\is_file($path)) { return -1; } @@ -265,7 +265,7 @@ final class File extends FileAbstract implements FileInterface, LocalContainerIn */ public static function owner(string $path) : int { - if (!\file_exists($path)) { + if (!\is_file($path)) { throw new PathException($path); } @@ -277,7 +277,7 @@ final class File extends FileAbstract implements FileInterface, LocalContainerIn */ public static function permission(string $path) : int { - if (!\file_exists($path)) { + if (!\is_file($path)) { return -1; } @@ -341,7 +341,7 @@ final class File extends FileAbstract implements FileInterface, LocalContainerIn public static function copy(string $from, string $to, bool $overwrite = false) : bool { if (!\is_file($from) - || (!$overwrite && \file_exists($to)) + || (!$overwrite && \is_file($to)) ) { return false; } @@ -350,7 +350,7 @@ final class File extends FileAbstract implements FileInterface, LocalContainerIn Directory::create(\dirname($to), 0755, true); } - if ($overwrite && \file_exists($to)) { + if ($overwrite && \is_file($to)) { \unlink($to); } @@ -380,7 +380,7 @@ final class File extends FileAbstract implements FileInterface, LocalContainerIn */ public static function delete(string $path) : bool { - if (!\file_exists($path)) { + if (!\is_file($path)) { return false; } @@ -430,7 +430,7 @@ final class File extends FileAbstract implements FileInterface, LocalContainerIn */ public function isExisting() : bool { - return \file_exists($this->path); + return \is_file($this->path); } /** @@ -438,7 +438,7 @@ final class File extends FileAbstract implements FileInterface, LocalContainerIn */ public static function create(string $path) : bool { - if (!\file_exists($path)) { + if (!\is_file($path)) { if (!Directory::exists(\dirname($path))) { Directory::create(\dirname($path), 0755, true); } diff --git a/Utils/Git/Repository.php b/Utils/Git/Repository.php index 4e9bb9e25..0082bbc34 100644 --- a/Utils/Git/Repository.php +++ b/Utils/Git/Repository.php @@ -95,7 +95,7 @@ class Repository $this->path = \realpath($path); - if (\file_exists($this->path . '/.git') && \is_dir($this->path . '/.git')) { + if (\is_dir($this->path . '/.git') && \is_dir($this->path . '/.git')) { $this->bare = false; } elseif (\is_file($this->path . '/config')) { // Is this a bare repo? $parseIni = \parse_ini_file($this->path . '/config'); @@ -251,7 +251,7 @@ class Repository */ public function create(string $source = null) : void { - if (!\is_dir($this->path) || \file_exists($this->path . '/.git')) { + if (!\is_dir($this->path) || \is_dir($this->path . '/.git')) { throw new \Exception('Already repository'); } @@ -662,7 +662,7 @@ class Repository continue; } - if (!\file_exists($path = $this->getDirectoryPath() . ($this->bare ? '/' : '/../') . $line)) { + if (!\is_dir($path = $this->getDirectoryPath() . ($this->bare ? '/' : '/../') . $line)) { return 0; } diff --git a/Utils/IO/Zip/Gz.php b/Utils/IO/Zip/Gz.php index 113ca159b..1eb86ee4c 100644 --- a/Utils/IO/Zip/Gz.php +++ b/Utils/IO/Zip/Gz.php @@ -32,7 +32,7 @@ class Gz implements ArchiveInterface public static function pack($source, string $destination, bool $overwrite = false) : bool { $destination = \str_replace('\\', '/', $destination); - if (!$overwrite && \file_exists($destination) || !\file_exists($source)) { + if (!$overwrite && \is_file($destination) || !\is_file($source)) { return false; } @@ -58,7 +58,7 @@ class Gz implements ArchiveInterface public static function unpack(string $source, string $destination) : bool { $destination = \str_replace('\\', '/', $destination); - if (\file_exists($destination) || !\file_exists($source)) { + if (\is_file($destination) || !\is_file($source)) { return false; } diff --git a/Utils/IO/Zip/Tar.php b/Utils/IO/Zip/Tar.php index 3c3c2ba94..a6819221f 100644 --- a/Utils/IO/Zip/Tar.php +++ b/Utils/IO/Zip/Tar.php @@ -35,7 +35,7 @@ class Tar implements ArchiveInterface { $destination = FileUtils::absolute(\str_replace('\\', '/', $destination)); - if (!$overwrite && \file_exists($destination)) { + if (!$overwrite && \is_file($destination)) { return false; } @@ -49,13 +49,6 @@ class Tar implements ArchiveInterface $source = $relative; } - if (($source = \realpath($source)) === false - || ($source = \str_replace('\\', '/', $source)) === false - || !\file_exists($source) - ) { - continue; - } - if (\is_dir($source)) { $files = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator($source), @@ -84,6 +77,8 @@ class Tar implements ArchiveInterface } } elseif (\is_file($source)) { $tar->addFile($source, $relative); + } else { + continue; } } @@ -95,7 +90,7 @@ class Tar implements ArchiveInterface */ public static function unpack(string $source, string $destination) : bool { - if (!\file_exists($source)) { + if (!\is_dir($source)) { return false; } diff --git a/Utils/IO/Zip/TarGz.php b/Utils/IO/Zip/TarGz.php index 7a5496ff7..9364afd58 100644 --- a/Utils/IO/Zip/TarGz.php +++ b/Utils/IO/Zip/TarGz.php @@ -34,7 +34,7 @@ class TarGz implements ArchiveInterface public static function pack($source, string $destination, bool $overwrite = false) : bool { $destination = \str_replace('\\', '/', $destination); - if (!$overwrite && \file_exists($destination)) { + if (!$overwrite && \is_file($destination)) { return false; } @@ -57,7 +57,7 @@ class TarGz implements ArchiveInterface public static function unpack(string $source, string $destination) : bool { $destination = \str_replace('\\', '/', $destination); - if (!\file_exists($destination) || !\file_exists($source)) { + if (!\is_dir($destination) || !\is_file($source)) { return false; } diff --git a/Utils/IO/Zip/Zip.php b/Utils/IO/Zip/Zip.php index 4f9bd28bc..159c0e753 100644 --- a/Utils/IO/Zip/Zip.php +++ b/Utils/IO/Zip/Zip.php @@ -35,7 +35,7 @@ class Zip implements ArchiveInterface { $destination = FileUtils::absolute(\str_replace('\\', '/', $destination)); - if (!$overwrite && \file_exists($destination)) { + if (!$overwrite && \is_file($destination)) { return false; } @@ -52,13 +52,6 @@ class Zip implements ArchiveInterface $source = $relative; } - if (($source = \realpath($source)) === false - || ($source = \str_replace('\\', '/', $source)) === false - || !\file_exists($source) - ) { - continue; - } - if (\is_dir($source)) { $files = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator($source), @@ -87,6 +80,8 @@ class Zip implements ArchiveInterface } } elseif (\is_file($source)) { $zip->addFile($source, $relative); + } else { + continue; } } @@ -98,7 +93,7 @@ class Zip implements ArchiveInterface */ public static function unpack(string $source, string $destination) : bool { - if (!\file_exists($source)) { + if (!\is_file($source)) { return false; } diff --git a/Utils/TaskSchedule/SchedulerAbstract.php b/Utils/TaskSchedule/SchedulerAbstract.php index 120ac419a..4affdd3ee 100644 --- a/Utils/TaskSchedule/SchedulerAbstract.php +++ b/Utils/TaskSchedule/SchedulerAbstract.php @@ -90,7 +90,7 @@ abstract class SchedulerAbstract ]; foreach ($paths as $path) { - if (\file_exists($path)) { + if (\is_file($path)) { self::setBin($path); return true; diff --git a/Views/ViewAbstract.php b/Views/ViewAbstract.php index 00edeb1c7..c91e89fe8 100644 --- a/Views/ViewAbstract.php +++ b/Views/ViewAbstract.php @@ -225,7 +225,7 @@ abstract class ViewAbstract implements RenderableInterface $path = __DIR__ . '/../..' . $this->template . '.tpl.php'; - if (!\file_exists($path)) { + if (!\is_file($path)) { throw new PathException($path); } diff --git a/tests/Account/NullAccountTest.php b/tests/Account/NullAccountTest.php index 35b713cdb..be4d9564c 100644 --- a/tests/Account/NullAccountTest.php +++ b/tests/Account/NullAccountTest.php @@ -23,11 +23,19 @@ use phpOMS\Account\NullAccount; */ final class NullAccountTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\Account\NullAccount + * @group framework + */ public function testNull() : void { self::assertInstanceOf('\phpOMS\Account\Account', new NullAccount()); } + /** + * @covers phpOMS\Account\NullAccount + * @group framework + */ public function testId() : void { $null = new NullAccount(2); diff --git a/tests/Ai/Ocr/BasicOcrTest.php b/tests/Ai/Ocr/BasicOcrTest.php index 1eeda73d0..54bf3859d 100644 --- a/tests/Ai/Ocr/BasicOcrTest.php +++ b/tests/Ai/Ocr/BasicOcrTest.php @@ -21,6 +21,10 @@ use phpOMS\Ai\Ocr\BasicOcr; */ class BasicOcrTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\Ai\Ocr\BasicOcr + * @group framework + */ public function testOcr() : void { $ocr = new BasicOcr(); @@ -38,6 +42,10 @@ class BasicOcrTest extends \PHPUnit\Framework\TestCase ); } + /** + * @covers phpOMS\Ai\Ocr\BasicOcr + * @group framework + */ public function testInvalidImagePath() : void { $this->expectException(\phpOMS\System\File\PathException::class); @@ -45,6 +53,10 @@ class BasicOcrTest extends \PHPUnit\Framework\TestCase $ocr->trainWith(__DIR__ . '/invalid', __DIR__ . '/train-labels-idx1-ubyte', 1); } + /** + * @covers phpOMS\Ai\Ocr\BasicOcr + * @group framework + */ public function testInvalidLabelPath() : void { $this->expectException(\phpOMS\System\File\PathException::class); diff --git a/tests/Application/ApplicationManagerTest.php b/tests/Application/ApplicationManagerTest.php index c366a90fc..6418d4d06 100644 --- a/tests/Application/ApplicationManagerTest.php +++ b/tests/Application/ApplicationManagerTest.php @@ -17,7 +17,6 @@ namespace phpOMS\tests\Application; require_once __DIR__ . '/../Autoloader.php'; use Model\CoreSettings; -use Modules\CMS\Models\Application; use phpOMS\Application\ApplicationAbstract; use phpOMS\Application\ApplicationManager; use phpOMS\Dispatcher\Dispatcher; @@ -49,17 +48,29 @@ class ApplicationManagerTest extends \PHPUnit\Framework\TestCase $this->appManager = new ApplicationManager($app->moduleManager); } + /** + * @covers phpOMS\Application\ApplicationManager + * @group framework + */ public function testInstall() : void { self::markTestIncomplete(); } + /** + * @covers phpOMS\Application\ApplicationManager + * @group framework + */ public function testInvalidSourceDestinationInstallPath() : void { self::assertFalse($this->appManager->install(__DIR__ . '/invalid', __DIR__)); self::assertFalse($this->appManager->install(__DIR__, __DIR__)); } + /** + * @covers phpOMS\Application\ApplicationManager + * @group framework + */ public function testMissingApplicationInfoFile() : void { $this->expectException(\phpOMS\System\File\PathException::class); @@ -67,6 +78,10 @@ class ApplicationManagerTest extends \PHPUnit\Framework\TestCase self::assertFalse($this->appManager->install(__DIR__, __DIR__ . '/newapp')); } + /** + * @covers phpOMS\Application\ApplicationManager + * @group framework + */ public function testInstallFromModules() : void { self::markTestIncomplete(); diff --git a/tests/Auth/OAuth2/Grant/AuthorizationCodeTest.php b/tests/Auth/OAuth2/Grant/AuthorizationCodeTest.php index 623eaf877..c0e0c73cd 100644 --- a/tests/Auth/OAuth2/Grant/AuthorizationCodeTest.php +++ b/tests/Auth/OAuth2/Grant/AuthorizationCodeTest.php @@ -28,6 +28,10 @@ class AuthorizationCodeTest extends \PHPUnit\Framework\TestCase $this->grant = new AuthorizationCode(); } + /** + * @covers phpOMS\Auth\OAuth2\Grant\AuthorizationCode + * @group framework + */ public function testDefault() : void { self::assertEquals('authorization_code', $this->grant->__toString()); @@ -49,6 +53,10 @@ class AuthorizationCodeTest extends \PHPUnit\Framework\TestCase ); } + /** + * @covers phpOMS\Auth\OAuth2\Grant\AuthorizationCode + * @group framework + */ public function testMissingDefaultOption() : void { $this->expectException(\Exception::class); diff --git a/tests/Auth/OAuth2/Grant/ClientCredentialsTest.php b/tests/Auth/OAuth2/Grant/ClientCredentialsTest.php index 577c003b9..04ebebc99 100644 --- a/tests/Auth/OAuth2/Grant/ClientCredentialsTest.php +++ b/tests/Auth/OAuth2/Grant/ClientCredentialsTest.php @@ -28,6 +28,10 @@ class ClientCredentialsTest extends \PHPUnit\Framework\TestCase $this->grant = new ClientCredentials(); } + /** + * @covers phpOMS\Auth\OAuth2\Grant\ClientCredentials + * @group framework + */ public function testDefault() : void { self::assertEquals('client_credentials', $this->grant->__toString()); diff --git a/tests/Auth/OAuth2/Grant/GrantAbstractTest.php b/tests/Auth/OAuth2/Grant/GrantAbstractTest.php index 101c8dac7..be78b1930 100644 --- a/tests/Auth/OAuth2/Grant/GrantAbstractTest.php +++ b/tests/Auth/OAuth2/Grant/GrantAbstractTest.php @@ -38,6 +38,10 @@ class GrantAbstractTest extends \PHPUnit\Framework\TestCase }; } + /** + * @covers phpOMS\Auth\OAuth2\Grant\GrantAbstract + * @group framework + */ public function testDefault() : void { self::assertEquals('TestGrant', $this->grant->__toString()); @@ -58,6 +62,10 @@ class GrantAbstractTest extends \PHPUnit\Framework\TestCase ); } + /** + * @covers phpOMS\Auth\OAuth2\Grant\GrantAbstract + * @group framework + */ public function testMissingDefaultOption() : void { $this->expectException(\Exception::class); diff --git a/tests/Auth/OAuth2/Grant/GrantFactoryTest.php b/tests/Auth/OAuth2/Grant/GrantFactoryTest.php index 86c997bec..5ce2e4a4b 100644 --- a/tests/Auth/OAuth2/Grant/GrantFactoryTest.php +++ b/tests/Auth/OAuth2/Grant/GrantFactoryTest.php @@ -30,12 +30,20 @@ class GrantFactoryTest extends \PHPUnit\Framework\TestCase $this->factory = new GrantFactory(); } + /** + * @covers phpOMS\Auth\OAuth2\Grant\GrantFactory + * @group framework + */ public function testGrantGet() : void { $grant = $this->factory->getGrant('AuthorizationCode'); self::assertInstanceOf(AuthorizationCode::class, $grant); } + /** + * @covers phpOMS\Auth\OAuth2\Grant\GrantFactory + * @group framework + */ public function testGrantInputOutput() : void { $grant = new class() extends GrantAbstract { @@ -54,6 +62,10 @@ class GrantFactoryTest extends \PHPUnit\Framework\TestCase self::assertInstanceOf(\get_class($grant), $this->factory->getGrant('test')); } + /** + * @covers phpOMS\Auth\OAuth2\Grant\GrantFactory + * @group framework + */ public function testInvalidGrantGet() : void { $this->expectException(\Exception::class); diff --git a/tests/Auth/OAuth2/Grant/PasswordTest.php b/tests/Auth/OAuth2/Grant/PasswordTest.php index f863b517d..555a53028 100644 --- a/tests/Auth/OAuth2/Grant/PasswordTest.php +++ b/tests/Auth/OAuth2/Grant/PasswordTest.php @@ -28,6 +28,10 @@ class PasswordTest extends \PHPUnit\Framework\TestCase $this->grant = new Password(); } + /** + * @covers phpOMS\Auth\OAuth2\Grant\Password + * @group framework + */ public function testDefault() : void { self::assertEquals('password', $this->grant->__toString()); @@ -49,6 +53,10 @@ class PasswordTest extends \PHPUnit\Framework\TestCase ); } + /** + * @covers phpOMS\Auth\OAuth2\Grant\Password + * @group framework + */ public function testMissingDefaultOption() : void { $this->expectException(\Exception::class); diff --git a/tests/Auth/OAuth2/Grant/RefreshTokenTest.php b/tests/Auth/OAuth2/Grant/RefreshTokenTest.php index ab216ef6c..aa7b4ca96 100644 --- a/tests/Auth/OAuth2/Grant/RefreshTokenTest.php +++ b/tests/Auth/OAuth2/Grant/RefreshTokenTest.php @@ -28,6 +28,10 @@ class RefreshTokenTest extends \PHPUnit\Framework\TestCase $this->grant = new RefreshToken(); } + /** + * @covers phpOMS\Auth\OAuth2\Grant\RefreshToken + * @group framework + */ public function testDefault() : void { self::assertEquals('refresh_token', $this->grant->__toString()); @@ -49,6 +53,10 @@ class RefreshTokenTest extends \PHPUnit\Framework\TestCase ); } + /** + * @covers phpOMS\Auth\OAuth2\Grant\RefreshToken + * @group framework + */ public function testMissingDefaultOption() : void { $this->expectException(\Exception::class); diff --git a/tests/Auth/OAuth2/OptionProvider/HttpBasicAuthOptionProviderTest.php b/tests/Auth/OAuth2/OptionProvider/HttpBasicAuthOptionProviderTest.php index a81c108be..157a4e61b 100644 --- a/tests/Auth/OAuth2/OptionProvider/HttpBasicAuthOptionProviderTest.php +++ b/tests/Auth/OAuth2/OptionProvider/HttpBasicAuthOptionProviderTest.php @@ -30,6 +30,10 @@ class HttpBasicAuthOptionProviderTest extends \PHPUnit\Framework\TestCase $this->provider = new HttpBasicAuthOptionProvider(); } + /** + * @covers phpOMS\Auth\OAuth2\OptionProvider\HttpBasicAuthOptionProvider + * @group framework + */ public function testDefault() : void { self::assertEquals( @@ -50,6 +54,10 @@ class HttpBasicAuthOptionProviderTest extends \PHPUnit\Framework\TestCase ); } + /** + * @covers phpOMS\Auth\OAuth2\OptionProvider\HttpBasicAuthOptionProvider + * @group framework + */ public function testInvalidParams() : void { self::assertEquals([], diff --git a/tests/Auth/OAuth2/OptionProvider/PostAuthOptionProviderTest.php b/tests/Auth/OAuth2/OptionProvider/PostAuthOptionProviderTest.php index dd1f0688a..a2c416136 100644 --- a/tests/Auth/OAuth2/OptionProvider/PostAuthOptionProviderTest.php +++ b/tests/Auth/OAuth2/OptionProvider/PostAuthOptionProviderTest.php @@ -30,6 +30,10 @@ class PostAuthOptionProviderTest extends \PHPUnit\Framework\TestCase $this->provider = new PostAuthOptionProvider(); } + /** + * @covers phpOMS\Auth\OAuth2\OptionProvider\PostAuthOptionProvider + * @group framework + */ public function testDefault() : void { self::assertEquals( diff --git a/tests/Auth/OAuth2/Token/AccessTokenTest.php b/tests/Auth/OAuth2/Token/AccessTokenTest.php index b188508c5..73a36559d 100644 --- a/tests/Auth/OAuth2/Token/AccessTokenTest.php +++ b/tests/Auth/OAuth2/Token/AccessTokenTest.php @@ -21,6 +21,10 @@ use phpOMS\Auth\OAuth2\Token\AccessToken; */ class AccessTokenTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\Auth\OAuth2\Token\AccessToken + * @group framework + */ public function testDefault() : void { $token = new AccessToken(['access_token' => 'token']); @@ -34,6 +38,10 @@ class AccessTokenTest extends \PHPUnit\Framework\TestCase self::assertEquals(['access_token' => 'token'], $token->jsonSerialize()); } + /** + * @covers phpOMS\Auth\OAuth2\Token\AccessToken + * @group framework + */ public function testExpiresInputOutput() : void { $expires = \time(); @@ -41,6 +49,10 @@ class AccessTokenTest extends \PHPUnit\Framework\TestCase self::assertEquals($expires, $token->getExpires()); } + /** + * @covers phpOMS\Auth\OAuth2\Token\AccessToken + * @group framework + */ public function testExpiresInInputOutput() : void { $expires = \time(); @@ -49,6 +61,10 @@ class AccessTokenTest extends \PHPUnit\Framework\TestCase self::assertTrue($expires < $token->getExpires() && $token->getExpires() < $expires + 20); } + /** + * @covers phpOMS\Auth\OAuth2\Token\AccessToken + * @group framework + */ public function testHasExpired() : void { $token = new AccessToken(['access_token' => 'token', 'expires_in' => -5]); @@ -59,18 +75,30 @@ class AccessTokenTest extends \PHPUnit\Framework\TestCase self::assertTrue($token->hasExpired()); } + /** + * @covers phpOMS\Auth\OAuth2\Token\AccessToken + * @group framework + */ public function testResourceOwnerIdInputOutput() : void { $token = new AccessToken(['access_token' => 'token', 'resource_owner_id' => 'owner']); self::assertEquals('owner', $token->getResourceOwnerId()); } + /** + * @covers phpOMS\Auth\OAuth2\Token\AccessToken + * @group framework + */ public function testRefreshTokenInputOutput() : void { $token = new AccessToken(['access_token' => 'token', 'refresh_token' => 'refresh']); self::assertEquals('refresh', $token->getRefreshToken()); } + /** + * @covers phpOMS\Auth\OAuth2\Token\AccessToken + * @group framework + */ public function testValuesInputOutput() : void { $token = new AccessToken([ @@ -87,6 +115,10 @@ class AccessTokenTest extends \PHPUnit\Framework\TestCase ); } + /** + * @covers phpOMS\Auth\OAuth2\Token\AccessToken + * @group framework + */ public function testJsonSeriaize() : void { $expires = \time() + 10; @@ -111,6 +143,10 @@ class AccessTokenTest extends \PHPUnit\Framework\TestCase ); } + /** + * @covers phpOMS\Auth\OAuth2\Token\AccessToken + * @group framework + */ public function testMissingAccessToken() : void { $this->expectException(\InvalidArgumentException::class); diff --git a/tests/Autoloader.php b/tests/Autoloader.php index cb25f3ceb..65448e07a 100644 --- a/tests/Autoloader.php +++ b/tests/Autoloader.php @@ -42,7 +42,7 @@ class Autoloader $class = \ltrim($class, '\\'); $class = \str_replace(['_', '\\'], '/', $class); - if (!\file_exists($path = __DIR__ . '/../../' . $class . '.php')) { + if (!\is_file($path = __DIR__ . '/../../' . $class . '.php')) { return; } @@ -66,6 +66,6 @@ class Autoloader $class = \ltrim($class, '\\'); $class = \str_replace(['_', '\\'], '/', $class); - return \file_exists(__DIR__ . '/../../' . $class . '.php'); + return \is_file(__DIR__ . '/../../' . $class . '.php'); } } diff --git a/tests/AutoloaderTest.php b/tests/AutoloaderTest.php index 22aa82015..bbe6370a6 100644 --- a/tests/AutoloaderTest.php +++ b/tests/AutoloaderTest.php @@ -34,6 +34,10 @@ class AutoloaderTest extends \PHPUnit\Framework\TestCase self::assertFalse(Autoloader::exists('\Does\Not\Exist')); } + /** + * @covers phpOMS\Autoloader + * @group framework + */ public function testLoading() : void { Autoloader::defaultAutoloader('\phpOMS\tests\TestLoad'); @@ -42,6 +46,10 @@ class AutoloaderTest extends \PHPUnit\Framework\TestCase self::assertTrue(\in_array(\realpath(__DIR__ . '/TestLoad.php'), $includes)); } + /** + * @covers phpOMS\Autoloader + * @group framework + */ public function testManualPathLoading() : void { Autoloader::addPath(__DIR__ . '/../'); @@ -52,6 +60,10 @@ class AutoloaderTest extends \PHPUnit\Framework\TestCase self::assertTrue(\in_array(\realpath(__DIR__ . '/TestLoad2.php'), $includes)); } + /** + * @covers phpOMS\Autoloader + * @group framework + */ public function testOpcodeCacheInvalidation() : void { if (!\extension_loaded('zend opcache') @@ -71,6 +83,10 @@ class AutoloaderTest extends \PHPUnit\Framework\TestCase self::assertTrue(\opcache_is_script_cached(__DIR__ . '/TestLoad3.php')); } + /** + * @covers phpOMS\Autoloader + * @group framework + */ public function testUncachedInvalidation() : void { self::assertFalse(\opcache_is_script_cached(__DIR__ . '/TestLoad4.php')); diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php index 142277b01..acdd66e94 100644 --- a/tests/Bootstrap.php +++ b/tests/Bootstrap.php @@ -5,9 +5,9 @@ \ini_set('display_startup_errors', '1'); \error_reporting(\E_ALL); -if (\file_exists('vendor/autoload.php')) { +if (\is_file('vendor/autoload.php')) { include_once 'vendor/autoload.php'; -} elseif (\file_exists('../../vendor/autoload.php')) { +} elseif (\is_file('../../vendor/autoload.php')) { include_once '../../vendor/autoload.php'; } diff --git a/tests/Business/Finance/FinanceFormulasTest.php b/tests/Business/Finance/FinanceFormulasTest.php index b6fe9af74..221b669e5 100644 --- a/tests/Business/Finance/FinanceFormulasTest.php +++ b/tests/Business/Finance/FinanceFormulasTest.php @@ -25,6 +25,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase { /** * @testdox The annual percentage yield (APY) and reverse value calculations are correct + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testAnnualPercentageYield() : void @@ -41,6 +42,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox The future value of annuity (FVA) and reverse value calculations are correct + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testFutureValueOfAnnuity() : void @@ -59,6 +61,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox The future value of annuity continuous compounding (FVACC) and reverse value calculations are correct + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testFutureValueOfAnnuityContinuousCompounding() : void @@ -77,6 +80,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox The annuity payment from the present value (PV) and reverse value calculations are correct + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testAnnuityPaymentPV() : void @@ -95,6 +99,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox The annuity payment from the future value (FV) and reverse value calculations are correct + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testAnnuityPaymentFV() : void @@ -113,6 +118,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox The annuity payment from the present value (PV) and reverse value calculations are correct + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testAnnutiyPaymentFactorPV() : void @@ -129,6 +135,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox The present value of the annuity is correct + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testPresentValueOfAnnuity() : void @@ -147,6 +154,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox The present value annuity factor of the annuity is correct + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testPresentValueAnnuityFactor() : void @@ -163,6 +171,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox The due present value the annuity is correct + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testPresentValueOfAnnuityDue() : void @@ -182,6 +191,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox The due future value the annuity is correct + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testFutureValueOfAnnuityDue() : void @@ -201,6 +211,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox The relative market share calculations by shares and ales are correct + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testRelativeMarketShare() : void @@ -211,6 +222,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox The asset ratio calculations are correct + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testAssetRatios() : void @@ -221,6 +233,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox Balance ratio calculations for DII, Receivables/Turnover, and more are correct + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testBalanceRatios() : void @@ -233,6 +246,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox Dept ratios for dept coverage, dept to equity and dept to income are correct + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testDeptRatios() : void @@ -245,6 +259,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox Return on balance statement positions are correct (e.g. return on assets, on equity) + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testReturnOnBalancePositions() : void @@ -256,6 +271,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox Balance / P&L ratios are correct (e.g. inventory turnover, net profit margin) + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testBalancePLRatios() : void @@ -265,6 +281,11 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase self::assertEquals(500 / 1000, FinanceFormulas::getReceivablesTurnoverRatio(500, 1000)); } + /** + * @testdox Balance / P&L ratios are correct (e.g. inventory turnover, net profit margin) + * @covers phpOMS\Business\Finance\FinanceFormulas + * @group framework + */ public function testRatios() : void { self::assertEquals(500 / 1000, FinanceFormulas::getInterestCoverageRatio(500, 1000)); @@ -279,6 +300,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox Compound calculations for interest, principal and periods are correct + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testCompound() : void @@ -298,6 +320,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox Continuous compound calculations for interest, principal and periods are correct + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testContinuousCompounding() : void @@ -318,6 +341,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox Calculations for interest, principal and periods are correct + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testSimpleInterest() : void @@ -336,6 +360,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox The discounted payback period is correct + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testDiscountedPaybackPeriod() : void @@ -349,6 +374,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox Test the correct calculation of the growth rate in order to double and vice versa + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testDoublingTime() : void @@ -361,6 +387,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox Test the correct calculation of the growth rate in order to double and vice versa with continuous compounding + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testDoublingTimeContinuousCompounding() : void @@ -373,6 +400,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox Calculations for equivalent annual annuity are correct + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testEquivalentAnnualAnnuity() : void @@ -388,6 +416,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox The free cash flow to equity calculation is correct (how much cash is available after expenses and dept payments) + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testFreeCashFlowToEquity() : void @@ -403,6 +432,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox The free cash flow to firm calculation is correct (how much cash is available after expenses) + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testFreeCashFlowToFirm() : void @@ -418,6 +448,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox The future value calculation is correct + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testFutureValue() : void @@ -431,6 +462,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox The future value calculation including continuous compounding is correct + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testFutureValueContinuousCompounding() : void @@ -444,6 +476,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox The future value factor calculation is correct + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testValueFactor() : void @@ -457,6 +490,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox The calculation of the geometric mean of multiple return rates is correct + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testGeometricMeanReturn() : void @@ -468,6 +502,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox The calculation of the future value of the growing annuity is correct + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testGrowingAnnuityFV() : void @@ -482,6 +517,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox The calculation of the payment based on the present value of the growing annuity is correct + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testGrowingAnnuityPaymentPV() : void @@ -496,6 +532,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox The calculation of the payment based on the future value of the growing annuity is correct + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testGrowingAnnuityPaymentFV() : void @@ -510,6 +547,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox The calculation of the present value of the growing annuity is correct + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testGrowingAnnuityPV() : void @@ -524,6 +562,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox The calculation of the present value of the growing perpetuity is correct + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testGrowingPerpetuityPV() : void @@ -537,6 +576,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox The calculation of the net present value is correct + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testNetPresentValue() : void @@ -549,6 +589,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox No cash flows in the net present value calculation result in 0 + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testEmptyNetPresentValue() : void @@ -558,6 +599,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox The calculation of the real rate of return is correct + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testRealRateOfReturn() : void @@ -570,6 +612,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox The calculation of the net working capital is correct + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testNetWorkingCapital() : void @@ -579,6 +622,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox The periods to reach a future value based on the present value is calculated correctly + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testNumberOfPeriodsPVFV() : void @@ -592,6 +636,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox The calculation of the present value is correct + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testPresentValue() : void @@ -605,6 +650,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase /** * @testdox The calculation of the present value using continuous compounding is correct + * @covers phpOMS\Business\Finance\FinanceFormulas * @group framework */ public function testPresentValueContinuousCompounding() : void diff --git a/tests/DataStorage/Cache/Connection/FileCacheTest.php b/tests/DataStorage/Cache/Connection/FileCacheTest.php index c00fae077..ca9b4ebb4 100644 --- a/tests/DataStorage/Cache/Connection/FileCacheTest.php +++ b/tests/DataStorage/Cache/Connection/FileCacheTest.php @@ -30,7 +30,7 @@ class FileCacheTest extends \PHPUnit\Framework\TestCase protected function setUp() : void { - if (\file_exists(__DIR__ . '/Cache')) { + if (\is_dir(__DIR__ . '/Cache')) { \rmdir(__DIR__ . '/Cache'); } @@ -41,7 +41,7 @@ class FileCacheTest extends \PHPUnit\Framework\TestCase { $this->cache->flushAll(); - if (\file_exists(__DIR__ . '/Cache')) { + if (\is_dir(__DIR__ . '/Cache')) { \rmdir(__DIR__ . '/Cache'); } } diff --git a/tests/DataStorage/Database/Connection/SQLiteConnectionTest.php b/tests/DataStorage/Database/Connection/SQLiteConnectionTest.php index 59eff1bc9..88c251480 100644 --- a/tests/DataStorage/Database/Connection/SQLiteConnectionTest.php +++ b/tests/DataStorage/Database/Connection/SQLiteConnectionTest.php @@ -78,7 +78,7 @@ class SQLiteConnectionTest extends \PHPUnit\Framework\TestCase public static function tearDownAfterClass() : void { - if (\file_exists($GLOBALS['CONFIG']['db']['core']['sqlite']['admin']['database'])) { + if (\is_file($GLOBALS['CONFIG']['db']['core']['sqlite']['admin']['database'])) { \unlink($GLOBALS['CONFIG']['db']['core']['sqlite']['admin']['database']); } } diff --git a/tests/DataStorage/Database/DataMapperAbstractTest.php b/tests/DataStorage/Database/DataMapperAbstractTest.php index a0c345509..34a0d6079 100644 --- a/tests/DataStorage/Database/DataMapperAbstractTest.php +++ b/tests/DataStorage/Database/DataMapperAbstractTest.php @@ -242,6 +242,10 @@ class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase self::assertCount(1, BaseModelMapper::getAll()); } + /** + * @covers phpOMS\DataStorage\Database\DataMapperAbstract + * @group framework + */ public function testFind() : void { $model1 = clone $this->model; @@ -262,6 +266,10 @@ class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase self::assertEquals($model3->string, \end($found)->string); } + /** + * @covers phpOMS\DataStorage\Database\DataMapperAbstract + * @group framework + */ public function testWithConditional() : void { $model1 = clone $this->model; diff --git a/tests/DataStorage/Session/FileSessionHandlerTest.php b/tests/DataStorage/Session/FileSessionHandlerTest.php index bad996100..97cd34da1 100644 --- a/tests/DataStorage/Session/FileSessionHandlerTest.php +++ b/tests/DataStorage/Session/FileSessionHandlerTest.php @@ -28,7 +28,7 @@ class FileSessionHandlerTest extends \PHPUnit\Framework\TestCase protected function setUp() : void { - if (\file_exists(__DIR__ . '/test')) { + if (\is_dir(__DIR__ . '/test')) { Directory::delete(__DIR__ . '/test'); } @@ -37,7 +37,7 @@ class FileSessionHandlerTest extends \PHPUnit\Framework\TestCase protected function tearDown() : void { - if (\file_exists(__DIR__ . '/test')) { + if (\is_dir(__DIR__ . '/test')) { Directory::delete(__DIR__ . '/test'); } } diff --git a/tests/Dispatcher/DispatcherTest.php b/tests/Dispatcher/DispatcherTest.php index e810d633c..de52e7374 100644 --- a/tests/Dispatcher/DispatcherTest.php +++ b/tests/Dispatcher/DispatcherTest.php @@ -172,6 +172,10 @@ class DispatcherTest extends \PHPUnit\Framework\TestCase ); } + /** + * @covers phpOMS\Dispatcher\Dispatcher + * @group framework + */ public function testArrayWithData() : void { $localization = new Localization(); diff --git a/tests/Log/FileLoggerTest.php b/tests/Log/FileLoggerTest.php index 8df223da9..3351da1db 100644 --- a/tests/Log/FileLoggerTest.php +++ b/tests/Log/FileLoggerTest.php @@ -31,11 +31,11 @@ class FileLoggerTest extends \PHPUnit\Framework\TestCase protected function setUp() : void { - if (\file_exists(__DIR__ . '/' . \date('Y-m-d') . '.log')) { + if (\is_file(__DIR__ . '/' . \date('Y-m-d') . '.log')) { \unlink(__DIR__ . '/' . \date('Y-m-d') . '.log'); } - if (\file_exists(__DIR__ . '/test.log')) { + if (\is_file(__DIR__ . '/test.log')) { \unlink(__DIR__ . '/test.log'); } @@ -44,11 +44,11 @@ class FileLoggerTest extends \PHPUnit\Framework\TestCase protected function tearDown() : void { - if (\file_exists(__DIR__ . '/' . \date('Y-m-d') . '.log')) { + if (\is_file(__DIR__ . '/' . \date('Y-m-d') . '.log')) { \unlink(__DIR__ . '/' . \date('Y-m-d') . '.log'); } - if (\file_exists(__DIR__ . '/test.log')) { + if (\is_file(__DIR__ . '/test.log')) { \unlink(__DIR__ . '/test.log'); } } @@ -84,7 +84,7 @@ class FileLoggerTest extends \PHPUnit\Framework\TestCase */ public function testFileLoggerInstance() : void { - if (\file_exists(__DIR__ . '/named.log')) { + if (\is_file(__DIR__ . '/named.log')) { \unlink(__DIR__ . '/named.log'); } @@ -96,7 +96,7 @@ class FileLoggerTest extends \PHPUnit\Framework\TestCase TestUtils::setMember($instance, 'instance', $instance); - if (\file_exists(__DIR__ . '/named.log')) { + if (\is_file(__DIR__ . '/named.log')) { \unlink(__DIR__ . '/named.log'); } } @@ -108,16 +108,16 @@ class FileLoggerTest extends \PHPUnit\Framework\TestCase */ public function testNamedLogFile() : void { - if (\file_exists(__DIR__ . '/named.log')) { + if (\is_file(__DIR__ . '/named.log')) { \unlink(__DIR__ . '/named.log'); } $log = new FileLogger(__DIR__ . '/named.log', false); $log->info('something'); - self::assertTrue(\file_exists(__DIR__ . '/named.log')); + self::assertTrue(\is_file(__DIR__ . '/named.log')); - if (\file_exists(__DIR__ . '/named.log')) { + if (\is_file(__DIR__ . '/named.log')) { \unlink(__DIR__ . '/named.log'); } } @@ -132,7 +132,7 @@ class FileLoggerTest extends \PHPUnit\Framework\TestCase $log = new FileLogger(__DIR__, false); $log->info('something'); - self::assertTrue(\file_exists(__DIR__ . '/' . \date('Y-m-d') . '.log')); + self::assertTrue(\is_file(__DIR__ . '/' . \date('Y-m-d') . '.log')); } /** @@ -144,7 +144,7 @@ class FileLoggerTest extends \PHPUnit\Framework\TestCase { $log = new FileLogger(__DIR__, false); - self::assertFalse(\file_exists(__DIR__ . '/' . \date('Y-m-d') . '.log')); + self::assertFalse(\is_file(__DIR__ . '/' . \date('Y-m-d') . '.log')); } /** diff --git a/tests/Math/Matrix/EigenvalueDecompositionTest.php b/tests/Math/Matrix/EigenvalueDecompositionTest.php index 356fe1fd6..5edb2e429 100644 --- a/tests/Math/Matrix/EigenvalueDecompositionTest.php +++ b/tests/Math/Matrix/EigenvalueDecompositionTest.php @@ -237,6 +237,10 @@ class EigenvalueDecompositionTest extends \PHPUnit\Framework\TestCase ); } + /** + * @covers phpOMS\Math\Matrix\EigenvalueDecomposition + * @group framework + */ public function testComplexEigenvalueDecomposition() : void { $A = new Matrix(); @@ -255,6 +259,10 @@ class EigenvalueDecompositionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta([2, -2], $eig->getImagEigenvalues()->toArray(), 0.1); } + /** + * @covers phpOMS\Math\Matrix\EigenvalueDecomposition + * @group framework + */ public function testComplexDivision() : void { $A = new Matrix(); @@ -275,6 +283,10 @@ class EigenvalueDecompositionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta([4.49865, -4.49865, 0.0], $eig->getImagEigenvalues()->toArray(), 0.1); } + /** + * @covers phpOMS\Math\Matrix\EigenvalueDecomposition + * @group framework + */ public function testComplexDivision2() : void { $A = new Matrix(); @@ -295,6 +307,10 @@ class EigenvalueDecompositionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta([0.0, 4.7940, -4.7940], $eig->getImagEigenvalues()->toArray(), 0.1); } + /** + * @covers phpOMS\Math\Matrix\EigenvalueDecomposition + * @group framework + */ public function testComplexDivision3() : void { $A = new Matrix(); @@ -318,6 +334,10 @@ class EigenvalueDecompositionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta([14.8641, -14.8641, 5.6595, -5.6595], $eig->getImagEigenvalues()->toArray(), 0.1); } + /** + * @covers phpOMS\Math\Matrix\EigenvalueDecomposition + * @group framework + */ public function testComplexDivision4() : void { $A = new Matrix(); diff --git a/tests/Math/Matrix/MatrixTest.php b/tests/Math/Matrix/MatrixTest.php index 8b4911b8b..8cd406c48 100644 --- a/tests/Math/Matrix/MatrixTest.php +++ b/tests/Math/Matrix/MatrixTest.php @@ -261,6 +261,10 @@ class MatrixTest extends \PHPUnit\Framework\TestCase self::assertEquals(2, $B->rank()); } + /** + * @covers phpOMS\Math\Matrix\Matrix + * @group framework + */ public function testInverse() : void { $A = new Matrix(); @@ -294,6 +298,10 @@ class MatrixTest extends \PHPUnit\Framework\TestCase self::assertEquals([[-6, -7], [0, -5]], $this->C->upperTriangular()->getMatrix()); } + /** + * @covers phpOMS\Math\Matrix\Matrix + * @group framework + */ public function testLowerTriangular() : void { self::markTestIncomplete(); diff --git a/tests/Math/Statistic/AverageTest.php b/tests/Math/Statistic/AverageTest.php index b980da1ca..b481ff6ec 100644 --- a/tests/Math/Statistic/AverageTest.php +++ b/tests/Math/Statistic/AverageTest.php @@ -25,6 +25,7 @@ class AverageTest extends \PHPUnit\Framework\TestCase { /** * @testdox The average change of a dataset is correctly calculated + * @covers phpOMS\Math\Statistic\Average * @group framework */ public function testAverage() : void @@ -34,6 +35,7 @@ class AverageTest extends \PHPUnit\Framework\TestCase /** * @testdox The average mean of angles is calculated correctly + * @covers phpOMS\Math\Statistic\Average * @group framework */ public function testAngleMean() : void @@ -49,6 +51,7 @@ class AverageTest extends \PHPUnit\Framework\TestCase /** * @testdox The arithmetic mean is correctly calculated + * @covers phpOMS\Math\Statistic\Average * @group framework */ public function testArithmeticMean() : void @@ -59,6 +62,7 @@ class AverageTest extends \PHPUnit\Framework\TestCase /** * @testdox The weighted mean is correctly calculated + * @covers phpOMS\Math\Statistic\Average * @group framework */ public function testWeightedAverage() : void @@ -71,6 +75,7 @@ class AverageTest extends \PHPUnit\Framework\TestCase /** * @testdox The geometric mean is correctly calculated + * @covers phpOMS\Math\Statistic\Average * @group framework */ public function testGeometricMean() : void @@ -81,6 +86,7 @@ class AverageTest extends \PHPUnit\Framework\TestCase /** * @testdox The harmonic mean is correctly calculated + * @covers phpOMS\Math\Statistic\Average * @group framework */ public function testHarmonicMean() : void @@ -91,6 +97,7 @@ class AverageTest extends \PHPUnit\Framework\TestCase /** * @testdox The moving average is correctly calculated + * @covers phpOMS\Math\Statistic\Average * @group framework */ public function testMovingAverage() : void @@ -109,6 +116,7 @@ class AverageTest extends \PHPUnit\Framework\TestCase /** * @testdox The weighted moving average is correctly calculated + * @covers phpOMS\Math\Statistic\Average * @group framework */ public function testWeightedMovingAverage() : void @@ -122,6 +130,7 @@ class AverageTest extends \PHPUnit\Framework\TestCase /** * @testdox Different weight and dataset dimensions throw a InvalidDimensionException + * @covers phpOMS\Math\Statistic\Average * @group framework */ public function testInvalidWeightedAverageDimension() : void @@ -133,6 +142,7 @@ class AverageTest extends \PHPUnit\Framework\TestCase /** * @testdox An empty dataset for the arithmetic mean throws a ZeroDivisionException + * @covers phpOMS\Math\Statistic\Average * @group framework */ public function testInvalidArithmeticMeanZeroDivision() : void @@ -144,6 +154,7 @@ class AverageTest extends \PHPUnit\Framework\TestCase /** * @testdox An empty dataset for the moving average throws a Exception + * @covers phpOMS\Math\Statistic\Average * @group framework */ public function testInvalidMovingAverageZeroDivision() : void @@ -155,6 +166,7 @@ class AverageTest extends \PHPUnit\Framework\TestCase /** * @testdox An empty dataset for the harmonic mean throws a ZeroDivisionException + * @covers phpOMS\Math\Statistic\Average * @group framework */ public function testInvalidHarmonicMeanZeroDivision() : void @@ -166,6 +178,7 @@ class AverageTest extends \PHPUnit\Framework\TestCase /** * @testdox An empty dataset for the geometric mean throws a ZeroDivisionException + * @covers phpOMS\Math\Statistic\Average * @group framework */ public function testInvalidGeometricMean() : void @@ -175,6 +188,10 @@ class AverageTest extends \PHPUnit\Framework\TestCase Average::geometricMean([]); } + /** + * @covers phpOMS\Math\Statistic\Average + * @group framework + */ public function testInvalidAngleMean() : void { $this->expectException(\phpOMS\Math\Exception\ZeroDivisionException::class); @@ -182,6 +199,10 @@ class AverageTest extends \PHPUnit\Framework\TestCase Average::angleMean([]); } + /** + * @covers phpOMS\Math\Statistic\Average + * @group framework + */ public function testInvalidAngleMean2() : void { $this->expectException(\phpOMS\Math\Exception\ZeroDivisionException::class); @@ -191,6 +212,7 @@ class AverageTest extends \PHPUnit\Framework\TestCase /** * @testdox A dataset with a 0 element throws a ZeroDivisionException + * @covers phpOMS\Math\Statistic\Average * @group framework */ public function testInvalidHarmonicMean() : void @@ -202,6 +224,7 @@ class AverageTest extends \PHPUnit\Framework\TestCase /** * @testdox The mode is correctly calculated + * @covers phpOMS\Math\Statistic\Average * @group framework */ public function testMode() : void @@ -212,6 +235,7 @@ class AverageTest extends \PHPUnit\Framework\TestCase /** * @testdox The median is correctly calculated + * @covers phpOMS\Math\Statistic\Average * @group framework */ public function testMedian() : void diff --git a/tests/Math/Statistic/Forecast/ErrorTest.php b/tests/Math/Statistic/Forecast/ErrorTest.php index ff059adaa..3a5eade13 100644 --- a/tests/Math/Statistic/Forecast/ErrorTest.php +++ b/tests/Math/Statistic/Forecast/ErrorTest.php @@ -23,6 +23,10 @@ use phpOMS\Utils\ArrayUtils; */ class ErrorTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\Math\Statistic\Forecast\Error + * @group framework + */ public function testForecastError() : void { self::assertEquals(1000 - 700, Error::getForecastError(1000, 700)); @@ -42,6 +46,10 @@ class ErrorTest extends \PHPUnit\Framework\TestCase self::assertEquals([Error::getForecastError(1000, 700)], Error::getForecastErrorArray([1000], [700])); } + /** + * @covers phpOMS\Math\Statistic\Forecast\Error + * @group framework + */ public function testErrorPercentage() : void { self::assertEqualsWithDelta(300 / 1000, Error::getPercentageError(300, 1000), 0.01); @@ -62,6 +70,10 @@ class ErrorTest extends \PHPUnit\Framework\TestCase ); } + /** + * @covers phpOMS\Math\Statistic\Forecast\Error + * @group framework + */ public function testMeanErrors() : void { $errors = [ @@ -76,6 +88,10 @@ class ErrorTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(406.2019, Error::getRootMeanSquaredError($errors), 0.01); } + /** + * @covers phpOMS\Math\Statistic\Forecast\Error + * @group framework + */ public function testMASE() : void { $observed = [ @@ -94,6 +110,10 @@ class ErrorTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(0.0983, Error::getMeanAbsoluteScaledError($scaledErrors), 0.01); } + /** + * @covers phpOMS\Math\Statistic\Forecast\Error + * @group framework + */ public function testMSSE() : void { $observed = [ @@ -115,6 +135,10 @@ class ErrorTest extends \PHPUnit\Framework\TestCase ); } + /** + * @covers phpOMS\Math\Statistic\Forecast\Error + * @group framework + */ public function testScaledError() : void { self::assertEquals( @@ -123,6 +147,10 @@ class ErrorTest extends \PHPUnit\Framework\TestCase ); } + /** + * @covers phpOMS\Math\Statistic\Forecast\Error + * @group framework + */ public function testSSE() : void { $errors = MeasureOfDispersion::meanDeviationArray([99.0, 98.6, 98.5, 101.1, 98.3, 98.6, 97.9, 98.4, 99.2, 99.1]); @@ -130,6 +158,10 @@ class ErrorTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(6.921, Error::getSumSquaredError($errors), 0.001); } + /** + * @covers phpOMS\Math\Statistic\Forecast\Error + * @group framework + */ public function testCoefficientOfDetermination() : void { self::assertEqualsWithDelta(0.9729, Error::getCoefficientOfDetermination( @@ -140,6 +172,10 @@ class ErrorTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(0.922085138, Error::getAdjustedCoefficientOfDetermination(0.944346527, 8, 2), 0.001); } + /** + * @covers phpOMS\Math\Statistic\Forecast\Error + * @group framework + */ public function testMAPE() : void { self::assertEqualsWithDelta(0.17551, Error::getMeanAbsolutePercentageError( @@ -148,6 +184,10 @@ class ErrorTest extends \PHPUnit\Framework\TestCase ), 0.001); } + /** + * @covers phpOMS\Math\Statistic\Forecast\Error + * @group framework + */ public function testSMAPE() : void { self::assertEqualsWithDelta(0.049338, Error::getSymmetricMeanAbsolutePercentageError( @@ -156,6 +196,10 @@ class ErrorTest extends \PHPUnit\Framework\TestCase ), 0.001); } + /** + * @covers phpOMS\Math\Statistic\Forecast\Error + * @group framework + */ public function testMAD() : void { self::assertEqualsWithDelta(22.075, Error::getMeanAbsoulteDeviation( diff --git a/tests/Math/Statistic/MeasureOfDispersionTest.php b/tests/Math/Statistic/MeasureOfDispersionTest.php index 311a95d96..d656f28f1 100644 --- a/tests/Math/Statistic/MeasureOfDispersionTest.php +++ b/tests/Math/Statistic/MeasureOfDispersionTest.php @@ -25,6 +25,7 @@ class MeasureOfDispersionTest extends \PHPUnit\Framework\TestCase { /** * @testdox The range of a dataset is correctly calculated + * @covers phpOMS\Math\Statistic\MeasureOfDispersion * @group framework */ public function testRange() : void @@ -34,6 +35,7 @@ class MeasureOfDispersionTest extends \PHPUnit\Framework\TestCase /** * @testdox The standard deviation is correctly calculated + * @covers phpOMS\Math\Statistic\MeasureOfDispersion * @group framework */ public function testStandardDeviationSample() : void @@ -43,6 +45,7 @@ class MeasureOfDispersionTest extends \PHPUnit\Framework\TestCase /** * @testdox The empirical covariance is correctly calculated + * @covers phpOMS\Math\Statistic\MeasureOfDispersion * @group framework */ public function testEmpiricalCovariance() : void @@ -58,6 +61,7 @@ class MeasureOfDispersionTest extends \PHPUnit\Framework\TestCase /** * @testdox The empirical covariance on a sample is correctly calculated + * @covers phpOMS\Math\Statistic\MeasureOfDispersion * @group framework */ public function testSampleCovariance() : void @@ -73,6 +77,7 @@ class MeasureOfDispersionTest extends \PHPUnit\Framework\TestCase /** * @testdox The sample variance is correctly calculated + * @covers phpOMS\Math\Statistic\MeasureOfDispersion * @group framework */ public function testVarianceSample() : void @@ -82,6 +87,7 @@ class MeasureOfDispersionTest extends \PHPUnit\Framework\TestCase /** * @testdox The population/empirical variance is correctly calculated + * @covers phpOMS\Math\Statistic\MeasureOfDispersion * @group framework */ public function testVariancePopulation() : void @@ -91,6 +97,7 @@ class MeasureOfDispersionTest extends \PHPUnit\Framework\TestCase /** * @testdox The mean deviations are correctly calculated + * @covers phpOMS\Math\Statistic\MeasureOfDispersion * @group framework */ public function testDeviation() : void @@ -102,6 +109,7 @@ class MeasureOfDispersionTest extends \PHPUnit\Framework\TestCase /** * @testdox The mean deviations for every dataset element is correctly calculated + * @covers phpOMS\Math\Statistic\MeasureOfDispersion * @group framework */ public function testDeviationArray() : void @@ -127,6 +135,7 @@ class MeasureOfDispersionTest extends \PHPUnit\Framework\TestCase /** * @testdox The empirical variation coefficient is correctly calculated + * @covers phpOMS\Math\Statistic\MeasureOfDispersion * @group framework */ public function testEmpiricalVariationCoefficient() : void @@ -136,6 +145,7 @@ class MeasureOfDispersionTest extends \PHPUnit\Framework\TestCase /** * @testdox The interquartile range is correctly calculated + * @covers phpOMS\Math\Statistic\MeasureOfDispersion * @group framework */ public function testIQR() : void @@ -146,6 +156,7 @@ class MeasureOfDispersionTest extends \PHPUnit\Framework\TestCase /** * @testdox The empirical variation coefficient with a mean of 0 throws a ZeroDivisionException + * @covers phpOMS\Math\Statistic\MeasureOfDispersion * @group framework */ public function testInvalidEmpiricalVariationCoefficient() : void @@ -157,6 +168,7 @@ class MeasureOfDispersionTest extends \PHPUnit\Framework\TestCase /** * @testdox An empty dataset in the empirical covariance throws a ZeroDivisionException + * @covers phpOMS\Math\Statistic\MeasureOfDispersion * @group framework */ public function testInvalidEmpiricalCovariance() : void @@ -168,6 +180,7 @@ class MeasureOfDispersionTest extends \PHPUnit\Framework\TestCase /** * @testdox Different dataset sizes in the empirical covariance throw a InvalidDimensionException + * @covers phpOMS\Math\Statistic\MeasureOfDispersion * @group framework */ public function testInvalidEmpiricalCovarianceDimension() : void @@ -179,6 +192,7 @@ class MeasureOfDispersionTest extends \PHPUnit\Framework\TestCase /** * @testdox An empty dataset in the sample variance throws a ZeroDivisionException + * @covers phpOMS\Math\Statistic\MeasureOfDispersion * @group framework */ public function testInvalidSampleVariance() : void @@ -190,6 +204,7 @@ class MeasureOfDispersionTest extends \PHPUnit\Framework\TestCase /** * @testdox An empty dataset in the empirical/population variance throws a ZeroDivisionException + * @covers phpOMS\Math\Statistic\MeasureOfDispersion * @group framework */ public function testInvalidEmpiricalVariance() : void @@ -199,6 +214,10 @@ class MeasureOfDispersionTest extends \PHPUnit\Framework\TestCase MeasureOfDispersion::empiricalVariance([]); } + /** + * @covers phpOMS\Math\Statistic\MeasureOfDispersion + * @group framework + */ public function testInvalidSampleCovarianceDimension() : void { $this->expectException(\phpOMS\Math\Exception\ZeroDivisionException::class); diff --git a/tests/Math/Stochastic/Distribution/BernoulliDistributionTest.php b/tests/Math/Stochastic/Distribution/BernoulliDistributionTest.php index 59cc57226..a0291bc55 100644 --- a/tests/Math/Stochastic/Distribution/BernoulliDistributionTest.php +++ b/tests/Math/Stochastic/Distribution/BernoulliDistributionTest.php @@ -21,12 +21,20 @@ use phpOMS\Math\Stochastic\Distribution\BernoulliDistribution; */ class BernoulliDistributionTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\Math\Stochastic\Distribution\BernoulliDistribution + * @group framework + */ public function testPmf() : void { self::assertEqualsWithDelta(0.3, BernoulliDistribution::getPmf(0.7, 0), 0.01); self::assertEqualsWithDelta(0.7, BernoulliDistribution::getPmf(0.7, 1), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\BernoulliDistribution + * @group framework + */ public function testMode() : void { self::assertEqualsWithDelta(1, BernoulliDistribution::getMode(0.7), 0.01); @@ -34,11 +42,19 @@ class BernoulliDistributionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(0, BernoulliDistribution::getMode(0.3), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\BernoulliDistribution + * @group framework + */ public function testMean() : void { self::assertEqualsWithDelta(0.4, BernoulliDistribution::getMean(0.4), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\BernoulliDistribution + * @group framework + */ public function testCdf() : void { self::assertEqualsWithDelta(0, BernoulliDistribution::getCdf(0.4, -2), 0.01); @@ -46,6 +62,10 @@ class BernoulliDistributionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(0.3, BernoulliDistribution::getCdf(0.7, 0.4), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\BernoulliDistribution + * @group framework + */ public function testMedian() : void { self::assertEqualsWithDelta(0.5, BernoulliDistribution::getMedian(0.5), 0.01); @@ -53,6 +73,10 @@ class BernoulliDistributionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(0, BernoulliDistribution::getMedian(0.3), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\BernoulliDistribution + * @group framework + */ public function testVariance() : void { $p = 0.3; @@ -61,6 +85,10 @@ class BernoulliDistributionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta($p * $q, BernoulliDistribution::getVariance($p), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\BernoulliDistribution + * @group framework + */ public function testStandardDeviation() : void { $p = 0.3; @@ -69,6 +97,10 @@ class BernoulliDistributionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(\sqrt($p * $q), BernoulliDistribution::getStandardDeviation($p), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\BernoulliDistribution + * @group framework + */ public function testSkewness() : void { $p = 0.3; @@ -77,6 +109,10 @@ class BernoulliDistributionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta((1 - 2 * $p) / \sqrt($p * $q), BernoulliDistribution::getSkewness($p), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\BernoulliDistribution + * @group framework + */ public function testExKurtosis() : void { $p = 0.3; @@ -85,6 +121,10 @@ class BernoulliDistributionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta((1 - 6 * $p * $q) / ($p * $q), BernoulliDistribution::getExKurtosis($p), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\BernoulliDistribution + * @group framework + */ public function testEntropy() : void { $p = 0.3; @@ -93,6 +133,10 @@ class BernoulliDistributionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(-$q * \log($q) - $p * \log($p), BernoulliDistribution::getEntropy($p), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\BernoulliDistribution + * @group framework + */ public function testMgf() : void { $p = 0.3; @@ -102,6 +146,10 @@ class BernoulliDistributionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta($q + $p * \exp($t), BernoulliDistribution::getMgf($p, $t), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\BernoulliDistribution + * @group framework + */ public function testFisherInformation() : void { $p = 0.3; @@ -110,6 +158,10 @@ class BernoulliDistributionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(1 / ($p * $q), BernoulliDistribution::getFisherInformation($p), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\BernoulliDistribution + * @group framework + */ public function testInvalidPmfParameter() : void { $this->expectException(\InvalidArgumentException::class); diff --git a/tests/Math/Stochastic/Distribution/BetaDistributionTest.php b/tests/Math/Stochastic/Distribution/BetaDistributionTest.php index f00ee0098..f0859a161 100644 --- a/tests/Math/Stochastic/Distribution/BetaDistributionTest.php +++ b/tests/Math/Stochastic/Distribution/BetaDistributionTest.php @@ -21,11 +21,19 @@ use phpOMS\Math\Stochastic\Distribution\BetaDistribution; */ class BetaDistributionTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\Math\Stochastic\Distribution\BetaDistribution + * @group framework + */ public function testMean() : void { self::assertEquals(1 / 2, BetaDistribution::getMean(2.0, 2.0)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\BetaDistribution + * @group framework + */ public function testMode() : void { self::assertEquals(1 / 2, BetaDistribution::getMode(2.0, 2.0)); @@ -34,16 +42,28 @@ class BetaDistributionTest extends \PHPUnit\Framework\TestCase self::assertEquals(1.0, BetaDistribution::getMode(1.0, 1.0)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\BetaDistribution + * @group framework + */ public function testVariance() : void { self::assertEqualsWithDelta(1 / 20, BetaDistribution::getVariance(2.0, 2.0), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\BetaDistribution + * @group framework + */ public function testStandardDeviation() : void { self::assertEqualsWithDelta(\sqrt(1 / 20), BetaDistribution::getStandardDeviation(2.0, 2.0), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\BetaDistribution + * @group framework + */ public function testSkewness() : void { self::assertEqualsWithDelta(0, BetaDistribution::getSkewness(2.0, 2.0), 0.001); @@ -51,21 +71,37 @@ class BetaDistributionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(-0.565685, BetaDistribution::getSkewness(2.0, 1.0), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\BetaDistribution + * @group framework + */ public function testExKurtosis() : void { self::assertEqualsWithDelta(-6 / 7, BetaDistribution::getExKurtosis(2.0, 2.0), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\BetaDistribution + * @group framework + */ public function testPdf() : void { self::assertEqualsWithDelta(0.9375, BetaDistribution::getPdf(0.5, 2, 5), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\BetaDistribution + * @group framework + */ public function testCdf() : void { self::assertEqualsWithDelta(0.890625, BetaDistribution::getCdf(0.5, 2, 5), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\BetaDistribution + * @group framework + */ public function testMgf() : void { self::assertEqualsWithDelta(1.0, BetaDistribution::getMgf(0, 2, 5), 0.001); diff --git a/tests/Math/Stochastic/Distribution/BinomialDistributionTest.php b/tests/Math/Stochastic/Distribution/BinomialDistributionTest.php index a60629372..7ae9ad9e5 100644 --- a/tests/Math/Stochastic/Distribution/BinomialDistributionTest.php +++ b/tests/Math/Stochastic/Distribution/BinomialDistributionTest.php @@ -21,6 +21,10 @@ use phpOMS\Math\Stochastic\Distribution\BinomialDistribution; */ class BinomialDistributionTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\Math\Stochastic\Distribution\BinomialDistribution + * @group framework + */ public function testPmf() : void { $p = 0.4; @@ -30,6 +34,10 @@ class BinomialDistributionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(0.1659, BinomialDistribution::getPmf($n, $k, $p), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\BinomialDistribution + * @group framework + */ public function testCdf() : void { $p = 0.4; @@ -39,6 +47,10 @@ class BinomialDistributionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(0.25, BinomialDistribution::getCdf($n, $k, $p), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\BinomialDistribution + * @group framework + */ public function testMean() : void { $n = 20; @@ -47,6 +59,10 @@ class BinomialDistributionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta($n * $p, BinomialDistribution::getMean($n, $p), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\BinomialDistribution + * @group framework + */ public function testMedian() : void { $n = 20; @@ -55,6 +71,10 @@ class BinomialDistributionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(\floor($n * $p), BinomialDistribution::getMedian($n, $p), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\BinomialDistribution + * @group framework + */ public function testMode() : void { $n = 20; @@ -63,6 +83,10 @@ class BinomialDistributionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(\floor(($n + 1) * $p), BinomialDistribution::getMode($n, $p), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\BinomialDistribution + * @group framework + */ public function testVariance() : void { $n = 20; @@ -71,6 +95,10 @@ class BinomialDistributionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta($n * $p * (1 - $p), BinomialDistribution::getVariance($n, $p), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\BinomialDistribution + * @group framework + */ public function testStandardDeviation() : void { $n = 20; @@ -79,6 +107,10 @@ class BinomialDistributionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(\sqrt($n * $p * (1 - $p)), BinomialDistribution::getStandardDeviation($n, $p), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\BinomialDistribution + * @group framework + */ public function testSkewness() : void { $n = 20; @@ -87,6 +119,10 @@ class BinomialDistributionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta((1 - 2 * $p) / \sqrt($n * $p * (1 - $p)), BinomialDistribution::getSkewness($n, $p), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\BinomialDistribution + * @group framework + */ public function testExKurtosis() : void { $n = 20; @@ -95,6 +131,10 @@ class BinomialDistributionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta((1 - 6 * $p * (1 - $p)) / ($n * $p * (1 - $p)), BinomialDistribution::getExKurtosis($n, $p), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\BinomialDistribution + * @group framework + */ public function testMgf() : void { $n = 20; @@ -104,6 +144,10 @@ class BinomialDistributionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta((1 - $p + $p * \exp($t)) ** $n, BinomialDistribution::getMgf($n, $t, $p), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\BinomialDistribution + * @group framework + */ public function testFisherInformation() : void { $n = 20; diff --git a/tests/Math/Stochastic/Distribution/CauchyDistributionTest.php b/tests/Math/Stochastic/Distribution/CauchyDistributionTest.php index 25ee8abaf..a8467bffc 100644 --- a/tests/Math/Stochastic/Distribution/CauchyDistributionTest.php +++ b/tests/Math/Stochastic/Distribution/CauchyDistributionTest.php @@ -21,12 +21,20 @@ use phpOMS\Math\Stochastic\Distribution\CauchyDistribution; */ class CauchyDistributionTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\Math\Stochastic\Distribution\CauchyDistribution + * @group framework + */ public function testMedianMode() : void { self::assertEquals(3.2, CauchyDistribution::getMedian(3.2)); self::assertEquals(3.2, CauchyDistribution::getMode(3.2)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\CauchyDistribution + * @group framework + */ public function testPdf() : void { $x = 1; @@ -36,6 +44,10 @@ class CauchyDistributionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(0.14979, CauchyDistribution::getPdf($x, $x0, $gamma), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\CauchyDistribution + * @group framework + */ public function testCdf() : void { $x = 1; @@ -45,6 +57,10 @@ class CauchyDistributionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(0.57798, CauchyDistribution::getCdf($x, $x0, $gamma), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\CauchyDistribution + * @group framework + */ public function testEntropy() : void { $gamma = 1.5; diff --git a/tests/Math/Stochastic/Distribution/ChiSquaredDistributionTest.php b/tests/Math/Stochastic/Distribution/ChiSquaredDistributionTest.php index 1c03995a8..c24e02b14 100644 --- a/tests/Math/Stochastic/Distribution/ChiSquaredDistributionTest.php +++ b/tests/Math/Stochastic/Distribution/ChiSquaredDistributionTest.php @@ -21,6 +21,10 @@ use phpOMS\Math\Stochastic\Distribution\ChiSquaredDistribution; */ class ChiSquaredDistributionTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\Math\Stochastic\Distribution\ChiSquaredDistribution + * @group framework + */ public function testHypothesisFalse() : void { $p = [0.6, 0.25, 0.15]; @@ -38,6 +42,10 @@ class ChiSquaredDistributionTest extends \PHPUnit\Framework\TestCase self::assertEquals(2, $test['df']); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\ChiSquaredDistribution + * @group framework + */ public function testDegreesOfFreedom() : void { self::assertEquals(2, ChiSquaredDistribution::getDegreesOfFreedom([1, 2, 3])); @@ -48,11 +56,19 @@ class ChiSquaredDistributionTest extends \PHPUnit\Framework\TestCase ])); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\ChiSquaredDistribution + * @group framework + */ public function testMode() : void { self::assertEquals(\max(5 - 2, 0), ChiSquaredDistribution::getMode(5)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\ChiSquaredDistribution + * @group framework + */ public function testMean() : void { $df = 5; @@ -60,6 +76,10 @@ class ChiSquaredDistributionTest extends \PHPUnit\Framework\TestCase self::assertEquals($df, ChiSquaredDistribution::getMean($df)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\ChiSquaredDistribution + * @group framework + */ public function testVariance() : void { $df = 5; @@ -67,6 +87,10 @@ class ChiSquaredDistributionTest extends \PHPUnit\Framework\TestCase self::assertEquals(2 * $df, ChiSquaredDistribution::getVariance($df)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\ChiSquaredDistribution + * @group framework + */ public function testStandardDeviation() : void { $df = 5; @@ -74,6 +98,10 @@ class ChiSquaredDistributionTest extends \PHPUnit\Framework\TestCase self::assertEquals(\sqrt(2 * $df), ChiSquaredDistribution::getStandardDeviation($df)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\ChiSquaredDistribution + * @group framework + */ public function testMedian() : void { $df = 5; @@ -81,6 +109,10 @@ class ChiSquaredDistributionTest extends \PHPUnit\Framework\TestCase self::assertEquals($df * (1 - 2 / (9 * $df)) ** 3, ChiSquaredDistribution::getMedian($df)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\ChiSquaredDistribution + * @group framework + */ public function testSkewness() : void { $df = 5; @@ -88,6 +120,10 @@ class ChiSquaredDistributionTest extends \PHPUnit\Framework\TestCase self::assertEquals(\sqrt(8 / $df), ChiSquaredDistribution::getSkewness($df)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\ChiSquaredDistribution + * @group framework + */ public function testExKurtosis() : void { $df = 5; @@ -95,6 +131,10 @@ class ChiSquaredDistributionTest extends \PHPUnit\Framework\TestCase self::assertEquals(12 / $df, ChiSquaredDistribution::getExKurtosis($df)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\ChiSquaredDistribution + * @group framework + */ public function testMgdf() : void { $df = 5; @@ -103,16 +143,28 @@ class ChiSquaredDistributionTest extends \PHPUnit\Framework\TestCase self::assertEquals((1 - 2 * $t) ** (-$df / 2), ChiSquaredDistribution::getMgf($df, $t)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\ChiSquaredDistribution + * @group framework + */ public function testPdf() : void { self::assertEqualsWithDelta(0.20755, ChiSquaredDistribution::getPdf(2, 3), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\ChiSquaredDistribution + * @group framework + */ public function testCdf() : void { self::assertEqualsWithDelta(0.42759, ChiSquaredDistribution::getCdf(2, 3), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\ChiSquaredDistribution + * @group framework + */ public function testHypothesisSizeException() : void { $this->expectException(\Exception::class); @@ -120,6 +172,10 @@ class ChiSquaredDistributionTest extends \PHPUnit\Framework\TestCase ChiSquaredDistribution::testHypothesis([1, 2], [2]); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\ChiSquaredDistribution + * @group framework + */ public function testHypothesisDegreesOfFreedomException() : void { $this->expectException(\Exception::class); @@ -127,6 +183,10 @@ class ChiSquaredDistributionTest extends \PHPUnit\Framework\TestCase ChiSquaredDistribution::testHypothesis([], []); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\ChiSquaredDistribution + * @group framework + */ public function testPdfOutOfBoundsException() : void { $this->expectException(\OutOfBoundsException::class); @@ -134,6 +194,10 @@ class ChiSquaredDistributionTest extends \PHPUnit\Framework\TestCase ChiSquaredDistribution::getPdf(-1, 0); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\ChiSquaredDistribution + * @group framework + */ public function testMgfOutOfBoundsException() : void { $this->expectException(\OutOfBoundsException::class); diff --git a/tests/Math/Stochastic/Distribution/ExponentialDistributionTest.php b/tests/Math/Stochastic/Distribution/ExponentialDistributionTest.php index 905e0d534..2295c6824 100644 --- a/tests/Math/Stochastic/Distribution/ExponentialDistributionTest.php +++ b/tests/Math/Stochastic/Distribution/ExponentialDistributionTest.php @@ -21,6 +21,10 @@ use phpOMS\Math\Stochastic\Distribution\ExponentialDistribution; */ class ExponentialDistributionTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\Math\Stochastic\Distribution\ExponentialDistribution + * @group framework + */ public function testPdf() : void { $lambda = 0.1; @@ -29,6 +33,10 @@ class ExponentialDistributionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(0.049659, ExponentialDistribution::getPdf($x, $lambda), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\ExponentialDistribution + * @group framework + */ public function testCdf() : void { $lambda = 0.1; @@ -37,21 +45,37 @@ class ExponentialDistributionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(0.5034, ExponentialDistribution::getCdf($x, $lambda), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\ExponentialDistribution + * @group framework + */ public function testMean() : void { self::assertEquals(1 / 3, ExponentialDistribution::getMean(3)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\ExponentialDistribution + * @group framework + */ public function testMode() : void { self::assertEquals(0, ExponentialDistribution::getMode()); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\ExponentialDistribution + * @group framework + */ public function testMedian() : void { self::assertEquals(1 / 3 * \log(2), ExponentialDistribution::getMedian(3)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\ExponentialDistribution + * @group framework + */ public function testMgf() : void { $lambda = 3; @@ -60,26 +84,46 @@ class ExponentialDistributionTest extends \PHPUnit\Framework\TestCase self::assertEquals($lambda / ($lambda - $t), ExponentialDistribution::getMgf($t, $lambda)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\ExponentialDistribution + * @group framework + */ public function testVariance() : void { self::assertEquals(1 / (3 ** 2), ExponentialDistribution::getVariance(3)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\ExponentialDistribution + * @group framework + */ public function testStandardDeviation() : void { self::assertEquals(\sqrt(1 / (3 ** 2)), ExponentialDistribution::getStandardDeviation(3)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\ExponentialDistribution + * @group framework + */ public function testExKurtosis() : void { self::assertEquals(6, ExponentialDistribution::getExKurtosis()); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\ExponentialDistribution + * @group framework + */ public function testSkewness() : void { self::assertEquals(2, ExponentialDistribution::getSkewness()); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\ExponentialDistribution + * @group framework + */ public function testMgfException() : void { $this->expectException(\OutOfBoundsException::class); diff --git a/tests/Math/Stochastic/Distribution/FDistributionTest.php b/tests/Math/Stochastic/Distribution/FDistributionTest.php index 37a6a82b1..dc8fda989 100644 --- a/tests/Math/Stochastic/Distribution/FDistributionTest.php +++ b/tests/Math/Stochastic/Distribution/FDistributionTest.php @@ -21,12 +21,20 @@ use phpOMS\Math\Stochastic\Distribution\FDistribution; */ class FDistributionTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\Math\Stochastic\Distribution\FDistribution + * @group framework + */ public function testMean() : void { self::assertEquals(0.0, FDistribution::getMean(2)); self::assertEquals(2, FDistribution::getMean(4)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\FDistribution + * @group framework + */ public function testMode() : void { self::assertEquals(0.0, FDistribution::getMode(0, 0)); @@ -34,6 +42,10 @@ class FDistributionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(1 / 3 * 2 / 3, FDistribution::getMode(3, 4), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\FDistribution + * @group framework + */ public function testVariance() : void { self::assertEquals(0.0, FDistribution::getVariance(1, 2)); @@ -41,6 +53,10 @@ class FDistributionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(11.1111, FDistribution::getVariance(3, 5), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\FDistribution + * @group framework + */ public function testStandardDeviation() : void { self::assertEquals(0.0, FDistribution::getStandardDeviation(1, 2)); @@ -48,17 +64,29 @@ class FDistributionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(\sqrt(11.1111), FDistribution::getStandardDeviation(3, 5), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\FDistribution + * @group framework + */ public function testSkewness() : void { self::assertEquals(0.0, FDistribution::getSkewness(1, 6)); self::assertEquals(2 * (2 * 4 + 7 - 2) / (7 - 6) * \sqrt(2 * (7 - 4) / (4 * (7 + 4 - 2))), FDistribution::getSkewness(4, 7)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\FDistribution + * @group framework + */ public function testPdf() : void { self::assertEqualsWithDelta(0.2788548, FDistribution::getPdf(1, 2, 3), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\FDistribution + * @group framework + */ public function testCdf() : void { self::assertEqualsWithDelta(0.5352419, FDistribution::getCdf(1, 2, 3), 0.001); diff --git a/tests/Math/Stochastic/Distribution/GammaDistributionTest.php b/tests/Math/Stochastic/Distribution/GammaDistributionTest.php index 97188fa97..d956bf3f2 100644 --- a/tests/Math/Stochastic/Distribution/GammaDistributionTest.php +++ b/tests/Math/Stochastic/Distribution/GammaDistributionTest.php @@ -21,42 +21,74 @@ use phpOMS\Math\Stochastic\Distribution\GammaDistribution; */ class GammaDistributionTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\Math\Stochastic\Distribution\GammaDistribution + * @group framework + */ public function testPdfScale() : void { self::assertEqualsWithDelta(0.0734, GammaDistribution::getPdfScale(10, 4, 3), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\GammaDistribution + * @group framework + */ public function testPdfAlphaBete() : void { self::assertEqualsWithDelta(0.180447, GammaDistribution::getPdfRate(2, 4, 1), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\GammaDistribution + * @group framework + */ public function testCdfScale() : void { self::assertEqualsWithDelta(0.42701, GammaDistribution::getCdfScale(10, 4, 3), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\GammaDistribution + * @group framework + */ public function testCdfAlphaBete() : void { self::assertEqualsWithDelta(0.142876, GammaDistribution::getCdfRate(2, 4, 1), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\GammaDistribution + * @group framework + */ public function testPdfIntegerScale() : void { self::assertEqualsWithDelta(\exp(-1), GammaDistribution::getPdfIntegerScale(1, 1, 1), 0.001); self::assertEqualsWithDelta(3 * \exp(-3 / 4) / 16, GammaDistribution::getPdfIntegerScale(3, 2, 4), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\GammaDistribution + * @group framework + */ public function testPdfIntegerRate() : void { self::assertEqualsWithDelta(0.180447, GammaDistribution::getPdfIntegerRate(2, 4, 1), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\GammaDistribution + * @group framework + */ public function testMeanScale() : void { self::assertEqualsWithDelta(8, GammaDistribution::getMeanScale(2, 4), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\GammaDistribution + * @group framework + */ public function testMeanRate() : void { $alpha = 4; @@ -64,11 +96,19 @@ class GammaDistributionTest extends \PHPUnit\Framework\TestCase self::assertEquals($alpha / $beta, GammaDistribution::getMeanRate($alpha, $beta)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\GammaDistribution + * @group framework + */ public function testVarianceScale() : void { self::assertEqualsWithDelta(32, GammaDistribution::getVarianceScale(2, 4), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\GammaDistribution + * @group framework + */ public function testVarianceRate() : void { $alpha = 4; @@ -76,11 +116,19 @@ class GammaDistributionTest extends \PHPUnit\Framework\TestCase self::assertEquals($alpha / \pow($beta, 2), GammaDistribution::getVarianceRate($alpha, $beta)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\GammaDistribution + * @group framework + */ public function testStandardDeviationScale() : void { self::assertEqualsWithDelta(\sqrt(32), GammaDistribution::getStandardDeviationScale(2, 4), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\GammaDistribution + * @group framework + */ public function testStandardDeviationRate() : void { $alpha = 4; @@ -88,16 +136,28 @@ class GammaDistributionTest extends \PHPUnit\Framework\TestCase self::assertEquals(\sqrt($alpha / \pow($beta, 2)), GammaDistribution::getStandardDeviationRate($alpha, $beta)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\GammaDistribution + * @group framework + */ public function testExKurtosis() : void { self::assertEqualsWithDelta(3, GammaDistribution::getExKurtosis(2, 4), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\GammaDistribution + * @group framework + */ public function testSkewness() : void { self::assertEqualsWithDelta(\sqrt(2), GammaDistribution::getSkewness(2, 4), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\GammaDistribution + * @group framework + */ public function testMgfScale() : void { $theta = 2; @@ -106,6 +166,10 @@ class GammaDistributionTest extends \PHPUnit\Framework\TestCase self::assertEquals(\pow(1 - $theta * $t, -$k), GammaDistribution::getMgfScale($k, $t, $theta)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\GammaDistribution + * @group framework + */ public function testMgfRate() : void { $alpha = 4; @@ -114,11 +178,19 @@ class GammaDistributionTest extends \PHPUnit\Framework\TestCase self::assertEquals(\pow(1 - $t / $beta, -$alpha), GammaDistribution::getMgfRate($t, $alpha, $beta)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\GammaDistribution + * @group framework + */ public function testModeScale() : void { self::assertEquals((3 - 1) * 2, GammaDistribution::getModeScale(3, 2)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\GammaDistribution + * @group framework + */ public function testModeRate() : void { self::assertEquals((3 - 1) / 2, GammaDistribution::getModeRate(3, 2)); diff --git a/tests/Math/Stochastic/Distribution/GeometricDistributionTest.php b/tests/Math/Stochastic/Distribution/GeometricDistributionTest.php index 0fb0f2aa6..1c7aca9d0 100644 --- a/tests/Math/Stochastic/Distribution/GeometricDistributionTest.php +++ b/tests/Math/Stochastic/Distribution/GeometricDistributionTest.php @@ -21,6 +21,10 @@ use phpOMS\Math\Stochastic\Distribution\GeometricDistribution; */ class GeometricDistributionTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\Math\Stochastic\Distribution\GeometricDistribution + * @group framework + */ public function testPmf() : void { $p = 0.2; @@ -29,6 +33,10 @@ class GeometricDistributionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(0.1024, GeometricDistribution::getPmf($p, $k), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\GeometricDistribution + * @group framework + */ public function testCdf() : void { $p = 0.2; @@ -38,17 +46,29 @@ class GeometricDistributionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(0.262, 1 - GeometricDistribution::getCdf($p, $k), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\GeometricDistribution + * @group framework + */ public function testMode() : void { self::assertEquals(1, GeometricDistribution::getMode()); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\GeometricDistribution + * @group framework + */ public function testMean() : void { $p = 0.3; self::assertEquals(1 / $p, GeometricDistribution::getMean($p)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\GeometricDistribution + * @group framework + */ public function testVariance() : void { $p = 0.3; @@ -56,6 +76,10 @@ class GeometricDistributionTest extends \PHPUnit\Framework\TestCase self::assertEquals((1 - $p) / $p ** 2, GeometricDistribution::getVariance($p)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\GeometricDistribution + * @group framework + */ public function testgetStandardDeviation() : void { $p = 0.3; @@ -63,6 +87,10 @@ class GeometricDistributionTest extends \PHPUnit\Framework\TestCase self::assertEquals(\sqrt((1 - $p) / $p ** 2), GeometricDistribution::getStandardDeviation($p)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\GeometricDistribution + * @group framework + */ public function testSkewness() : void { $p = 0.3; @@ -70,6 +98,10 @@ class GeometricDistributionTest extends \PHPUnit\Framework\TestCase self::assertEquals((2 - $p) / \sqrt(1 - $p), GeometricDistribution::getSkewness($p)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\GeometricDistribution + * @group framework + */ public function testExKurtosis() : void { $p = 0.3; @@ -77,6 +109,10 @@ class GeometricDistributionTest extends \PHPUnit\Framework\TestCase self::assertEquals(6 + ($p ** 2) / (1 - $p), GeometricDistribution::getExKurtosis($p)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\GeometricDistribution + * @group framework + */ public function testMedian() : void { $p = 0.3; @@ -84,6 +120,10 @@ class GeometricDistributionTest extends \PHPUnit\Framework\TestCase self::assertEquals(\ceil(-1 / \log(1 - $p, 2)), GeometricDistribution::getMedian($p)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\GeometricDistribution + * @group framework + */ public function testMgf() : void { $p = 0.3; diff --git a/tests/Math/Stochastic/Distribution/HypergeometricDistributionTest.php b/tests/Math/Stochastic/Distribution/HypergeometricDistributionTest.php index ac7c7dced..93b591b81 100644 --- a/tests/Math/Stochastic/Distribution/HypergeometricDistributionTest.php +++ b/tests/Math/Stochastic/Distribution/HypergeometricDistributionTest.php @@ -21,31 +21,55 @@ use phpOMS\Math\Stochastic\Distribution\HypergeometricDistribution; */ class HypergeometricDistributionTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\Math\Stochastic\Distribution\HypergeometricDistribution + * @group framework + */ public function testMean() : void { self::assertEquals(9, HypergeometricDistribution::getMean(15, 20, 12)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\HypergeometricDistribution + * @group framework + */ public function testVariance() : void { self::assertEqualsWithDelta(0.973328526784575 ** 2, HypergeometricDistribution::getVariance(15, 20, 12), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\HypergeometricDistribution + * @group framework + */ public function testStandardDeviation() : void { self::assertEqualsWithDelta(0.973328526784575, HypergeometricDistribution::getStandardDeviation(15, 20, 12), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\HypergeometricDistribution + * @group framework + */ public function testSkewness() : void { self::assertEqualsWithDelta(0.114156, HypergeometricDistribution::getSkewness(15, 20, 12), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\HypergeometricDistribution + * @group framework + */ public function testExKurtosis() : void { self::assertEqualsWithDelta(-0.247277, HypergeometricDistribution::getExKurtosis(15, 20, 12), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\HypergeometricDistribution + * @group framework + */ public function testMode() : void { $N = 8; @@ -55,11 +79,19 @@ class HypergeometricDistributionTest extends \PHPUnit\Framework\TestCase self::assertEquals(3, HypergeometricDistribution::getMode($K, $N, $n)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\HypergeometricDistribution + * @group framework + */ public function testPmf() : void { self::assertEqualsWithDelta(0.146284, HypergeometricDistribution::getPmf(7, 20, 5, 10), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\HypergeometricDistribution + * @group framework + */ public function testCdf() : void { self::assertEqualsWithDelta(0.97136, HypergeometricDistribution::getCdf(7, 20, 5, 10), 0.001); diff --git a/tests/Math/Stochastic/Distribution/LaplaceDistributionTest.php b/tests/Math/Stochastic/Distribution/LaplaceDistributionTest.php index 23c3421c8..ecd3735d5 100644 --- a/tests/Math/Stochastic/Distribution/LaplaceDistributionTest.php +++ b/tests/Math/Stochastic/Distribution/LaplaceDistributionTest.php @@ -21,6 +21,10 @@ use phpOMS\Math\Stochastic\Distribution\LaplaceDistribution; */ class LaplaceDistributionTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\Math\Stochastic\Distribution\LaplaceDistribution + * @group framework + */ public function testPdf() : void { $x = 2; @@ -30,6 +34,10 @@ class LaplaceDistributionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(0.17118, LaplaceDistribution::getPdf($x, $m, $b), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\LaplaceDistribution + * @group framework + */ public function testCdf() : void { $x = 2; @@ -39,31 +47,55 @@ class LaplaceDistributionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(0.88017, LaplaceDistribution::getCdf($x, $m, $b), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\LaplaceDistribution + * @group framework + */ public function testMode() : void { self::assertEquals(2, LaplaceDistribution::getMode(2)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\LaplaceDistribution + * @group framework + */ public function testMean() : void { self::assertEquals(2, LaplaceDistribution::getMean(2)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\LaplaceDistribution + * @group framework + */ public function testMedian() : void { self::assertEquals(2, LaplaceDistribution::getMedian(2)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\LaplaceDistribution + * @group framework + */ public function testExKurtosis() : void { self::assertEquals(3, LaplaceDistribution::getExKurtosis()); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\LaplaceDistribution + * @group framework + */ public function testSkewness() : void { self::assertEquals(0, LaplaceDistribution::getSkewness()); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\LaplaceDistribution + * @group framework + */ public function testVariance() : void { $b = 3; @@ -71,6 +103,10 @@ class LaplaceDistributionTest extends \PHPUnit\Framework\TestCase self::assertEquals(2 * $b ** 2, LaplaceDistribution::getVariance($b)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\LaplaceDistribution + * @group framework + */ public function testStandardDeviation() : void { $b = 3; @@ -78,6 +114,10 @@ class LaplaceDistributionTest extends \PHPUnit\Framework\TestCase self::assertEquals(\sqrt(2 * $b ** 2), LaplaceDistribution::getStandardDeviation($b)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\LaplaceDistribution + * @group framework + */ public function testMgf() : void { $t = 2; @@ -87,6 +127,10 @@ class LaplaceDistributionTest extends \PHPUnit\Framework\TestCase self::assertEquals(\exp($m * $t) / (1 - $b ** 2 * $t ** 2), LaplaceDistribution::getMgf($t, $m, $b)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\LaplaceDistribution + * @group framework + */ public function testMgfException() : void { $this->expectException(\OutOfBoundsException::class); diff --git a/tests/Math/Stochastic/Distribution/LogDistributionTest.php b/tests/Math/Stochastic/Distribution/LogDistributionTest.php index d98d90443..85dbcd9ce 100644 --- a/tests/Math/Stochastic/Distribution/LogDistributionTest.php +++ b/tests/Math/Stochastic/Distribution/LogDistributionTest.php @@ -21,6 +21,10 @@ use phpOMS\Math\Stochastic\Distribution\LogDistribution; */ class LogDistributionTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\Math\Stochastic\Distribution\LogDistribution + * @group framework + */ public function testPmf() : void { $p = 0.3; @@ -32,6 +36,10 @@ class LogDistributionTest extends \PHPUnit\Framework\TestCase ); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\LogDistribution + * @group framework + */ public function testCdf() : void { $p = 6 / 9; @@ -43,6 +51,10 @@ class LogDistributionTest extends \PHPUnit\Framework\TestCase ); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\LogDistribution + * @group framework + */ public function testMean() : void { $p = 0.3; @@ -50,11 +62,19 @@ class LogDistributionTest extends \PHPUnit\Framework\TestCase self::assertEquals(-1 / \log(1 - $p) * $p / (1 - $p), LogDistribution::getMean($p)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\LogDistribution + * @group framework + */ public function testMode() : void { self::assertEquals(1, LogDistribution::getMode()); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\LogDistribution + * @group framework + */ public function testVariance() : void { $p = 0.3; @@ -65,6 +85,10 @@ class LogDistributionTest extends \PHPUnit\Framework\TestCase ); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\LogDistribution + * @group framework + */ public function testStandardDeviation() : void { $p = 0.3; @@ -75,6 +99,10 @@ class LogDistributionTest extends \PHPUnit\Framework\TestCase ); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\LogDistribution + * @group framework + */ public function testMgf() : void { $p = 0.3; diff --git a/tests/Math/Stochastic/Distribution/LogNormalDistributionTest.php b/tests/Math/Stochastic/Distribution/LogNormalDistributionTest.php index 978bc3520..ea38abe7c 100644 --- a/tests/Math/Stochastic/Distribution/LogNormalDistributionTest.php +++ b/tests/Math/Stochastic/Distribution/LogNormalDistributionTest.php @@ -21,21 +21,37 @@ use phpOMS\Math\Stochastic\Distribution\LogNormalDistribution; */ class LogNormalDistributionTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\Math\Stochastic\Distribution\LogNormalDistribution + * @group framework + */ public function testPdf() : void { self::assertEqualsWithDelta(0.060069054, LogNormalDistribution::getPdf(3, 2, 2), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\LogNormalDistribution + * @group framework + */ public function testCdf() : void { self::assertEqualsWithDelta(0.32610510, LogNormalDistribution::getCdf(3, 2, 2), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\LogNormalDistribution + * @group framework + */ public function testMean() : void { self::assertEqualsWithDelta(\exp(13 / 2), LogNormalDistribution::getMean(2, 3), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\LogNormalDistribution + * @group framework + */ public function testVariance() : void { self::assertEqualsWithDelta( @@ -44,6 +60,10 @@ class LogNormalDistributionTest extends \PHPUnit\Framework\TestCase ); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\LogNormalDistribution + * @group framework + */ public function testStandardDeviation() : void { self::assertEqualsWithDelta( @@ -57,6 +77,10 @@ class LogNormalDistributionTest extends \PHPUnit\Framework\TestCase ); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\LogNormalDistribution + * @group framework + */ public function testSkewness() : void { self::assertEqualsWithDelta( @@ -65,6 +89,10 @@ class LogNormalDistributionTest extends \PHPUnit\Framework\TestCase ); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\LogNormalDistribution + * @group framework + */ public function testExKurtosis() : void { self::assertEqualsWithDelta( @@ -73,16 +101,28 @@ class LogNormalDistributionTest extends \PHPUnit\Framework\TestCase ); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\LogNormalDistribution + * @group framework + */ public function testMedian() : void { self::assertEquals(\exp(3), LogNormalDistribution::getMedian(3)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\LogNormalDistribution + * @group framework + */ public function testMode() : void { self::assertEquals(\exp(3 - 4 ** 2), LogNormalDistribution::getMode(3, 4)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\LogNormalDistribution + * @group framework + */ public function testEntropy() : void { self::assertEqualsWithDelta( @@ -91,6 +131,10 @@ class LogNormalDistributionTest extends \PHPUnit\Framework\TestCase ); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\LogNormalDistribution + * @group framework + */ public function testFisherInformation() : void { self::assertEquals( diff --git a/tests/Math/Stochastic/Distribution/LogisticDistributionTest.php b/tests/Math/Stochastic/Distribution/LogisticDistributionTest.php index 9e2b6d2bf..0e0951e49 100644 --- a/tests/Math/Stochastic/Distribution/LogisticDistributionTest.php +++ b/tests/Math/Stochastic/Distribution/LogisticDistributionTest.php @@ -21,6 +21,10 @@ use phpOMS\Math\Stochastic\Distribution\LogisticDistribution; */ class LogisticDistributionTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\Math\Stochastic\Distribution\LogisticDistribution + * @group framework + */ public function testPdf() : void { $x = 3; @@ -33,6 +37,10 @@ class LogisticDistributionTest extends \PHPUnit\Framework\TestCase ); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\LogisticDistribution + * @group framework + */ public function testCdf() : void { $x = 3; @@ -45,21 +53,37 @@ class LogisticDistributionTest extends \PHPUnit\Framework\TestCase ); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\LogisticDistribution + * @group framework + */ public function testMode() : void { self::assertEquals(3, LogisticDistribution::getMode(3)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\LogisticDistribution + * @group framework + */ public function testMean() : void { self::assertEquals(3, LogisticDistribution::getMean(3)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\LogisticDistribution + * @group framework + */ public function testMedian() : void { self::assertEquals(3, LogisticDistribution::getMedian(3)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\LogisticDistribution + * @group framework + */ public function testVariance() : void { $s = 3; @@ -69,6 +93,10 @@ class LogisticDistributionTest extends \PHPUnit\Framework\TestCase ); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\LogisticDistribution + * @group framework + */ public function testStandardDeviation() : void { $s = 3; @@ -78,16 +106,28 @@ class LogisticDistributionTest extends \PHPUnit\Framework\TestCase ); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\LogisticDistribution + * @group framework + */ public function testSkewness() : void { self::assertEquals(0, LogisticDistribution::getSkewness()); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\LogisticDistribution + * @group framework + */ public function testExKurtosis() : void { self::assertEquals(6 / 5, LogisticDistribution::getExKurtosis()); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\LogisticDistribution + * @group framework + */ public function testEntropy() : void { $s = 3; diff --git a/tests/Math/Stochastic/Distribution/NormalDistributionTest.php b/tests/Math/Stochastic/Distribution/NormalDistributionTest.php index d0e0a0c05..2ea3ac942 100644 --- a/tests/Math/Stochastic/Distribution/NormalDistributionTest.php +++ b/tests/Math/Stochastic/Distribution/NormalDistributionTest.php @@ -21,6 +21,10 @@ use phpOMS\Math\Stochastic\Distribution\NormalDistribution; */ class NormalDistributionTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\Math\Stochastic\Distribution\NormalDistribution + * @group framework + */ public function testPdf() : void { $mean = 2; @@ -30,6 +34,10 @@ class NormalDistributionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(0.24197, NormalDistribution::getPdf($x, $mean, $sig), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\NormalDistribution + * @group framework + */ public function testCdf() : void { $mean = 2; @@ -39,6 +47,10 @@ class NormalDistributionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(0.84134, NormalDistribution::getCdf($x, $mean, $sig), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\NormalDistribution + * @group framework + */ public function testMean() : void { $mu = 4; @@ -46,6 +58,10 @@ class NormalDistributionTest extends \PHPUnit\Framework\TestCase self::assertEquals($mu, NormalDistribution::getMean($mu)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\NormalDistribution + * @group framework + */ public function testMedian() : void { $mu = 4; @@ -53,6 +69,10 @@ class NormalDistributionTest extends \PHPUnit\Framework\TestCase self::assertEquals($mu, NormalDistribution::getMedian($mu)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\NormalDistribution + * @group framework + */ public function testMode() : void { $mu = 4; @@ -60,16 +80,28 @@ class NormalDistributionTest extends \PHPUnit\Framework\TestCase self::assertEquals($mu, NormalDistribution::getMode($mu)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\NormalDistribution + * @group framework + */ public function testSkewness() : void { self::assertEquals(0, NormalDistribution::getSkewness()); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\NormalDistribution + * @group framework + */ public function testExKurtosis() : void { self::assertEquals(0, NormalDistribution::getExKurtosis()); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\NormalDistribution + * @group framework + */ public function testVariance() : void { $sig = 0.8; @@ -77,6 +109,10 @@ class NormalDistributionTest extends \PHPUnit\Framework\TestCase self::assertEquals($sig ** 2, NormalDistribution::getVariance($sig)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\NormalDistribution + * @group framework + */ public function testStandardDeviation() : void { $sig = 0.8; @@ -84,16 +120,28 @@ class NormalDistributionTest extends \PHPUnit\Framework\TestCase self::assertEquals($sig, NormalDistribution::getStandardDeviation($sig)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\NormalDistribution + * @group framework + */ public function testSampleSizeCalculation() : void { self::assertEqualsWithDelta(277.54, NormalDistribution::getSampleSizeFromPopulation(NormalDistribution::TABLE['0.95'], 0.05, 1000, 0.5), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\NormalDistribution + * @group framework + */ public function testSampleSizeInfiniteCalculation() : void { self::assertEqualsWithDelta(384.16, NormalDistribution::getSampleSizeFromInfinitePopulation(NormalDistribution::TABLE['0.95'], 0.05, 0.5), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\NormalDistribution + * @group framework + */ public function testMgf() : void { $t = 3; @@ -106,6 +154,10 @@ class NormalDistributionTest extends \PHPUnit\Framework\TestCase ); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\NormalDistribution + * @group framework + */ public function testFisherInformation() : void { self::assertEquals( diff --git a/tests/Math/Stochastic/Distribution/ParetoDistributionTest.php b/tests/Math/Stochastic/Distribution/ParetoDistributionTest.php index dd613f5b0..60be11081 100644 --- a/tests/Math/Stochastic/Distribution/ParetoDistributionTest.php +++ b/tests/Math/Stochastic/Distribution/ParetoDistributionTest.php @@ -21,55 +21,95 @@ use phpOMS\Math\Stochastic\Distribution\ParetoDistribution; */ class ParetoDistributionTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\Math\Stochastic\Distribution\ParetoDistribution + * @group framework + */ public function testPdf() : void { self::assertEqualsWithDelta(0.263374485596, ParetoDistribution::getPdf(3, 2, 4), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\ParetoDistribution + * @group framework + */ public function testCdf() : void { self::assertEqualsWithDelta(0.8024691358, ParetoDistribution::getCdf(3, 2, 4), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\ParetoDistribution + * @group framework + */ public function testMean() : void { self::assertEqualsWithDelta(8 / 3, ParetoDistribution::getMean(2, 4), 0.001); self::assertEquals(\PHP_FLOAT_MAX, ParetoDistribution::getMean(2, 1)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\ParetoDistribution + * @group framework + */ public function testVariance() : void { self::assertEqualsWithDelta(2, ParetoDistribution::getVariance(3, 4), 0.001); self::assertEqualsWithDelta(\PHP_FLOAT_MAX, ParetoDistribution::getVariance(3, 2), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\ParetoDistribution + * @group framework + */ public function testStandardDeviation() : void { self::assertEqualsWithDelta(\sqrt(2), ParetoDistribution::getStandardDeviation(3, 4), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\ParetoDistribution + * @group framework + */ public function testExKurtosis() : void { self::assertEqualsWithDelta(35.666666666666664, ParetoDistribution::getExKurtosis(6, 5), 0.001); self::assertEquals(0.0, ParetoDistribution::getExKurtosis(4)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\ParetoDistribution + * @group framework + */ public function testSkewness() : void { self::assertEqualsWithDelta(3.810317377662722, ParetoDistribution::getSkewness(6, 5), 0.001); self::assertEquals(0.0, ParetoDistribution::getSkewness(3)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\ParetoDistribution + * @group framework + */ public function testMedian() : void { self::assertEquals(3 * \pow(2, 1 / 4), ParetoDistribution::getMedian(3, 4)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\ParetoDistribution + * @group framework + */ public function testMode() : void { self::assertEquals(3, ParetoDistribution::getMode(3)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\ParetoDistribution + * @group framework + */ public function testEntropy() : void { self::assertEquals( @@ -78,6 +118,10 @@ class ParetoDistributionTest extends \PHPUnit\Framework\TestCase ); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\ParetoDistribution + * @group framework + */ public function testFisherInformation() : void { self::assertEquals( diff --git a/tests/Math/Stochastic/Distribution/PoissonDistributionTest.php b/tests/Math/Stochastic/Distribution/PoissonDistributionTest.php index 1ea07ba2f..0e90d29ee 100644 --- a/tests/Math/Stochastic/Distribution/PoissonDistributionTest.php +++ b/tests/Math/Stochastic/Distribution/PoissonDistributionTest.php @@ -21,6 +21,10 @@ use phpOMS\Math\Stochastic\Distribution\PoissonDistribution; */ class PoissonDistributionTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\Math\Stochastic\Distribution\PoissonDistribution + * @group framework + */ public function testPmf() : void { $k = 4; @@ -29,6 +33,10 @@ class PoissonDistributionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(0.16803, PoissonDistribution::getPmf(4, 3), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\PoissonDistribution + * @group framework + */ public function testCdf() : void { $k = 4; @@ -37,6 +45,10 @@ class PoissonDistributionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(0.81526, PoissonDistribution::getCdf(4, 3), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\PoissonDistribution + * @group framework + */ public function testMode() : void { $l = 4.6; @@ -44,6 +56,10 @@ class PoissonDistributionTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(4, PoissonDistribution::getMode($l), 0.01); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\PoissonDistribution + * @group framework + */ public function testMean() : void { $l = 4.6; @@ -51,6 +67,10 @@ class PoissonDistributionTest extends \PHPUnit\Framework\TestCase self::assertEquals($l, PoissonDistribution::getMean($l)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\PoissonDistribution + * @group framework + */ public function testVariance() : void { $l = 4.6; @@ -58,6 +78,10 @@ class PoissonDistributionTest extends \PHPUnit\Framework\TestCase self::assertEquals($l, PoissonDistribution::getVariance($l)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\PoissonDistribution + * @group framework + */ public function testStandardDeviation() : void { $l = 4.6; @@ -65,6 +89,10 @@ class PoissonDistributionTest extends \PHPUnit\Framework\TestCase self::assertEquals(\sqrt($l), PoissonDistribution::getStandardDeviation($l)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\PoissonDistribution + * @group framework + */ public function testSkewness() : void { $l = 4.6; @@ -72,6 +100,10 @@ class PoissonDistributionTest extends \PHPUnit\Framework\TestCase self::assertEquals(1 / \sqrt($l), PoissonDistribution::getSkewness($l)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\PoissonDistribution + * @group framework + */ public function testExKurtosis() : void { $l = 4.6; @@ -79,6 +111,10 @@ class PoissonDistributionTest extends \PHPUnit\Framework\TestCase self::assertEquals(1 / $l, PoissonDistribution::getExKurtosis($l)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\PoissonDistribution + * @group framework + */ public function testMedian() : void { $l = 4.6; @@ -86,6 +122,10 @@ class PoissonDistributionTest extends \PHPUnit\Framework\TestCase self::assertEquals(\floor($l + 1 / 3 - 0.02 / $l), PoissonDistribution::getMedian($l)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\PoissonDistribution + * @group framework + */ public function testFisherInformation() : void { $l = 4.6; @@ -93,6 +133,10 @@ class PoissonDistributionTest extends \PHPUnit\Framework\TestCase self::assertEquals(1 / $l, PoissonDistribution::getFisherInformation($l)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\PoissonDistribution + * @group framework + */ public function testMgf() : void { $l = 4.6; diff --git a/tests/Math/Stochastic/Distribution/TDistributionTest.php b/tests/Math/Stochastic/Distribution/TDistributionTest.php index 944d24e22..a6d0d87b0 100644 --- a/tests/Math/Stochastic/Distribution/TDistributionTest.php +++ b/tests/Math/Stochastic/Distribution/TDistributionTest.php @@ -21,44 +21,76 @@ use phpOMS\Math\Stochastic\Distribution\TDistribution; */ class TDistributionTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\Math\Stochastic\Distribution\TDistribution + * @group framework + */ public function testMean() : void { self::assertEquals(0, TDistribution::getMean()); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\TDistribution + * @group framework + */ public function testMedian() : void { self::assertEquals(0, TDistribution::getMedian()); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\TDistribution + * @group framework + */ public function testMode() : void { self::assertEquals(0, TDistribution::getMode()); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\TDistribution + * @group framework + */ public function testVariance() : void { self::assertEqualsWithDelta(5 / 3, TDistribution::getVariance(5), 0.001); self::assertEqualsWithDelta(\PHP_FLOAT_MAX, TDistribution::getVariance(2), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\TDistribution + * @group framework + */ public function testStandardDeviation() : void { self::assertEqualsWithDelta(\sqrt(5 / 3), TDistribution::getStandardDeviation(5), 0.001); self::assertEqualsWithDelta(\PHP_FLOAT_MAX, TDistribution::getStandardDeviation(2), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\TDistribution + * @group framework + */ public function testExKurtosis() : void { self::assertEqualsWithDelta(6, TDistribution::getExKurtosis(5), 0.001); self::assertEqualsWithDelta(\PHP_FLOAT_MAX, TDistribution::getExKurtosis(3), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\TDistribution + * @group framework + */ public function testSkewness() : void { self::assertEquals(0, TDistribution::getSkewness()); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\TDistribution + * @group framework + */ public function testCdf() : void { self::assertEqualsWithDelta(0.0, TDistribution::getCdf(1.25, 5, 0), 0.001); diff --git a/tests/Math/Stochastic/Distribution/UniformDistributionContinuousTest.php b/tests/Math/Stochastic/Distribution/UniformDistributionContinuousTest.php index 436913ccb..3323c8106 100644 --- a/tests/Math/Stochastic/Distribution/UniformDistributionContinuousTest.php +++ b/tests/Math/Stochastic/Distribution/UniformDistributionContinuousTest.php @@ -21,6 +21,10 @@ use phpOMS\Math\Stochastic\Distribution\UniformDistributionContinuous; */ class UniformDistributionContinuousTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\Math\Stochastic\Distribution\UniformDistributionContinuous + * @group framework + */ public function testPdf() : void { $a = 1; @@ -31,6 +35,10 @@ class UniformDistributionContinuousTest extends \PHPUnit\Framework\TestCase self::assertEquals(0, UniformDistributionContinuous::getPdf(5, $a, $b)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\UniformDistributionContinuous + * @group framework + */ public function testCdf() : void { $a = 1; @@ -42,6 +50,10 @@ class UniformDistributionContinuousTest extends \PHPUnit\Framework\TestCase self::assertEquals(1, UniformDistributionContinuous::getCdf(5, $a, $b)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\UniformDistributionContinuous + * @group framework + */ public function testMode() : void { $a = 1; @@ -56,6 +68,10 @@ class UniformDistributionContinuousTest extends \PHPUnit\Framework\TestCase ); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\UniformDistributionContinuous + * @group framework + */ public function testMean() : void { $a = 1; @@ -64,6 +80,10 @@ class UniformDistributionContinuousTest extends \PHPUnit\Framework\TestCase self::assertEquals(1 / 2 * ($b + $a), UniformDistributionContinuous::getMean($a, $b)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\UniformDistributionContinuous + * @group framework + */ public function testMedian() : void { $a = 1; @@ -72,6 +92,10 @@ class UniformDistributionContinuousTest extends \PHPUnit\Framework\TestCase self::assertEquals(1 / 2 * ($b + $a), UniformDistributionContinuous::getMedian($a, $b)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\UniformDistributionContinuous + * @group framework + */ public function testVariance() : void { $a = 1; @@ -80,6 +104,10 @@ class UniformDistributionContinuousTest extends \PHPUnit\Framework\TestCase self::assertEquals(1 / 12 * ($b - $a) ** 2, UniformDistributionContinuous::getVariance($a, $b)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\UniformDistributionContinuous + * @group framework + */ public function testStandardDeviation() : void { $a = 1; @@ -88,16 +116,28 @@ class UniformDistributionContinuousTest extends \PHPUnit\Framework\TestCase self::assertEquals(\sqrt(1 / 12 * ($b - $a) ** 2), UniformDistributionContinuous::getStandardDeviation($a, $b)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\UniformDistributionContinuous + * @group framework + */ public function testSkewness() : void { self::assertEquals(0, UniformDistributionContinuous::getSkewness()); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\UniformDistributionContinuous + * @group framework + */ public function testExKurtosis() : void { self::assertEquals(-6 / 5, UniformDistributionContinuous::getExKurtosis()); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\UniformDistributionContinuous + * @group framework + */ public function testMgf() : void { self::assertEquals(1, UniformDistributionContinuous::getMgf(0, 2, 3)); diff --git a/tests/Math/Stochastic/Distribution/UniformDistributionDiscreteTest.php b/tests/Math/Stochastic/Distribution/UniformDistributionDiscreteTest.php index ac4fbe4da..2a14b2de4 100644 --- a/tests/Math/Stochastic/Distribution/UniformDistributionDiscreteTest.php +++ b/tests/Math/Stochastic/Distribution/UniformDistributionDiscreteTest.php @@ -21,6 +21,10 @@ use phpOMS\Math\Stochastic\Distribution\UniformDistributionDiscrete; */ class UniformDistributionDiscreteTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\Math\Stochastic\Distribution\UniformDistributionDiscrete + * @group framework + */ public function testPmf() : void { $a = 1; @@ -29,6 +33,10 @@ class UniformDistributionDiscreteTest extends \PHPUnit\Framework\TestCase self::assertEquals(1 / ($b - $a + 1), UniformDistributionDiscrete::getPmf($a, $b)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\UniformDistributionDiscrete + * @group framework + */ public function testCdf() : void { $a = 1; @@ -38,11 +46,19 @@ class UniformDistributionDiscreteTest extends \PHPUnit\Framework\TestCase self::assertEquals(($k - $a + 1) / ($b - $a + 1), UniformDistributionDiscrete::getCdf($k, $a, $b)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\UniformDistributionDiscrete + * @group framework + */ public function testSkewness() : void { self::assertEquals(0, UniformDistributionDiscrete::getSkewness()); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\UniformDistributionDiscrete + * @group framework + */ public function testMean() : void { $a = 1; @@ -51,6 +67,10 @@ class UniformDistributionDiscreteTest extends \PHPUnit\Framework\TestCase self::assertEquals(1 / 2 * ($a + $b), UniformDistributionDiscrete::getMean($a, $b)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\UniformDistributionDiscrete + * @group framework + */ public function testMedian() : void { $a = 1; @@ -59,6 +79,10 @@ class UniformDistributionDiscreteTest extends \PHPUnit\Framework\TestCase self::assertEquals(1 / 2 * ($a + $b), UniformDistributionDiscrete::getMedian($a, $b)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\UniformDistributionDiscrete + * @group framework + */ public function testVariance() : void { $a = 1; @@ -67,6 +91,10 @@ class UniformDistributionDiscreteTest extends \PHPUnit\Framework\TestCase self::assertEquals((($b - $a + 1) ** 2 - 1) / 12, UniformDistributionDiscrete::getVariance($a, $b)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\UniformDistributionDiscrete + * @group framework + */ public function testStandardDeviation() : void { $a = 1; @@ -75,6 +103,10 @@ class UniformDistributionDiscreteTest extends \PHPUnit\Framework\TestCase self::assertEquals(\sqrt((($b - $a + 1) ** 2 - 1) / 12), UniformDistributionDiscrete::getStandardDeviation($a, $b)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\UniformDistributionDiscrete + * @group framework + */ public function testExKurtosis() : void { $a = 1; @@ -84,6 +116,10 @@ class UniformDistributionDiscreteTest extends \PHPUnit\Framework\TestCase self::assertEquals(-(6 * ($n ** 2 + 1)) / (5 * ($n ** 2 - 1)), UniformDistributionDiscrete::getExKurtosis($a, $b)); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\UniformDistributionDiscrete + * @group framework + */ public function testMgf() : void { self::assertEquals( @@ -92,6 +128,10 @@ class UniformDistributionDiscreteTest extends \PHPUnit\Framework\TestCase ); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\UniformDistributionDiscrete + * @group framework + */ public function testCdfExceptionUpper() : void { $this->expectException(\OutOfBoundsException::class); @@ -99,6 +139,10 @@ class UniformDistributionDiscreteTest extends \PHPUnit\Framework\TestCase UniformDistributionDiscrete::getCdf(5, 2, 4); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\UniformDistributionDiscrete + * @group framework + */ public function testCdfExceptionLower() : void { $this->expectException(\OutOfBoundsException::class); diff --git a/tests/Math/Stochastic/Distribution/WeibullDistributionTest.php b/tests/Math/Stochastic/Distribution/WeibullDistributionTest.php index 31720850c..d640c4896 100644 --- a/tests/Math/Stochastic/Distribution/WeibullDistributionTest.php +++ b/tests/Math/Stochastic/Distribution/WeibullDistributionTest.php @@ -21,48 +21,84 @@ use phpOMS\Math\Stochastic\Distribution\WeibullDistribution; */ class WeibullDistributionTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\Math\Stochastic\Distribution\WeibullDistribution + * @group framework + */ public function testPdf() : void { self::assertEqualsWithDelta(0.213668559, WeibullDistribution::getPdf(3, 4, 2), 0.001); self::assertEqualsWithDelta(0.0, WeibullDistribution::getPdf(-1, 4, 2), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\WeibullDistribution + * @group framework + */ public function testCdf() : void { self::assertEqualsWithDelta(0.430217175, WeibullDistribution::getCdf(3, 4, 2), 0.001); self::assertEqualsWithDelta(0.0, WeibullDistribution::getCdf(-1, 4, 2), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\WeibullDistribution + * @group framework + */ public function testMean() : void { self::assertEqualsWithDelta(3.54490771, WeibullDistribution::getMean(4, 2), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\WeibullDistribution + * @group framework + */ public function testMedian() : void { self::assertEqualsWithDelta(3.33021844, WeibullDistribution::getMedian(4, 2), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\WeibullDistribution + * @group framework + */ public function testMode() : void { self::assertEqualsWithDelta(2.82842712, WeibullDistribution::getMode(4, 2), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\WeibullDistribution + * @group framework + */ public function testVariance() : void { self::assertEqualsWithDelta(3.43362932, WeibullDistribution::getVariance(4, 2), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\WeibullDistribution + * @group framework + */ public function testStandardDeviation() : void { self::assertEqualsWithDelta(\sqrt(3.43362932), WeibullDistribution::getStandardDeviation(4, 2), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\WeibullDistribution + * @group framework + */ public function testEntropy() : void { self::assertEqualsWithDelta(1.981755, WeibullDistribution::getEntropy(4, 2), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\WeibullDistribution + * @group framework + */ public function testSkewness() : void { self::assertEqualsWithDelta(0.631110, WeibullDistribution::getSkewness(4, 2), 0.001); diff --git a/tests/Math/Stochastic/Distribution/ZTestTest.php b/tests/Math/Stochastic/Distribution/ZTestTest.php index 3532e29ed..9a7a9cb3d 100644 --- a/tests/Math/Stochastic/Distribution/ZTestTest.php +++ b/tests/Math/Stochastic/Distribution/ZTestTest.php @@ -24,6 +24,10 @@ use phpOMS\Math\Stochastic\Distribution\ZTesting; class ZTestingTest extends \PHPUnit\Framework\TestCase { // http://sphweb.bumc.bu.edu/otlt/MPH-Modules/BS/BS704_HypothesisTesting-ChiSquare/BS704_HypothesisTesting-ChiSquare_print.html + /** + * @covers phpOMS\Math\Stochastic\Distribution\ZTesting + * @group framework + */ public function testHypothesisFalse() : void { $a = 0.95; @@ -35,11 +39,19 @@ class ZTestingTest extends \PHPUnit\Framework\TestCase } // https://support.microsoft.com/en-us/office/z-test-function-d633d5a3-2031-4614-a016-92180ad82bee?ui=en-us&rs=en-us&ad=us + /** + * @covers phpOMS\Math\Stochastic\Distribution\ZTesting + * @group framework + */ public function testZTest() : void { self::assertEqualsWithDelta(0.090574, ZTesting::zTest(4, [3, 6, 7, 8, 6, 5, 4, 2, 1, 9]), 0.001); } + /** + * @covers phpOMS\Math\Stochastic\Distribution\ZTesting + * @group framework + */ public function testZTestValues() : void { $data = [3, 6, 7, 8, 6, 5, 4, 2, 1, 9]; diff --git a/tests/Message/Console/ConsoleHeaderTest.php b/tests/Message/Console/ConsoleHeaderTest.php index 4f4e67f3f..56ff3882e 100644 --- a/tests/Message/Console/ConsoleHeaderTest.php +++ b/tests/Message/Console/ConsoleHeaderTest.php @@ -22,54 +22,112 @@ use phpOMS\Message\Console\ConsoleHeader; */ class ConsoleHeaderTest extends \PHPUnit\Framework\TestCase { + private ConsoleHeader $header; + + public function setUp() : void + { + $this->header = new ConsoleHeader(); + } + + /** + * @covers phpOMS\Message\Console\ConsoleHeader + * @group framework + */ public function testDefaults() : void { - $header = new ConsoleHeader(); - self::assertFalse($header->isLocked()); - self::assertEquals(0, $header->getStatusCode()); - self::assertEquals('1.0', $header->getProtocolVersion()); - self::assertEquals('', $header->getReasonPhrase()); - self::assertEquals([], $header->get('key')); - self::assertFalse($header->has('key')); - self::assertInstanceOf(Localization::class, $header->getL11n()); - self::assertEquals(0, $header->getAccount()); + self::assertFalse($this->header->isLocked()); + self::assertEquals(0, $this->header->getStatusCode()); + self::assertEquals('1.0', $this->header->getProtocolVersion()); + self::assertEquals('', $this->header->getReasonPhrase()); + self::assertEquals([], $this->header->get('key')); + self::assertFalse($this->header->has('key')); + self::assertInstanceOf(Localization::class, $this->header->getL11n()); + self::assertEquals(0, $this->header->getAccount()); } - public function testGetSet() : void + /** + * @covers phpOMS\Message\Console\ConsoleHeader + * @group framework + */ + public function testValueInputOutput() : void { - $header = new ConsoleHeader(); - - self::assertTrue($header->set('key', 'header')); - self::assertEquals(['header'], $header->get('key')); - self::assertTrue($header->has('key')); - - self::assertFalse($header->set('key', 'header2')); - self::assertEquals(['header'], $header->get('key')); - - self::assertTrue($header->set('key', 'header3', true)); - self::assertEquals(['header3'], $header->get('key')); - - self::assertTrue($header->remove('key')); - self::assertFalse($header->has('key')); - self::assertFalse($header->remove('key')); - - $header->setAccount(2); - self::AssertEquals(2, $header->getAccount(2)); + self::assertTrue($this->header->set('key', 'header')); + self::assertEquals(['header'], $this->header->get('key')); } + /** + * @covers phpOMS\Message\Console\ConsoleHeader + * @group framework + */ + public function testHasKey() : void + { + self::assertTrue($this->header->set('key', 'header')); + self::assertTrue($this->header->has('key')); + } + + /** + * @covers phpOMS\Message\Console\ConsoleHeader + * @group framework + */ + public function testInvalidOverwrite() : void + { + self::assertTrue($this->header->set('key', 'header')); + self::assertFalse($this->header->set('key', 'header2')); + self::assertEquals(['header'], $this->header->get('key')); + } + + /** + * @covers phpOMS\Message\Console\ConsoleHeader + * @group framework + */ + public function testOverwrite() : void + { + self::assertTrue($this->header->set('key', 'header')); + self::assertTrue($this->header->set('key', 'header3', true)); + self::assertEquals(['header3'], $this->header->get('key')); + } + + /** + * @covers phpOMS\Message\Console\ConsoleHeader + * @group framework + */ + public function testRemove() : void + { + self::assertTrue($this->header->set('key', 'header')); + self::assertTrue($this->header->remove('key')); + self::assertFalse($this->header->has('key')); + self::assertFalse($this->header->remove('key')); + } + + /** + * @covers phpOMS\Message\Console\ConsoleHeader + * @group framework + */ + public function testAccount() : void + { + $this->header->setAccount(2); + self::AssertEquals(2, $this->header->getAccount(2)); + } + + /** + * @covers phpOMS\Message\Console\ConsoleHeader + * @group framework + */ public function testLockedHeaderSet() : void { - $header = new ConsoleHeader(); - $header->lock(); - self::assertTrue($header->isLocked()); - self::assertFalse($header->set('key', 'value')); + $this->header->lock(); + self::assertTrue($this->header->isLocked()); + self::assertFalse($this->header->set('key', 'value')); } + /** + * @covers phpOMS\Message\Console\ConsoleHeader + * @group framework + */ public function testLockedHeaderRemove() : void { - $header = new ConsoleHeader(); - $header->lock(); - self::assertTrue($header->isLocked()); - self::assertFalse($header->remove('key')); + $this->header->lock(); + self::assertTrue($this->header->isLocked()); + self::assertFalse($this->header->remove('key')); } } diff --git a/tests/Message/Console/ConsoleRequestTest.php b/tests/Message/Console/ConsoleRequestTest.php index bc809d140..41ea31996 100644 --- a/tests/Message/Console/ConsoleRequestTest.php +++ b/tests/Message/Console/ConsoleRequestTest.php @@ -25,10 +25,20 @@ use phpOMS\Uri\Argument; */ class ConsoleRequestTest extends \PHPUnit\Framework\TestCase { + private ConsoleRequest $request; + + public function setUp() : void + { + $this->request = new ConsoleRequest(new Argument('get:some/test/path'), $l11n = new Localization()); + } + + /** + * @covers phpOMS\Message\Console\ConsoleRequest + * @group framework + */ public function testDefault() : void { $request = new ConsoleRequest(); - self::assertEquals('en', $request->getHeader()->getL11n()->getLanguage()); self::assertEquals(OSType::LINUX, $request->getOS()); self::assertEquals('127.0.0.1', $request->getOrigin()); @@ -39,30 +49,93 @@ class ConsoleRequestTest extends \PHPUnit\Framework\TestCase self::assertNull($request->getData('key')); } - public function testSetGet() : void + /** + * @covers phpOMS\Message\Console\ConsoleRequest + * @group framework + */ + public function testOSInputOutput() : void { - $request = new ConsoleRequest(new Argument('get:some/test/path'), $l11n = new Localization()); - - $request->setOS(OSType::WINDOWS_XP); - self::assertEquals(OSType::WINDOWS_XP, $request->getOS()); - - $request->setMethod(RequestMethod::PUT); - - $request->setMethod(RequestMethod::DELETE); - - $request->setMethod(RequestMethod::POST); - - self::assertEquals('get:some/test/path', $request->getUri()->__toString()); - - self::assertEquals($l11n, $request->getHeader()->getL11n()); - - self::assertTrue($request->setData('key', 'value')); - self::assertFalse($request->setData('key', 'value2', false)); - self::assertEquals('value', $request->getData('key')); - self::assertTrue($request->hasData('key')); - self::assertEquals(['key' => 'value'], $request->getData()); + $this->request->setOS(OSType::WINDOWS_XP); + self::assertEquals(OSType::WINDOWS_XP, $this->request->getOS()); } + /** + * @covers phpOMS\Message\Console\ConsoleRequest + * @group framework + */ + public function testMethodInputOutput() : void + { + $this->request->setMethod(RequestMethod::POST); + self::assertEquals(RequestMethod::POST, $this->request->getMethod()); + } + + /** + * @covers phpOMS\Message\Console\ConsoleRequest + * @group framework + */ + public function testInputOutputUriString() : void + { + self::assertEquals('get:some/test/path', $this->request->getUri()->__toString()); + } + + /** + * @covers phpOMS\Message\Console\ConsoleRequest + * @group framework + */ + public function testInputOutputL11n() : void + { + $l11n = new Localization(); + self::assertEquals($l11n, $this->request->getHeader()->getL11n()); + } + + /** + * @covers phpOMS\Message\Console\ConsoleRequest + * @group framework + */ + public function testDataInputOutput() : void + { + self::assertTrue($this->request->setData('key', 'value')); + self::assertEquals('value', $this->request->getData('key')); + self::assertEquals(['key' => 'value'], $this->request->getData()); + } + + /** + * @covers phpOMS\Message\Console\ConsoleRequest + * @group framework + */ + public function testHasData() : void + { + self::assertTrue($this->request->setData('key', 'value')); + self::assertTrue($this->request->hasData('key')); + } + + /** + * @covers phpOMS\Message\Console\ConsoleRequest + * @group framework + */ + public function testInvalidOverwrite() : void + { + self::assertTrue($this->request->setData('key', 'value')); + self::assertFalse($this->request->setData('key', 'value2', false)); + self::assertEquals('value', $this->request->getData('key')); + } + + /** + * @covers phpOMS\Message\Console\ConsoleRequest + * @group framework + */ + public function testOverwrite() : void + { + self::assertTrue($this->request->setData('key', 'value')); + self::assertTrue($this->request->setData('key', 'value2', true)); + self::assertEquals('value2', $this->request->getData('key')); + self::assertEquals(['key' => 'value2'], $this->request->getData()); + } + + /** + * @covers phpOMS\Message\Console\ConsoleRequest + * @group framework + */ public function testToString() : void { $request = new ConsoleRequest(new Argument('get:some/test/path')); diff --git a/tests/Message/Console/ConsoleResponseTest.php b/tests/Message/Console/ConsoleResponseTest.php index 5106651c8..e99033bb9 100644 --- a/tests/Message/Console/ConsoleResponseTest.php +++ b/tests/Message/Console/ConsoleResponseTest.php @@ -22,6 +22,10 @@ use phpOMS\Message\Console\ConsoleResponse; */ class ConsoleResponseTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\Message\Console\ConsoleResponse + * @group framework + */ public function testDefault() : void { $response = new ConsoleResponse(new Localization()); @@ -32,6 +36,10 @@ class ConsoleResponseTest extends \PHPUnit\Framework\TestCase self::assertInstanceOf('\phpOMS\Message\Console\ConsoleHeader', $response->getHeader()); } + /** + * @covers phpOMS\Message\Console\ConsoleResponse + * @group framework + */ public function testSetGet() : void { $response = new ConsoleResponse(new Localization()); diff --git a/tests/Message/Http/RestTest.php b/tests/Message/Http/RestTest.php index 18fb13d3e..503fd582b 100644 --- a/tests/Message/Http/RestTest.php +++ b/tests/Message/Http/RestTest.php @@ -94,11 +94,19 @@ class RestTest extends \PHPUnit\Framework\TestCase self::assertEquals('abc', REST::request($request)->getJsonData()['args']['gdata']); } + /** + * @covers phpOMS\Message\Http\Rest + * @group framework + */ public function testJsonRequest() : void { self::markTestIncomplete(); } + /** + * @covers phpOMS\Message\Http\Rest + * @group framework + */ public function testMultiRequest() : void { self::markTestIncomplete(); diff --git a/tests/Model/Message/DomTest.php b/tests/Model/Message/DomTest.php index ade8f5d0c..8b697b139 100644 --- a/tests/Model/Message/DomTest.php +++ b/tests/Model/Message/DomTest.php @@ -22,6 +22,10 @@ use phpOMS\Model\Message\DomAction; */ class DomTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\Model\Message\Dom + * @group framework + */ public function testAttributes() : void { $obj = new Dom(); @@ -34,6 +38,10 @@ class DomTest extends \PHPUnit\Framework\TestCase self::assertObjectHasAttribute('action', $obj); } + /** + * @covers phpOMS\Model\Message\Dom + * @group framework + */ public function testDefault() : void { $obj = new Dom(); @@ -45,6 +53,10 @@ class DomTest extends \PHPUnit\Framework\TestCase self::assertEquals(DomAction::MODIFY, $obj->toArray()['action']); } + /** + * @covers phpOMS\Model\Message\Dom + * @group framework + */ public function testSetGet() : void { $obj = new Dom(); diff --git a/tests/Model/Message/FormValidationTest.php b/tests/Model/Message/FormValidationTest.php index 177b5635a..6ecd5e655 100644 --- a/tests/Model/Message/FormValidationTest.php +++ b/tests/Model/Message/FormValidationTest.php @@ -21,6 +21,10 @@ use phpOMS\Model\Message\FormValidation; */ class FormValidationTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\Model\Message\FormValidation + * @group framework + */ public function testAttributes() : void { $obj = new FormValidation([]); @@ -30,6 +34,10 @@ class FormValidationTest extends \PHPUnit\Framework\TestCase self::assertObjectHasAttribute('validation', $obj); } + /** + * @covers phpOMS\Model\Message\FormValidation + * @group framework + */ public function testDefault() : void { $obj = new FormValidation([]); @@ -38,6 +46,10 @@ class FormValidationTest extends \PHPUnit\Framework\TestCase self::assertEmpty($obj->toArray()['validation']); } + /** + * @covers phpOMS\Model\Message\FormValidation + * @group framework + */ public function testSetGet() : void { $arr = ['a' => true, 'b' => false]; diff --git a/tests/Model/Message/NotifyTest.php b/tests/Model/Message/NotifyTest.php index 7e4488bbe..fca4a3226 100644 --- a/tests/Model/Message/NotifyTest.php +++ b/tests/Model/Message/NotifyTest.php @@ -22,6 +22,10 @@ use phpOMS\Model\Message\NotifyType; */ class NotifyTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\Model\Message\Notify + * @group framework + */ public function testAttributes() : void { $obj = new Notify(); @@ -35,6 +39,10 @@ class NotifyTest extends \PHPUnit\Framework\TestCase self::assertObjectHasAttribute('level', $obj); } + /** + * @covers phpOMS\Model\Message\Notify + * @group framework + */ public function testDefault() : void { $obj = new Notify(); @@ -47,6 +55,10 @@ class NotifyTest extends \PHPUnit\Framework\TestCase self::assertEquals(NotifyType::INFO, $obj->toArray()['level']); } + /** + * @covers phpOMS\Model\Message\Notify + * @group framework + */ public function testSetGet() : void { $obj = new Notify('message', NotifyType::WARNING); diff --git a/tests/Model/Message/RedirectTest.php b/tests/Model/Message/RedirectTest.php index 248f95e65..9fb39807c 100644 --- a/tests/Model/Message/RedirectTest.php +++ b/tests/Model/Message/RedirectTest.php @@ -21,6 +21,10 @@ use phpOMS\Model\Message\Redirect; */ class RedirectTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\Model\Message\Redirect + * @group framework + */ public function testAttributes() : void { $obj = new Redirect(''); @@ -32,6 +36,10 @@ class RedirectTest extends \PHPUnit\Framework\TestCase self::assertObjectHasAttribute('new', $obj); } + /** + * @covers phpOMS\Model\Message\Redirect + * @group framework + */ public function testDefault() : void { $obj = new Redirect(''); @@ -42,6 +50,10 @@ class RedirectTest extends \PHPUnit\Framework\TestCase self::assertFalse($obj->toArray()['new']); } + /** + * @covers phpOMS\Model\Message\Redirect + * @group framework + */ public function testSetGet() : void { $obj = new Redirect('url', true); diff --git a/tests/Model/Message/ReloadTest.php b/tests/Model/Message/ReloadTest.php index 0717ee025..5e9ef2ce1 100644 --- a/tests/Model/Message/ReloadTest.php +++ b/tests/Model/Message/ReloadTest.php @@ -21,6 +21,10 @@ use phpOMS\Model\Message\Reload; */ class ReloadTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\Model\Message\Reload + * @group framework + */ public function testAttributes() : void { $obj = new Reload(); @@ -30,6 +34,10 @@ class ReloadTest extends \PHPUnit\Framework\TestCase self::assertObjectHasAttribute('delay', $obj); } + /** + * @covers phpOMS\Model\Message\Reload + * @group framework + */ public function testDefault() : void { $obj = new Reload(); @@ -38,6 +46,10 @@ class ReloadTest extends \PHPUnit\Framework\TestCase self::assertEquals(0, $obj->toArray()['time']); } + /** + * @covers phpOMS\Model\Message\Reload + * @group framework + */ public function testSetGet() : void { $obj = new Reload(5); diff --git a/tests/Module/Exception/InvalidThemeExceptionTest.php b/tests/Module/Exception/InvalidThemeExceptionTest.php index b0f9561ef..731e3dc4a 100644 --- a/tests/Module/Exception/InvalidThemeExceptionTest.php +++ b/tests/Module/Exception/InvalidThemeExceptionTest.php @@ -21,6 +21,10 @@ use phpOMS\Module\Exception\InvalidThemeException; */ class InvalidThemeExceptionTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\Module\Exception\InvalidThemeException + * @group framework + */ public function testException() : void { self::assertInstanceOf(\UnexpectedValueException::class, new InvalidThemeException('')); diff --git a/tests/Module/ModuleManagerTest.php b/tests/Module/ModuleManagerTest.php index 6dc31c2a5..884d981a8 100644 --- a/tests/Module/ModuleManagerTest.php +++ b/tests/Module/ModuleManagerTest.php @@ -245,6 +245,10 @@ class ModuleManagerTest extends \PHPUnit\Framework\TestCase self::assertFalse($this->moduleManager->isRunning('TestModule')); } + /** + * @covers phpOMS\Module\ModuleManager + * @group framework + */ public function testInvalidModulePath() : void { $moduleManager = new ModuleManager($this->app, __DIR__ . '/Testmodule'); @@ -253,11 +257,19 @@ class ModuleManagerTest extends \PHPUnit\Framework\TestCase self::assertEquals([], $moduleManager->getInstalledModules()); } + /** + * @covers phpOMS\Module\ModuleManager + * @group framework + */ public function testInvalidModuleInstall() : void { self::assertFalse($this->moduleManager->install('Invalid')); } + /** + * @covers phpOMS\Module\ModuleManager + * @group framework + */ public function testInvalidModuleUninstall() : void { self::assertFalse($this->moduleManager->uninstall('Invalid')); diff --git a/tests/Module/PackageManagerTest.php b/tests/Module/PackageManagerTest.php index 8a6338016..baac342b6 100644 --- a/tests/Module/PackageManagerTest.php +++ b/tests/Module/PackageManagerTest.php @@ -29,17 +29,17 @@ class PackageManagerTest extends \PHPUnit\Framework\TestCase { public static function setUpBeforeClass() : void { - if (\file_exists(__DIR__ . '/testPackage.zip')) { + if (\is_file(__DIR__ . '/testPackage.zip')) { \unlink(__DIR__ . '/testPackage.zip'); } - if (\file_exists(__DIR__ . '/testPackageExtracted')) { + if (\is_file(__DIR__ . '/testPackageExtracted')) { \array_map('unlink', \glob(__DIR__ . '/testPackageExtracted/testSubPackage/*')); \rmdir(__DIR__ . '/testPackageExtracted/testSubPackage'); \array_map('unlink', \glob(__DIR__ . '/testPackageExtracted/*')); } - if (\file_exists(__DIR__ . '/public.key')) { + if (\is_file(__DIR__ . '/public.key')) { \unlink(__DIR__ . '/public.key'); } @@ -88,7 +88,7 @@ class PackageManagerTest extends \PHPUnit\Framework\TestCase */ public function testPackageValidInstall() : void { - if (\file_exists(__DIR__ . '/dummyModule')) { + if (\is_dir(__DIR__ . '/dummyModule')) { Directory::delete(__DIR__ . '/dummyModule'); } @@ -110,19 +110,19 @@ class PackageManagerTest extends \PHPUnit\Framework\TestCase 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::assertFalse(\is_dir(__DIR__ . '/dummyModule/toMove')); + self::assertTrue(\is_dir(__DIR__ . '/dummyModule/moveHere')); + self::assertTrue(\is_file(__DIR__ . '/dummyModule/moveHere/a.md')); + self::assertTrue(\is_file(__DIR__ . '/dummyModule/moveHere/sub/b.txt')); - self::assertTrue(\file_exists(__DIR__ . '/dummyModule/externalCopy.md')); + self::assertTrue(\is_file(__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::assertTrue(\is_dir(__DIR__ . '/dummyModule/toCopy')); + self::assertTrue(\is_dir(__DIR__ . '/dummyModule/copyHere')); + self::assertTrue(\is_file(__DIR__ . '/dummyModule/copyHere/a.md')); + self::assertTrue(\is_file(__DIR__ . '/dummyModule/copyHere/sub/b.txt')); - self::assertFalse(\file_exists(__DIR__ . '/dummyModule/Remove')); + self::assertFalse(\is_dir(__DIR__ . '/dummyModule/Remove')); \sleep(1); @@ -134,7 +134,7 @@ class PackageManagerTest extends \PHPUnit\Framework\TestCase self::assertEquals('cmd script', \file_get_contents(__DIR__ . '/dummyModule/cmdscript.md')); } - if (\file_exists(__DIR__ . '/dummyModule')) { + if (\is_dir(__DIR__ . '/dummyModule')) { Directory::delete(__DIR__ . '/dummyModule'); } } @@ -234,18 +234,18 @@ class PackageManagerTest extends \PHPUnit\Framework\TestCase public static function tearDownAfterClass() : void { - if (\file_exists(__DIR__ . '/testPackage.zip')) { + if (\is_file(__DIR__ . '/testPackage.zip')) { \unlink(__DIR__ . '/testPackage.zip'); } - if (\file_exists(__DIR__ . '/testPackageExtracted')) { + if (\is_dir(__DIR__ . '/testPackageExtracted')) { \array_map('unlink', \glob(__DIR__ . '/testPackageExtracted/testSubPackage/*')); \rmdir(__DIR__ . '/testPackageExtracted/testSubPackage'); \array_map('unlink', \glob(__DIR__ . '/testPackageExtracted/*')); \rmdir(__DIR__ . '/testPackageExtracted'); } - if (\file_exists(__DIR__ . '/public.key')) { + if (\is_file(__DIR__ . '/public.key')) { \unlink(__DIR__ . '/public.key'); } diff --git a/tests/Socket/Client/ClientTest.php b/tests/Socket/Client/ClientTest.php index 5d9b8af27..5c8b88bfb 100644 --- a/tests/Socket/Client/ClientTest.php +++ b/tests/Socket/Client/ClientTest.php @@ -36,11 +36,11 @@ class ClientTest extends \PHPUnit\Framework\TestCase public static function setUpBeforeClass() : void { - if (\file_exists(__DIR__ . '/client.log')) { + if (\is_file(__DIR__ . '/client.log')) { \unlink(__DIR__ . '/client.log'); } - if (\file_exists(__DIR__ . '/server.log')) { + if (\is_file(__DIR__ . '/server.log')) { \unlink(__DIR__ . '/server.log'); } } @@ -76,6 +76,10 @@ class ClientTest extends \PHPUnit\Framework\TestCase \unlink(__DIR__ . '/server.log'); } + /** + * @covers phpOMS\Socket\Client\Client + * @group framework + */ public function testSetupTCPSocket() : void { self::markTestIncomplete(); diff --git a/tests/Socket/Client/NullClientConnectionTest.php b/tests/Socket/Client/NullClientConnectionTest.php index 6ed1cf39f..1139a5303 100644 --- a/tests/Socket/Client/NullClientConnectionTest.php +++ b/tests/Socket/Client/NullClientConnectionTest.php @@ -23,6 +23,10 @@ use phpOMS\Socket\Client\NullClientConnection; */ final class NullClientConnectionTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\Socket\Client\NullClientConnection + * @group framework + */ public function testDefault() : void { self::assertInstanceOf(ClientConnection::class, new NullClientConnection(new Account(), null)); diff --git a/tests/Socket/Server/ServerTest.php b/tests/Socket/Server/ServerTest.php index 2ce13aed0..8539a26b2 100644 --- a/tests/Socket/Server/ServerTest.php +++ b/tests/Socket/Server/ServerTest.php @@ -36,11 +36,11 @@ class ServerTest extends \PHPUnit\Framework\TestCase public static function setUpBeforeClass() : void { - if (\file_exists(__DIR__ . '/client.log')) { + if (\is_file(__DIR__ . '/client.log')) { \unlink(__DIR__ . '/client.log'); } - if (\file_exists(__DIR__ . '/server.log')) { + if (\is_file(__DIR__ . '/server.log')) { \unlink(__DIR__ . '/server.log'); } } @@ -76,6 +76,10 @@ class ServerTest extends \PHPUnit\Framework\TestCase \unlink(__DIR__ . '/server.log'); } + /** + * @covers phpOMS\Socket\Server\Server + * @group framework + */ public function testSetupTCPSocket() : void { $pipes = []; @@ -89,7 +93,7 @@ class ServerTest extends \PHPUnit\Framework\TestCase $socket->run(); - self::assertTrue(\file_exists(__DIR__ . '/server.log')); + self::assertTrue(\is_file(__DIR__ . '/server.log')); self::assertEquals( 'Creating socket...' . "\n" . 'Binding socket...' . "\n" @@ -103,7 +107,7 @@ class ServerTest extends \PHPUnit\Framework\TestCase \file_get_contents(__DIR__ . '/server.log') ); - self::assertTrue(\file_exists(__DIR__ . '/client.log')); + self::assertTrue(\is_file(__DIR__ . '/client.log')); $client = \file_get_contents(__DIR__ . '/client.log'); self::assertStringContainsString('Sending: handshake', $client); self::assertStringContainsString('Sending: help', $client); diff --git a/tests/Stdlib/Base/Exception/InvalidEnumNameTest.php b/tests/Stdlib/Base/Exception/InvalidEnumNameTest.php index 386e885cb..52377cc83 100644 --- a/tests/Stdlib/Base/Exception/InvalidEnumNameTest.php +++ b/tests/Stdlib/Base/Exception/InvalidEnumNameTest.php @@ -21,6 +21,10 @@ use phpOMS\Stdlib\Base\Exception\InvalidEnumName; */ class InvalidEnumNameTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\Stdlib\Base\Exception\InvalidEnumName + * @group framework + */ public function testException() : void { self::assertInstanceOf(\UnexpectedValueException::class, new InvalidEnumName('')); diff --git a/tests/Stdlib/Base/Exception/InvalidEnumValueTest.php b/tests/Stdlib/Base/Exception/InvalidEnumValueTest.php index d216fa98c..9a14c0271 100644 --- a/tests/Stdlib/Base/Exception/InvalidEnumValueTest.php +++ b/tests/Stdlib/Base/Exception/InvalidEnumValueTest.php @@ -21,6 +21,10 @@ use phpOMS\Stdlib\Base\Exception\InvalidEnumValue; */ class InvalidEnumValueTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\Stdlib\Base\Exception\InvalidEnumValue + * @group framework + */ public function testException() : void { self::assertInstanceOf(\UnexpectedValueException::class, new InvalidEnumValue('')); diff --git a/tests/System/File/FileUtilsTest.php b/tests/System/File/FileUtilsTest.php index d0931aae7..c65911d7d 100644 --- a/tests/System/File/FileUtilsTest.php +++ b/tests/System/File/FileUtilsTest.php @@ -75,7 +75,7 @@ class FileUtilsTest extends \PHPUnit\Framework\TestCase */ public function testChangeFileEncoding() : void { - if (\file_exists(__DIR__ . '/UTF-8.txt')) { + if (\is_file(__DIR__ . '/UTF-8.txt')) { \unlink(__DIR__ . '/UTF-8.txt'); } @@ -85,7 +85,7 @@ class FileUtilsTest extends \PHPUnit\Framework\TestCase self::assertNotEquals("This is a test file with some¶\ncontent Ø Æ.", \file_get_contents(__DIR__ . '/Windows-1252.txt')); self::assertEquals("This is a test file with some¶\ncontent Ø Æ.", \file_get_contents(__DIR__ . '/UTF-8.txt')); - if (\file_exists(__DIR__ . '/UTF-8.txt')) { + if (\is_file(__DIR__ . '/UTF-8.txt')) { \unlink(__DIR__ . '/UTF-8.txt'); } } diff --git a/tests/System/File/Ftp/DirectoryTest.php b/tests/System/File/Ftp/DirectoryTest.php index 006c78501..a6d3e6953 100644 --- a/tests/System/File/Ftp/DirectoryTest.php +++ b/tests/System/File/Ftp/DirectoryTest.php @@ -42,11 +42,19 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase } } + /** + * @covers phpOMS\System\File\Ftp\Directory + * @group framework + */ public function testConnection() : void { self::assertNotFalse(Directory::ftpConnect(new HttpUri(self::BASE . '/test'))); } + /** + * @covers phpOMS\System\File\Ftp\Directory + * @group framework + */ public function testInvalidConnection() : void { self::assertFalse(Directory::ftpConnect(new HttpUri('ftp://orange-management.org:21'))); @@ -54,7 +62,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox A directory can be created - * @covers phpOMS\System\File\Ftp\Directory + * @covers phpOMS\System\File\Ftp\Directory * @group framework */ public function testStaticCreate() : void @@ -68,7 +76,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox A directory can be checked for existence - * @covers phpOMS\System\File\Ftp\Directory + * @covers phpOMS\System\File\Ftp\Directory * @group framework */ public function testStaticExists() : void @@ -79,7 +87,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox An existing directory cannot be overwritten - * @covers phpOMS\System\File\Ftp\Directory + * @covers phpOMS\System\File\Ftp\Directory * @group framework */ public function testInvalidStaticOverwrite() : void @@ -93,7 +101,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox A directory can be forced to be created recursively - * @covers phpOMS\System\File\Ftp\Directory + * @covers phpOMS\System\File\Ftp\Directory * @group framework */ public function testStaticSubdir() : void @@ -109,7 +117,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox By default a directory is not created recursively - * @covers phpOMS\System\File\Ftp\Directory + * @covers phpOMS\System\File\Ftp\Directory * @group framework */ public function testInvalidStaticSubdir() : void @@ -119,7 +127,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox The name of a directory is just its name without its path - * @covers phpOMS\System\File\Ftp\Directory + * @covers phpOMS\System\File\Ftp\Directory * @group framework */ public function testStaticName() : void @@ -131,7 +139,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox The basename is the same as the name of the directory - * @covers phpOMS\System\File\Ftp\Directory + * @covers phpOMS\System\File\Ftp\Directory * @group framework */ public function testStaticBasename() : void @@ -143,7 +151,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox The dirname is the same as the name of the directory - * @covers phpOMS\System\File\Ftp\Directory + * @covers phpOMS\System\File\Ftp\Directory * @group framework */ public function testStaticDirname() : void @@ -155,7 +163,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox The parent of a directory can be returned - * @covers phpOMS\System\File\Ftp\Directory + * @covers phpOMS\System\File\Ftp\Directory * @group framework */ public function testStaticParent() : void @@ -167,7 +175,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox The full absolute path of a directory can be returned - * @covers phpOMS\System\File\Ftp\Directory + * @covers phpOMS\System\File\Ftp\Directory * @group framework */ public function testStaticDirectoryPath() : void @@ -179,7 +187,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox The directories creation date can be returned - * @covers phpOMS\System\File\Ftp\Directory + * @covers phpOMS\System\File\Ftp\Directory * @group framework */ public function testStaticCreatedAt() : void @@ -198,7 +206,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox The directories last change date can be returned - * @covers phpOMS\System\File\Ftp\Directory + * @covers phpOMS\System\File\Ftp\Directory * @group framework */ public function testStaticChangedAt() : void @@ -217,7 +225,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox A directory can be deleted - * @covers phpOMS\System\File\Ftp\Directory + * @covers phpOMS\System\File\Ftp\Directory * @group framework */ public function testStaticDelete() : void @@ -231,7 +239,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox A none-existing directory cannot be deleted - * @covers phpOMS\System\File\Ftp\Directory + * @covers phpOMS\System\File\Ftp\Directory * @group framework */ public function testInvalidStaticDelete() : void @@ -243,7 +251,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox The size of a directory can be returned - * @covers phpOMS\System\File\Ftp\Directory + * @covers phpOMS\System\File\Ftp\Directory * @group framework */ public function testStaticSizeRecursive() : void @@ -254,7 +262,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox The size of a none-existing directory is negative - * @covers phpOMS\System\File\Ftp\Directory + * @covers phpOMS\System\File\Ftp\Directory * @group framework */ public function testInvalidStaticSizeRecursive() : void @@ -265,7 +273,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox The recursive size of a directory is equals or greater than the size of the same directory none-recursive - * @covers phpOMS\System\File\Ftp\Directory + * @covers phpOMS\System\File\Ftp\Directory * @group framework */ public function testStaticSize() : void @@ -276,7 +284,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox The permission of a directory can be returned - * @covers phpOMS\System\File\Ftp\Directory + * @covers phpOMS\System\File\Ftp\Directory * @group framework */ public function testStaticPermission() : void @@ -287,7 +295,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox The permission of a none-existing directory is negative - * @covers phpOMS\System\File\Ftp\Directory + * @covers phpOMS\System\File\Ftp\Directory * @group framework */ public function testInvalidStaticPermission() : void @@ -298,7 +306,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox A directory can be copied recursively - * @covers phpOMS\System\File\Ftp\Directory + * @covers phpOMS\System\File\Ftp\Directory * @group framework */ public function testStaticCopy() : void @@ -310,6 +318,10 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase Directory::delete(self::$con, __DIR__ . '/newdirtest'); } + /** + * @covers phpOMS\System\File\Ftp\Directory + * @group framework + */ public function testStaticCopyOverwrite() : void { $dirTestPath = __DIR__ . '/dirtest'; @@ -321,6 +333,10 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase Directory::delete(self::$con, __DIR__ . '/newdirtest'); } + /** + * @covers phpOMS\System\File\Ftp\Directory + * @group framework + */ public function testStaticInvalidCopyOverwrite() : void { $dirTestPath = __DIR__ . '/dirtest'; @@ -332,7 +348,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox A directory can be moved/renamed to a different path - * @covers phpOMS\System\File\Ftp\Directory + * @covers phpOMS\System\File\Ftp\Directory * @group framework */ public function testStaticMove() : void @@ -345,6 +361,10 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase Directory::move(self::$con, __DIR__ . '/newdirtest', $dirTestPath); } + /** + * @covers phpOMS\System\File\Ftp\Directory + * @group framework + */ public function testStaticInvalidMoveOverwrite() : void { $dirTestPath = __DIR__ . '/dirtest'; @@ -355,6 +375,10 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase Directory::move(self::$con, __DIR__ . '/newdirtest', $dirTestPath); } + /** + * @covers phpOMS\System\File\Ftp\Directory + * @group framework + */ public function testStaticMoveOverwrite() : void { $dirTestPath = __DIR__ . '/dirtest'; @@ -370,7 +394,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox The amount of files in a directory can be returned recursively - * @covers phpOMS\System\File\Ftp\Directory + * @covers phpOMS\System\File\Ftp\Directory * @group framework */ public function testStaticCountRecursive() : void @@ -381,7 +405,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox The amount of files in a directory can be returned none-recursively - * @covers phpOMS\System\File\Ftp\Directory + * @covers phpOMS\System\File\Ftp\Directory * @group framework */ public function testStaticCount() : void @@ -392,7 +416,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox The amount of files of a none-existing directory is negative - * @covers phpOMS\System\File\Ftp\Directory + * @covers phpOMS\System\File\Ftp\Directory * @group framework */ public function testInvalidStaticCount() : void @@ -403,7 +427,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox All files and sub-directories of a directory can be listed - * @covers phpOMS\System\File\Ftp\Directory + * @covers phpOMS\System\File\Ftp\Directory * @group framework */ public function testStaticListFiles() : void @@ -412,18 +436,30 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase self::assertCount(6, Directory::list(self::$con, $dirTestPath, '*', true)); } + /** + * @covers phpOMS\System\File\Ftp\Directory + * @group framework + */ public function testStaticListFilesByExtension() : void { $dirTestPath = __DIR__ . '/dirtest'; self::assertCount(3, Directory::listByExtension(self::$con, $dirTestPath, 'txt', '', true)); } + /** + * @covers phpOMS\System\File\Ftp\Directory + * @group framework + */ public function testStaticOwner() : void { $dirTestPath = __DIR__ . '/dirtest'; self::assertNotEmpty(Directory::owner(self::$con, $dirTestPath)); } + /** + * @covers phpOMS\System\File\Ftp\Directory + * @group framework + */ public function testDirectoryNameSanitizing() : void { self::assertEquals(':/some/test/[path', Directory::sanitize(':#&^$/some%/test/[path!')); @@ -431,7 +467,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox A none-existing directory returns a empty list of files and sub-directories - * @covers phpOMS\System\File\Ftp\Directory + * @covers phpOMS\System\File\Ftp\Directory * @group framework */ public function testInvalidListPath() : void @@ -439,6 +475,10 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase self::assertEquals([], Directory::list(self::$con, __DIR__ . '/invalid.txt')); } + /** + * @covers phpOMS\System\File\Ftp\Directory + * @group framework + */ public function testInvalidListFilesByExtension() : void { self::assertEquals([], Directory::listByExtension(self::$con, __DIR__ . '/invalid/path/here', 'txt')); @@ -446,7 +486,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox A invalid directory cannot be copied to a new destination - * @covers phpOMS\System\File\Ftp\Directory + * @covers phpOMS\System\File\Ftp\Directory * @group framework */ public function testInvalidCopyPath() : void @@ -456,7 +496,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox A invalid directory cannot be moved to a new destination - * @covers phpOMS\System\File\Ftp\Directory + * @covers phpOMS\System\File\Ftp\Directory * @group framework */ public function testInvalidMovePath() : void @@ -466,7 +506,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox Reading the creation date of a none-existing directory throws a PathException - * @covers phpOMS\System\File\Ftp\Directory + * @covers phpOMS\System\File\Ftp\Directory * @group framework */ public function testInvalidCreatedPath() : void @@ -478,7 +518,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox Reading the last change date of a none-existing directory throws a PathException - * @covers phpOMS\System\File\Ftp\Directory + * @covers phpOMS\System\File\Ftp\Directory * @group framework */ public function testInvalidChangedPath() : void @@ -490,7 +530,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox Reading the owner of a none-existing directory throws a PathException - * @covers phpOMS\System\File\Ftp\Directory + * @covers phpOMS\System\File\Ftp\Directory * @group framework */ public function testInvalidOwnerPath() : void @@ -500,6 +540,10 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase Directory::owner(self::$con, __DIR__ . '/invalid'); } + /** + * @covers phpOMS\System\File\Ftp\Directory + * @group framework + */ public function testList() : void { $dirTestPath = __DIR__ . '/dirtest'; @@ -511,6 +555,10 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase ], $dir->getList()); } + /** + * @covers phpOMS\System\File\Ftp\Directory + * @group framework + */ public function testNodeOutput() : void { $dirTestPath = __DIR__ . '/dirtest'; @@ -519,55 +567,75 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase self::assertInstanceOf(Directory::class, $dir->getNode('sub')); } + /** + * @covers phpOMS\System\File\Ftp\Directory + * @group framework + */ public function testNodeCreate() : void { $dir = new Directory(new HttpUri(self::BASE . __DIR__), '*', true, self::$con); $dir->addNode(new Directory(new HttpUri(self::BASE . __DIR__ . '/nodedir'))); - self::assertTrue(\file_exists(__DIR__ . '/nodedir')); + self::assertTrue(\is_dir(__DIR__ . '/nodedir')); \rmdir(__DIR__ . '/nodedir'); $dir = new Directory(new HttpUri(self::BASE . __DIR__ . '/nodedir2'), '*', true, self::$con); $dir->createNode(); - self::assertTrue(\file_exists(__DIR__ . '/nodedir2')); + self::assertTrue(\is_dir(__DIR__ . '/nodedir2')); \rmdir(__DIR__ . '/nodedir2'); } + /** + * @covers phpOMS\System\File\Ftp\Directory + * @group framework + */ public function testNodeDelete() : void { $dir = new Directory(new HttpUri(self::BASE . __DIR__), '*', true, self::$con); $dir->addNode(new Directory(new HttpUri(self::BASE . __DIR__ . '/nodedir'))); - self::assertTrue(\file_exists(__DIR__ . '/nodedir')); + self::assertTrue(\is_dir(__DIR__ . '/nodedir')); self::assertTrue($dir->getNode('nodedir')->deleteNode()); - self::assertFalse(\file_exists(__DIR__ . '/nodedir')); + self::assertFalse(\is_dir(__DIR__ . '/nodedir')); } + /** + * @covers phpOMS\System\File\Ftp\Directory + * @group framework + */ public function testNodeCopy() : void { $dir = new Directory(new HttpUri(self::BASE . __DIR__), '*', true, self::$con); $dir->addNode(new Directory(new HttpUri(self::BASE . __DIR__ . '/nodedir'))); $dir->getNode('nodedir')->copyNode(__DIR__ . '/nodedir2'); - self::assertTrue(\file_exists(__DIR__ . '/nodedir2')); + self::assertTrue(\is_dir(__DIR__ . '/nodedir2')); \rmdir(__DIR__ . '/nodedir'); \rmdir(__DIR__ . '/nodedir2'); } + /** + * @covers phpOMS\System\File\Ftp\Directory + * @group framework + */ public function testNodeMove() : void { $dir = new Directory(new HttpUri(self::BASE . __DIR__), '*', true, self::$con); $dir->addNode(new Directory(new HttpUri(self::BASE . __DIR__ . '/nodedir'))); $dir->getNode('nodedir')->moveNode(__DIR__ . '/nodedir2'); - self::assertFalse(\file_exists(__DIR__ . '/nodedir')); - self::assertTrue(\file_exists(__DIR__ . '/nodedir2')); + self::assertFalse(\is_dir(__DIR__ . '/nodedir')); + self::assertTrue(\is_dir(__DIR__ . '/nodedir2')); \rmdir(__DIR__ . '/nodedir2'); } + /** + * @covers phpOMS\System\File\Ftp\Directory + * @group framework + */ public function testNodeExists() : void { $dir = new Directory(new HttpUri(self::BASE . __DIR__), '*', true, self::$con); @@ -577,6 +645,10 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase self::assertFalse($dir->isExisting('invalid')); } + /** + * @covers phpOMS\System\File\Ftp\Directory + * @group framework + */ public function testParentOutput() : void { $dir = new Directory(new HttpUri(self::BASE . __DIR__ . '/dirtest'), '*', true, self::$con); @@ -584,6 +656,10 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase self::assertEquals(__DIR__, $dir->getParent()->getPath()); } + /** + * @covers phpOMS\System\File\Ftp\Directory + * @group framework + */ public function testNodeNext() : void { $dir = new Directory(new HttpUri(self::BASE . __DIR__ . '/dirtest'), '*', true, self::$con); @@ -591,6 +667,10 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase self::assertEquals(__DIR__ . '/dirtest/test.txt', $dir->next()->getPath()); } + /** + * @covers phpOMS\System\File\Ftp\Directory + * @group framework + */ public function testNodeCurrent() : void { $dir = new Directory(new HttpUri(self::BASE . __DIR__ . '/dirtest'), '*', true, self::$con); @@ -598,6 +678,10 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase self::assertEquals(__DIR__ . '/dirtest/sub', $dir->current()->getPath()); } + /** + * @covers phpOMS\System\File\Ftp\Directory + * @group framework + */ public function testNodeKey() : void { $dir = new Directory(new HttpUri(self::BASE . __DIR__ . '/dirtest'), '*', true, self::$con); @@ -607,6 +691,10 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase self::assertEquals('test.txt', $dir->key()); } + /** + * @covers phpOMS\System\File\Ftp\Directory + * @group framework + */ public function testNodeArrayRead() : void { $dir = new Directory(new HttpUri(self::BASE . __DIR__ . '/dirtest'), '*', true, self::$con); @@ -614,30 +702,42 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase self::assertEquals('test', $dir['test.txt']->getName()); } + /** + * @covers phpOMS\System\File\Ftp\Directory + * @group framework + */ public function testNodeArraySet() : void { $dir = new Directory(new HttpUri(self::BASE . __DIR__), '*', true, self::$con); $dir[] = new Directory(new HttpUri(self::BASE . __DIR__ . '/nodedir')); - self::assertTrue(\file_exists(__DIR__ . '/nodedir')); + self::assertTrue(\is_dir(__DIR__ . '/nodedir')); \rmdir(__DIR__ . '/nodedir'); $dir['nodedir'] = new Directory(new HttpUri(self::BASE . __DIR__ . '/nodedir')); - self::assertTrue(\file_exists(__DIR__ . '/nodedir')); + self::assertTrue(\is_dir(__DIR__ . '/nodedir')); \rmdir(__DIR__ . '/nodedir'); } + /** + * @covers phpOMS\System\File\Ftp\Directory + * @group framework + */ public function testNodeArrayRemove() : void { $dir = new Directory(new HttpUri(self::BASE . __DIR__), '*', true, self::$con); $dir->addNode(new Directory(new HttpUri(self::BASE . __DIR__ . '/nodedir'))); - self::assertTrue(\file_exists(__DIR__ . '/nodedir')); + self::assertTrue(\is_dir(__DIR__ . '/nodedir')); unset($dir['nodedir']); - self::assertFalse(\file_exists(__DIR__ . '/nodedir')); + self::assertFalse(\is_dir(__DIR__ . '/nodedir')); } + /** + * @covers phpOMS\System\File\Ftp\Directory + * @group framework + */ public function testNodeArrayExists() : void { $dir = new Directory(new HttpUri(self::BASE . __DIR__), '*', true, self::$con); @@ -646,6 +746,10 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase self::assertFalse(isset($dir['invalid'])); } + /** + * @covers phpOMS\System\File\Ftp\Directory + * @group framework + */ public function testNodeCreatedAt() : void { $dirPath = __DIR__ . '/test'; @@ -659,6 +763,10 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase \rmdir($dirPath); } + /** + * @covers phpOMS\System\File\Ftp\Directory + * @group framework + */ public function testNodeChangedAt() : void { $dirPath = __DIR__ . '/test'; @@ -672,6 +780,10 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase \rmdir($dirPath); } + /** + * @covers phpOMS\System\File\Ftp\Directory + * @group framework + */ public function testNodeOwner() : void { $dir = new Directory(new HttpUri(self::BASE . __DIR__ . '/dirtest'), '*', true, self::$con); @@ -679,6 +791,10 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase self::assertNotEmpty($dir->getOwner()); } + /** + * @covers phpOMS\System\File\Ftp\Directory + * @group framework + */ public function testNodePermission() : void { $dir = new Directory(new HttpUri(self::BASE . __DIR__ . '/dirtest'), '*', true, self::$con); @@ -686,6 +802,10 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase self::assertGreaterThan(0, $dir->getPermission()); } + /** + * @covers phpOMS\System\File\Ftp\Directory + * @group framework + */ public function testDirname() : void { $dir = new Directory(new HttpUri(self::BASE . __DIR__ . '/dirtest'), '*', true, self::$con); @@ -693,6 +813,10 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase self::assertEquals('dirtest', $dir->next()->getDirname()); } + /** + * @covers phpOMS\System\File\Ftp\Directory + * @group framework + */ public function testName() : void { $dir = new Directory(new HttpUri(self::BASE . __DIR__ . '/dirtest'), '*', true, self::$con); @@ -700,6 +824,10 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase self::assertEquals('test', $dir->next()->getName()); } + /** + * @covers phpOMS\System\File\Ftp\Directory + * @group framework + */ public function testBaseame() : void { $dir = new Directory(new HttpUri(self::BASE . __DIR__ . '/dirtest'), '*', true, self::$con); @@ -707,6 +835,10 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase self::assertEquals('test.txt', $dir->next()->getBasename()); } + /** + * @covers phpOMS\System\File\Ftp\Directory + * @group framework + */ public function testDirpath() : void { $dir = new Directory(new HttpUri(self::BASE . __DIR__ . '/dirtest'), '*', true, self::$con); diff --git a/tests/System/File/Ftp/FileTest.php b/tests/System/File/Ftp/FileTest.php index 9ba918f5d..58849c827 100644 --- a/tests/System/File/Ftp/FileTest.php +++ b/tests/System/File/Ftp/FileTest.php @@ -44,11 +44,19 @@ class FileTest extends \PHPUnit\Framework\TestCase } } + /** + * @covers phpOMS\System\File\Ftp\File + * @group framework + */ public function testConnection() : void { self::assertNotFalse(File::ftpConnect(new HttpUri(self::BASE . '/test'))); } + /** + * @covers phpOMS\System\File\Ftp\File + * @group framework + */ public function testInvalidConnection() : void { self::assertFalse(File::ftpConnect(new HttpUri('ftp://orange-management.org:21'))); @@ -56,7 +64,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox A file without content can be created - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testStaticCreate() : void @@ -71,7 +79,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox A file cannot be created if it already exists - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testInvalidStaticCreate() : void @@ -86,7 +94,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox A file with content can be created - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testStaticPut() : void @@ -101,43 +109,43 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox A file cannot be replaced if it doesn't exists - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testInvalidStaticCreateReplace() : void { $testFile = __DIR__ . '/test.txt'; self::assertFalse(File::put(self::$con, $testFile, 'test', ContentPutMode::REPLACE)); - self::assertfalse(\file_exists($testFile)); + self::assertfalse(\is_file($testFile)); } /** * @testdox A file cannot be appended if it doesn't exists - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testInvalidStaticCreateAppend() : void { $testFile = __DIR__ . '/test.txt'; self::assertFalse(File::put(self::$con, $testFile, 'test', ContentPutMode::APPEND)); - self::assertfalse(\file_exists($testFile)); + self::assertfalse(\is_file($testFile)); } /** * @testdox A file cannot be prepended if it doesn't exists - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testInvalidStaticCreatePrepend() : void { $testFile = __DIR__ . '/test.txt'; self::assertFalse(File::put(self::$con, $testFile, 'test', ContentPutMode::PREPEND)); - self::assertfalse(\file_exists($testFile)); + self::assertfalse(\is_file($testFile)); } /** * @testdox A file can be checked for existence - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testStaticExists() : void @@ -148,7 +156,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox A file can be replaced with a new one - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testStaticReplace() : void @@ -164,7 +172,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox The set alias works like the replace flag - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testStaticSetAlias() : void @@ -180,7 +188,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox A file can be appended with additional content - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testStaticAppend() : void @@ -196,7 +204,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox The append alias works like the append flag - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testStaticAppendAlias() : void @@ -212,7 +220,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox A file can be prepended with additional content - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testStaticPrepend() : void @@ -228,7 +236,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox The prepend alias works like the prepend flag - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testStaticPrependAlias() : void @@ -244,7 +252,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox The content of a file can be read - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testStaticGet() : void @@ -258,7 +266,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox The parent directory of a file can be returned - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testStaticParent() : void @@ -270,7 +278,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox The extension of a file can be returned - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testStaticExtension() : void @@ -282,7 +290,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox The name of a file can be returned - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testStaticName() : void @@ -294,7 +302,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox The basename of a file can be returned - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testStaticBaseName() : void @@ -306,7 +314,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox The file name of a file can be returned - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testStaticDirname() : void @@ -318,7 +326,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox The file path of a file can be returned - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testStaticDirectoryPath() : void @@ -330,7 +338,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox The count of a file is always 1 - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testStaticCount() : void @@ -342,7 +350,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox The directories creation date can be returned - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testStaticCreatedAt() : void @@ -360,7 +368,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox The directories last change date can be returned - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testStaticChangedAt() : void @@ -378,7 +386,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox A file can be deleted - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testStaticDelete() : void @@ -392,7 +400,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox A none-existing file cannot be deleted - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testInvalidStaticDelete() : void @@ -404,7 +412,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox The size of a file can be returned - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testStaticSize() : void @@ -421,7 +429,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox The permission of a file can be returned - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testStaticPermission() : void @@ -438,7 +446,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox The permission of a none-existing file is negative - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testInvalidStaticPermission() : void @@ -449,7 +457,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox A file can be copied to a different location - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testStaticCopy() : void @@ -472,7 +480,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox A file cannot be copied to a different location if the destination already exists - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testInvalidStaticCopy() : void @@ -492,7 +500,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox A file can be forced to be copied to a different location even if the destination already exists - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testStaticCopyOverwrite() : void @@ -512,7 +520,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox A file can be moved to a different location - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testStaticMove() : void @@ -532,7 +540,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox A file cannot be moved to a different location if the destination already exists - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testInvalidStaticMove() : void @@ -553,7 +561,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox A file can be forced to be moved to a different location even if the destination already exists - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testStaticMoveOverwrite() : void @@ -571,12 +579,20 @@ class FileTest extends \PHPUnit\Framework\TestCase File::delete(self::$con, $newPath); } + /** + * @covers phpOMS\System\File\Ftp\File + * @group framework + */ public function testStaticOwner() : void { $dirTestPath = __DIR__ . '/dirtest/test.txt'; self::assertNotEmpty(File::owner(self::$con, $dirTestPath)); } + /** + * @covers phpOMS\System\File\Ftp\File + * @group framework + */ public function testFileNameSanitizing() : void { self::assertEquals('/some/test/[path.txt', File::sanitize(':#&^$/some%/test/[path!.txt')); @@ -584,7 +600,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox The size of a none-existing file is negative - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testInvalidSizePath() : void @@ -594,7 +610,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox A none-existing file cannot be copied - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testInvalidCopyPath() : void @@ -604,7 +620,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox A none-existing file cannot be moved - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testInvalidMovePath() : void @@ -614,7 +630,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox Reading the content of a none-existing file throws a PathException - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testInvalidGetPath() : void @@ -626,7 +642,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox Reading the created date of a none-existing file throws a PathException - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testInvalidCreatedPath() : void @@ -638,7 +654,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox Reading the last change date of a none-existing file throws a PathException - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testInvalidChangedPath() : void @@ -650,7 +666,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox Reading the owner of a none-existing file throws a PathException - * @covers phpOMS\System\File\Ftp\File + * @covers phpOMS\System\File\Ftp\File * @group framework */ public function testInvalidOwnerPath() : void @@ -660,10 +676,14 @@ class FileTest extends \PHPUnit\Framework\TestCase File::owner(self::$con, __DIR__ . '/invalid.txt'); } + /** + * @covers phpOMS\System\File\Ftp\File + * @group framework + */ public function testNodeInputOutput() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } @@ -674,10 +694,14 @@ class FileTest extends \PHPUnit\Framework\TestCase \unlink($testFile); } + /** + * @covers phpOMS\System\File\Ftp\File + * @group framework + */ public function testNodeReplace() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } @@ -689,10 +713,14 @@ class FileTest extends \PHPUnit\Framework\TestCase \unlink($testFile); } + /** + * @covers phpOMS\System\File\Ftp\File + * @group framework + */ public function testNodeAppend() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } @@ -704,10 +732,14 @@ class FileTest extends \PHPUnit\Framework\TestCase \unlink($testFile); } + /** + * @covers phpOMS\System\File\Ftp\File + * @group framework + */ public function testNodePrepend() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } @@ -719,6 +751,10 @@ class FileTest extends \PHPUnit\Framework\TestCase \unlink($testFile); } + /** + * @covers phpOMS\System\File\Ftp\File + * @group framework + */ public function testNodeExtension() : void { $testFile = __DIR__ . '/test.txt'; @@ -727,10 +763,14 @@ class FileTest extends \PHPUnit\Framework\TestCase self::assertEquals('txt', $file->getExtension()); } + /** + * @covers phpOMS\System\File\Ftp\File + * @group framework + */ public function testNodeCreatedAt() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } @@ -744,10 +784,14 @@ class FileTest extends \PHPUnit\Framework\TestCase \unlink($testFile); } + /** + * @covers phpOMS\System\File\Ftp\File + * @group framework + */ public function testNodeChangedAt() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } @@ -761,6 +805,10 @@ class FileTest extends \PHPUnit\Framework\TestCase \unlink($testFile); } + /** + * @covers phpOMS\System\File\Ftp\File + * @group framework + */ public function testNodeOwner() : void { $testFile = __DIR__ . '/dirtest/test.txt'; @@ -769,6 +817,10 @@ class FileTest extends \PHPUnit\Framework\TestCase self::assertNotEmpty($file->getOwner()); } + /** + * @covers phpOMS\System\File\Ftp\File + * @group framework + */ public function testNodePermission() : void { $testFile = __DIR__ . '/dirtest/test.txt'; @@ -777,6 +829,10 @@ class FileTest extends \PHPUnit\Framework\TestCase self::assertGreaterThan(0, $file->getPermission()); } + /** + * @covers phpOMS\System\File\Ftp\File + * @group framework + */ public function testDirname() : void { $testFile = __DIR__ . '/dirtest/test.txt'; @@ -785,6 +841,10 @@ class FileTest extends \PHPUnit\Framework\TestCase self::assertEquals('dirtest', $file->getDirname()); } + /** + * @covers phpOMS\System\File\Ftp\File + * @group framework + */ public function testName() : void { $testFile = __DIR__ . '/dirtest/test.txt'; @@ -793,6 +853,10 @@ class FileTest extends \PHPUnit\Framework\TestCase self::assertEquals('test', $file->getName()); } + /** + * @covers phpOMS\System\File\Ftp\File + * @group framework + */ public function testBaseame() : void { $testFile = __DIR__ . '/dirtest/test.txt'; @@ -801,6 +865,10 @@ class FileTest extends \PHPUnit\Framework\TestCase self::assertEquals('test.txt', $file->getBasename()); } + /** + * @covers phpOMS\System\File\Ftp\File + * @group framework + */ public function testDirpath() : void { $testFile = __DIR__ . '/dirtest/test.txt'; @@ -809,6 +877,10 @@ class FileTest extends \PHPUnit\Framework\TestCase self::assertEquals(__DIR__ . '/dirtest', $file->getDirPath()); } + /** + * @covers phpOMS\System\File\Ftp\File + * @group framework + */ public function testParentOutput() : void { $testFile = __DIR__ . '/dirtest/test.txt'; @@ -817,40 +889,52 @@ class FileTest extends \PHPUnit\Framework\TestCase self::assertEquals(__DIR__ . '/dirtest', $file->getDirPath()); } + /** + * @covers phpOMS\System\File\Ftp\File + * @group framework + */ public function testNodeCreate() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } $file = new File(new HttpUri(self::BASE . $testFile), self::$con); $file->createNode(); - self::assertTrue(\file_exists($testFile)); + self::assertTrue(\is_file($testFile)); \unlink($testFile); } + /** + * @covers phpOMS\System\File\Ftp\File + * @group framework + */ public function testNodeDelete() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } $file = new File(new HttpUri(self::BASE . $testFile), self::$con); $file->createNode(); - self::assertTrue(\file_exists($testFile)); + self::assertTrue(\is_file($testFile)); self::assertTrue($file->deleteNode()); - self::assertFalse(\file_exists($testFile)); + self::assertFalse(\is_file($testFile)); } + /** + * @covers phpOMS\System\File\Ftp\File + * @group framework + */ public function testNodeCopy() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } @@ -858,17 +942,21 @@ class FileTest extends \PHPUnit\Framework\TestCase $file->createNode(); self::assertTrue($file->copyNode(__DIR__ . '/test2.txt')); - self::assertTrue(\file_exists($testFile)); - self::assertTrue(\file_exists(__DIR__ . '/test2.txt')); + self::assertTrue(\is_file($testFile)); + self::assertTrue(\is_file(__DIR__ . '/test2.txt')); \unlink($testFile); \unlink(__DIR__ . '/test2.txt'); } + /** + * @covers phpOMS\System\File\Ftp\File + * @group framework + */ public function testNodeMove() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } @@ -876,12 +964,16 @@ class FileTest extends \PHPUnit\Framework\TestCase $file->createNode(); self::assertTrue($file->moveNode(__DIR__ . '/test2.txt')); - self::assertFalse(\file_exists($testFile)); - self::assertTrue(\file_exists(__DIR__ . '/test2.txt')); + self::assertFalse(\is_file($testFile)); + self::assertTrue(\is_file(__DIR__ . '/test2.txt')); \unlink(__DIR__ . '/test2.txt'); } + /** + * @covers phpOMS\System\File\Ftp\File + * @group framework + */ public function testNodeExists() : void { $file = new File(new HttpUri(self::BASE . __DIR__ . '/dirtest/test.txt'), self::$con); @@ -891,6 +983,10 @@ class FileTest extends \PHPUnit\Framework\TestCase self::assertFalse($file2->isExisting()); } + /** + * @covers phpOMS\System\File\Ftp\File + * @group framework + */ public function testNodeParent() : void { $file = new File(new HttpUri(self::BASE . __DIR__ . '/dirtest/test.txt'), self::$con); @@ -898,6 +994,10 @@ class FileTest extends \PHPUnit\Framework\TestCase self::assertEquals('Ftp', $file->getParent()->getName()); } + /** + * @covers phpOMS\System\File\Ftp\File + * @group framework + */ public function testNodeDirectory() : void { $file = new File(new HttpUri(self::BASE . __DIR__ . '/dirtest/test.txt'), self::$con); diff --git a/tests/System/File/Ftp/FtpStorageTest.php b/tests/System/File/Ftp/FtpStorageTest.php index 856152851..b6a7d443b 100644 --- a/tests/System/File/Ftp/FtpStorageTest.php +++ b/tests/System/File/Ftp/FtpStorageTest.php @@ -474,7 +474,7 @@ class FtpStorageTest extends \PHPUnit\Framework\TestCase { $testFile = __DIR__ . '/test.txt'; self::assertFalse(FtpStorage::put($testFile, 'test', ContentPutMode::REPLACE)); - self::assertfalse(\file_exists($testFile)); + self::assertfalse(\is_file($testFile)); } /** @@ -486,7 +486,7 @@ class FtpStorageTest extends \PHPUnit\Framework\TestCase { $testFile = __DIR__ . '/test.txt'; self::assertFalse(FtpStorage::put($testFile, 'test', ContentPutMode::APPEND)); - self::assertfalse(\file_exists($testFile)); + self::assertfalse(\is_file($testFile)); } /** @@ -498,7 +498,7 @@ class FtpStorageTest extends \PHPUnit\Framework\TestCase { $testFile = __DIR__ . '/test.txt'; self::assertFalse(FtpStorage::put($testFile, 'test', ContentPutMode::PREPEND)); - self::assertfalse(\file_exists($testFile)); + self::assertfalse(\is_file($testFile)); } /** @@ -932,6 +932,10 @@ class FtpStorageTest extends \PHPUnit\Framework\TestCase File::delete(self::$con, $newPath); } + /** + * @covers phpOMS\System\File\Ftp\FtpStorage + * @group framework + */ public function testSanitize() : void { self::assertEquals(':/some/test/[path', FtpStorage::sanitize(':#&^$/some%/test/[path!')); diff --git a/tests/System/File/Local/DirectoryTest.php b/tests/System/File/Local/DirectoryTest.php index f1aedfd75..ad6421abf 100644 --- a/tests/System/File/Local/DirectoryTest.php +++ b/tests/System/File/Local/DirectoryTest.php @@ -25,7 +25,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase { /** * @testdox A directory can be created - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testStaticCreate() : void @@ -39,7 +39,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox A directory can be checked for existence - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testStaticExists() : void @@ -50,7 +50,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox An existing directory cannot be overwritten - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testInvalidStaticOverwrite() : void @@ -64,7 +64,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox A directory can be forced to be created recursively - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testStaticSubdir() : void @@ -80,7 +80,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox By default a directory is not created recursively - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testInvalidStaticSubdir() : void @@ -90,7 +90,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox The name of a directory is just its name without its path - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testStaticName() : void @@ -102,7 +102,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox The basename is the same as the name of the directory - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testStaticBasename() : void @@ -114,7 +114,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox The dirname is the same as the name of the directory - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testStaticDirname() : void @@ -126,7 +126,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox The parent of a directory can be returned - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testStaticParent() : void @@ -138,7 +138,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox The full absolute path of a directory can be returned - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testStaticDirectoryPath() : void @@ -150,7 +150,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox The directories creation date can be returned - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testStaticCreatedAt() : void @@ -167,7 +167,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox The directories last change date can be returned - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testStaticChangedAt() : void @@ -184,7 +184,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox A directory can be deleted - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testStaticDelete() : void @@ -198,7 +198,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox A none-existing directory cannot be deleted - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testInvalidStaticDelete() : void @@ -210,7 +210,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox The size of a directory can be returned - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testStaticSizeRecursive() : void @@ -221,7 +221,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox The size of a none-existing directory is negative - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testInvalidStaticSizeRecursive() : void @@ -232,7 +232,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox The recursive size of a directory is equals or greater than the size of the same directory none-recursive - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testStaticSize() : void @@ -243,7 +243,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox The permission of a directory can be returned - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testStaticPermission() : void @@ -254,7 +254,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox The permission of a none-existing directory is negative - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testInvalidStaticPermission() : void @@ -265,7 +265,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox A directory can be copied recursively - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testStaticCopy() : void @@ -279,7 +279,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox A directory can be forced to be copied to a different location even if the destination already exists - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testStaticCopyOverwrite() : void @@ -295,7 +295,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox By default a directory is not overwritten on copy - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testStaticInvalidCopyOverwrite() : void @@ -309,7 +309,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox A directory can be moved/renamed to a different path - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testStaticMove() : void @@ -325,7 +325,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox By default a directory is not overwritten on move - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testStaticInvalidMoveOverwrite() : void @@ -340,7 +340,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox A directory can be forced to be moved/renamed to a different path even if the destination already exists - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testStaticMoveOverwrite() : void @@ -358,7 +358,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox The amount of files in a directory can be returned recursively - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testStaticCountRecursive() : void @@ -369,7 +369,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox The amount of files in a directory can be returned none-recursively - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testStaticCount() : void @@ -380,7 +380,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox The amount of files of a none-existing directory is negative - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testInvalidStaticCount() : void @@ -391,7 +391,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox All files and sub-directories of a directory can be listed - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testStaticListFiles() : void @@ -405,7 +405,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox All files of a directory can be listed by file extension - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testStaticListFilesByExtension() : void @@ -416,7 +416,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox The owner of a directory can be returned - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testStaticOwner() : void @@ -427,7 +427,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox Invalid directory names and paths can be sanitized - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testDirectoryNameSanitizing() : void @@ -437,7 +437,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox A none-existing directory returns a empty list of files and sub-directories - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testInvalidListPath() : void @@ -447,7 +447,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox A none-existing directory returns a empty list of files for the extension - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testInvalidListFilesByExtension() : void @@ -457,7 +457,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox A invalid directory cannot be copied to a new destination - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testInvalidCopyPath() : void @@ -467,7 +467,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox A invalid directory cannot be moved to a new destination - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testInvalidMovePath() : void @@ -477,7 +477,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox Reading the creation date of a none-existing directory throws a PathException - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testInvalidCreatedPath() : void @@ -489,7 +489,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox Reading the last change date of a none-existing directory throws a PathException - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testInvalidChangedPath() : void @@ -501,7 +501,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase /** * @testdox Reading the owner of a none-existing directory throws a PathException - * @covers phpOMS\System\File\Local\Directory + * @covers phpOMS\System\File\Local\Directory * @group framework */ public function testInvalidOwnerPath() : void @@ -511,6 +511,10 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase Directory::owner(__DIR__ . '/invalid'); } + /** + * @covers phpOMS\System\File\Local\Directory + * @group framework + */ public function testList() : void { $dirTestPath = __DIR__ . '/dirtest'; @@ -522,6 +526,10 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase ], $dir->getList()); } + /** + * @covers phpOMS\System\File\Local\Directory + * @group framework + */ public function testNodeOutput() : void { $dirTestPath = __DIR__ . '/dirtest'; @@ -530,55 +538,75 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase self::assertInstanceOf(Directory::class, $dir->getNode('sub')); } + /** + * @covers phpOMS\System\File\Local\Directory + * @group framework + */ public function testNodeCreate() : void { $dir = new Directory(__DIR__); $dir->addNode(new Directory(__DIR__ . '/nodedir')); - self::assertTrue(\file_exists(__DIR__ . '/nodedir')); + self::assertTrue(\is_dir(__DIR__ . '/nodedir')); \rmdir(__DIR__ . '/nodedir'); $dir = new Directory(__DIR__ . '/nodedir2'); $dir->createNode(); - self::assertTrue(\file_exists(__DIR__ . '/nodedir2')); + self::assertTrue(\is_dir(__DIR__ . '/nodedir2')); \rmdir(__DIR__ . '/nodedir2'); } + /** + * @covers phpOMS\System\File\Local\Directory + * @group framework + */ public function testNodeDelete() : void { $dir = new Directory(__DIR__); $dir->addNode(new Directory(__DIR__ . '/nodedir')); - self::assertTrue(\file_exists(__DIR__ . '/nodedir')); + self::assertTrue(\is_dir(__DIR__ . '/nodedir')); self::assertTrue($dir->getNode('nodedir')->deleteNode()); - self::assertFalse(\file_exists(__DIR__ . '/nodedir')); + self::assertFalse(\is_dir(__DIR__ . '/nodedir')); } + /** + * @covers phpOMS\System\File\Local\Directory + * @group framework + */ public function testNodeCopy() : void { $dir = new Directory(__DIR__); $dir->addNode(new Directory(__DIR__ . '/nodedir')); $dir->getNode('nodedir')->copyNode(__DIR__ . '/nodedir2'); - self::assertTrue(\file_exists(__DIR__ . '/nodedir2')); + self::assertTrue(\is_dir(__DIR__ . '/nodedir2')); \rmdir(__DIR__ . '/nodedir'); \rmdir(__DIR__ . '/nodedir2'); } + /** + * @covers phpOMS\System\File\Local\Directory + * @group framework + */ public function testNodeMove() : void { $dir = new Directory(__DIR__); $dir->addNode(new Directory(__DIR__ . '/nodedir')); $dir->getNode('nodedir')->moveNode(__DIR__ . '/nodedir2'); - self::assertFalse(\file_exists(__DIR__ . '/nodedir')); - self::assertTrue(\file_exists(__DIR__ . '/nodedir2')); + self::assertFalse(\is_dir(__DIR__ . '/nodedir')); + self::assertTrue(\is_dir(__DIR__ . '/nodedir2')); \rmdir(__DIR__ . '/nodedir2'); } + /** + * @covers phpOMS\System\File\Local\Directory + * @group framework + */ public function testNodeExists() : void { $dir = new Directory(__DIR__); @@ -588,6 +616,10 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase self::assertFalse($dir->isExisting('invalid')); } + /** + * @covers phpOMS\System\File\Local\Directory + * @group framework + */ public function testParentOutput() : void { $dir = new Directory(__DIR__ . '/dirtest'); @@ -595,6 +627,10 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase self::assertEquals(__DIR__, $dir->getParent()->getPath()); } + /** + * @covers phpOMS\System\File\Local\Directory + * @group framework + */ public function testNodeNext() : void { $dir = new Directory(__DIR__ . '/dirtest'); @@ -602,6 +638,10 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase self::assertEquals(__DIR__ . '/dirtest/test.txt', $dir->next()->getPath()); } + /** + * @covers phpOMS\System\File\Local\Directory + * @group framework + */ public function testNodeCurrent() : void { $dir = new Directory(__DIR__ . '/dirtest'); @@ -609,6 +649,10 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase self::assertEquals(__DIR__ . '/dirtest/sub', $dir->current()->getPath()); } + /** + * @covers phpOMS\System\File\Local\Directory + * @group framework + */ public function testNodeKey() : void { $dir = new Directory(__DIR__ . '/dirtest'); @@ -618,6 +662,10 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase self::assertEquals('test.txt', $dir->key()); } + /** + * @covers phpOMS\System\File\Local\Directory + * @group framework + */ public function testNodeArrayRead() : void { $dir = new Directory(__DIR__ . '/dirtest'); @@ -625,30 +673,42 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase self::assertEquals('test', $dir['test.txt']->getName()); } + /** + * @covers phpOMS\System\File\Local\Directory + * @group framework + */ public function testNodeArraySet() : void { $dir = new Directory(__DIR__); $dir[] = new Directory(__DIR__ . '/nodedir'); - self::assertTrue(\file_exists(__DIR__ . '/nodedir')); + self::assertTrue(\is_dir(__DIR__ . '/nodedir')); \rmdir(__DIR__ . '/nodedir'); $dir['nodedir'] = new Directory(__DIR__ . '/nodedir'); - self::assertTrue(\file_exists(__DIR__ . '/nodedir')); + self::assertTrue(\is_dir(__DIR__ . '/nodedir')); \rmdir(__DIR__ . '/nodedir'); } + /** + * @covers phpOMS\System\File\Local\Directory + * @group framework + */ public function testNodeArrayRemove() : void { $dir = new Directory(__DIR__); $dir->addNode(new Directory(__DIR__ . '/nodedir')); - self::assertTrue(\file_exists(__DIR__ . '/nodedir')); + self::assertTrue(\is_dir(__DIR__ . '/nodedir')); unset($dir['nodedir']); - self::assertFalse(\file_exists(__DIR__ . '/nodedir')); + self::assertFalse(\is_dir(__DIR__ . '/nodedir')); } + /** + * @covers phpOMS\System\File\Local\Directory + * @group framework + */ public function testNodeArrayExists() : void { $dir = new Directory(__DIR__); @@ -657,6 +717,10 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase self::assertFalse(isset($dir['invalid'])); } + /** + * @covers phpOMS\System\File\Local\Directory + * @group framework + */ public function testNodeCreatedAt() : void { $dirPath = __DIR__ . '/test'; @@ -670,6 +734,10 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase \rmdir($dirPath); } + /** + * @covers phpOMS\System\File\Local\Directory + * @group framework + */ public function testNodeChangedAt() : void { $dirPath = __DIR__ . '/test'; @@ -683,6 +751,10 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase \rmdir($dirPath); } + /** + * @covers phpOMS\System\File\Local\Directory + * @group framework + */ public function testNodeOwner() : void { $dir = new Directory(__DIR__ . '/dirtest'); @@ -690,6 +762,10 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase self::assertNotEmpty($dir->getOwner()); } + /** + * @covers phpOMS\System\File\Local\Directory + * @group framework + */ public function testNodePermission() : void { $dir = new Directory(__DIR__ . '/dirtest'); @@ -697,6 +773,10 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase self::assertGreaterThan(0, $dir->getPermission()); } + /** + * @covers phpOMS\System\File\Local\Directory + * @group framework + */ public function testDirname() : void { $dir = new Directory(__DIR__ . '/dirtest'); @@ -704,6 +784,10 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase self::assertEquals('dirtest', $dir->next()->getDirName()); } + /** + * @covers phpOMS\System\File\Local\Directory + * @group framework + */ public function testName() : void { $dir = new Directory(__DIR__ . '/dirtest'); @@ -711,6 +795,10 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase self::assertEquals('test', $dir->next()->getName()); } + /** + * @covers phpOMS\System\File\Local\Directory + * @group framework + */ public function testBaseame() : void { $dir = new Directory(__DIR__ . '/dirtest'); @@ -718,6 +806,10 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase self::assertEquals('test.txt', $dir->next()->getBasename()); } + /** + * @covers phpOMS\System\File\Local\Directory + * @group framework + */ public function testDirpath() : void { $dir = new Directory(__DIR__ . '/dirtest'); diff --git a/tests/System/File/Local/FileTest.php b/tests/System/File/Local/FileTest.php index d8e3b047a..d2ff711df 100644 --- a/tests/System/File/Local/FileTest.php +++ b/tests/System/File/Local/FileTest.php @@ -26,17 +26,17 @@ class FileTest extends \PHPUnit\Framework\TestCase { /** * @testdox A file without content can be created - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testStaticCreate() : void { $testFile = __DIR__ . '/path/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } - if (\file_exists(__DIR__ . '/path')) { + if (\is_file(__DIR__ . '/path')) { \rmdir(__DIR__ . '/path'); } @@ -50,13 +50,13 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox A file cannot be created if it already exists - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testInvalidStaticCreate() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } @@ -69,17 +69,17 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox A file with content can be created - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testStaticPut() : void { $testFile = __DIR__ . '/path/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } - if (\file_exists(__DIR__ . '/path')) { + if (\is_file(__DIR__ . '/path')) { \rmdir(__DIR__ . '/path'); } @@ -93,55 +93,55 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox A file cannot be replaced if it doesn't exists - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testInvalidStaticCreateReplace() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } self::assertFalse(File::put($testFile, 'test', ContentPutMode::REPLACE)); - self::assertfalse(\file_exists($testFile)); + self::assertfalse(\is_file($testFile)); } /** * @testdox A file cannot be appended if it doesn't exists - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testInvalidStaticCreateAppend() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } self::assertFalse(File::put($testFile, 'test', ContentPutMode::APPEND)); - self::assertfalse(\file_exists($testFile)); + self::assertfalse(\is_file($testFile)); } /** * @testdox A file cannot be prepended if it doesn't exists - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testInvalidStaticCreatePrepend() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } self::assertFalse(File::put($testFile, 'test', ContentPutMode::PREPEND)); - self::assertfalse(\file_exists($testFile)); + self::assertfalse(\is_file($testFile)); } /** * @testdox A file can be checked for existence - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testStaticExists() : void @@ -152,13 +152,13 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox A file can be replaced with a new one - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testStaticReplace() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } @@ -172,13 +172,13 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox The set alias works like the replace flag - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testStaticSetAlias() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } @@ -192,13 +192,13 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox A file can be appended with additional content - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testStaticAppend() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } @@ -212,13 +212,13 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox The append alias works like the append flag - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testStaticAppendAlias() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } @@ -232,13 +232,13 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox A file can be prepended with additional content - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testStaticPrepend() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } @@ -252,13 +252,13 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox The prepend alias works like the prepend flag - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testStaticPrependAlias() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } @@ -272,13 +272,13 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox The content of a file can be read - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testStaticGet() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } @@ -290,7 +290,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox The parent directory of a file can be returned - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testStaticParent() : void @@ -302,7 +302,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox The extension of a file can be returned - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testStaticExtension() : void @@ -314,7 +314,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox The name of a file can be returned - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testStaticName() : void @@ -326,7 +326,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox The basename of a file can be returned - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testStaticBaseName() : void @@ -338,7 +338,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox The file name of a file can be returned - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testStaticDirname() : void @@ -350,7 +350,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox The file path of a file can be returned - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testStaticDirectoryPath() : void @@ -362,7 +362,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox The count of a file is always 1 - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testStaticCount() : void @@ -374,7 +374,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox The directories creation date can be returned - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testStaticCreatedAt() : void @@ -390,7 +390,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox The directories last change date can be returned - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testStaticChangedAt() : void @@ -406,7 +406,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox A file can be deleted - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testStaticDelete() : void @@ -420,7 +420,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox A none-existing file cannot be deleted - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testInvalidStaticDelete() : void @@ -432,13 +432,13 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox The size of a file can be returned - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testStaticSize() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } @@ -451,13 +451,13 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox The permission of a file can be returned - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testStaticPermission() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } @@ -470,7 +470,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox The permission of a none-existing file is negative - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testInvalidStaticPermission() : void @@ -479,6 +479,10 @@ class FileTest extends \PHPUnit\Framework\TestCase self::assertEquals(-1, File::permission($testFile)); } + /** + * @covers phpOMS\System\File\Local\File + * @group framework + */ public function testPathInfo() : void { $testFile = __DIR__ . '/test.txt'; @@ -494,13 +498,13 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox A file can be copied to a different location - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testStaticCopy() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } @@ -521,18 +525,18 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox A file cannot be copied to a different location if the destination already exists - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testInvalidStaticCopy() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } $newPath = __DIR__ . '/test2.txt'; - if (\file_exists($newPath)) { + if (\is_file($newPath)) { \unlink($newPath); } @@ -548,18 +552,18 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox A file can be forced to be copied to a different location even if the destination already exists - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testStaticCopyOverwrite() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } $newPath = __DIR__ . '/test2.txt'; - if (\file_exists($newPath)) { + if (\is_file($newPath)) { \unlink($newPath); } @@ -575,13 +579,13 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox A file can be moved to a different location - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testStaticMove() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } @@ -601,13 +605,13 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox A file cannot be moved to a different location if the destination already exists - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testInvalidStaticMove() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } @@ -626,13 +630,13 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox A file can be forced to be moved to a different location even if the destination already exists - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testStaticMoveOverwrite() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } @@ -648,12 +652,20 @@ class FileTest extends \PHPUnit\Framework\TestCase \unlink($newPath); } + /** + * @covers phpOMS\System\File\Local\File + * @group framework + */ public function testStaticOwner() : void { $dirTestPath = __DIR__ . '/dirtest/test.txt'; self::assertNotEmpty(File::owner($dirTestPath)); } + /** + * @covers phpOMS\System\File\Local\File + * @group framework + */ public function testFileNameSanitizing() : void { self::assertEquals('/some/test/[path.txt', File::sanitize(':#&^$/some%/test/[path!.txt')); @@ -661,7 +673,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox The size of a none-existing file is negative - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testInvalidSizePath() : void @@ -671,7 +683,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox A none-existing file cannot be copied - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testInvalidCopyPath() : void @@ -681,7 +693,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox A none-existing file cannot be moved - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testInvalidMovePath() : void @@ -691,7 +703,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox Reading the content of a none-existing file throws a PathException - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testInvalidGetPath() : void @@ -703,7 +715,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox Reading the created date of a none-existing file throws a PathException - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testInvalidCreatedPath() : void @@ -715,7 +727,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox Reading the last change date of a none-existing file throws a PathException - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testInvalidChangedPath() : void @@ -727,7 +739,7 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @testdox Reading the owner of a none-existing file throws a PathException - * @covers phpOMS\System\File\Local\File + * @covers phpOMS\System\File\Local\File * @group framework */ public function testInvalidOwnerPath() : void @@ -737,10 +749,14 @@ class FileTest extends \PHPUnit\Framework\TestCase File::owner(__DIR__ . '/invalid.txt'); } + /** + * @covers phpOMS\System\File\Local\File + * @group framework + */ public function testNodeInputOutput() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } @@ -751,10 +767,14 @@ class FileTest extends \PHPUnit\Framework\TestCase \unlink($testFile); } + /** + * @covers phpOMS\System\File\Local\File + * @group framework + */ public function testNodeReplace() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } @@ -766,10 +786,14 @@ class FileTest extends \PHPUnit\Framework\TestCase \unlink($testFile); } + /** + * @covers phpOMS\System\File\Local\File + * @group framework + */ public function testNodeAppend() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } @@ -781,10 +805,14 @@ class FileTest extends \PHPUnit\Framework\TestCase \unlink($testFile); } + /** + * @covers phpOMS\System\File\Local\File + * @group framework + */ public function testNodePrepend() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } @@ -796,6 +824,10 @@ class FileTest extends \PHPUnit\Framework\TestCase \unlink($testFile); } + /** + * @covers phpOMS\System\File\Local\File + * @group framework + */ public function testNodeExtension() : void { $testFile = __DIR__ . '/test.txt'; @@ -804,10 +836,14 @@ class FileTest extends \PHPUnit\Framework\TestCase self::assertEquals('txt', $file->getExtension()); } + /** + * @covers phpOMS\System\File\Local\File + * @group framework + */ public function testNodeCreatedAt() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } @@ -821,10 +857,14 @@ class FileTest extends \PHPUnit\Framework\TestCase \unlink($testFile); } + /** + * @covers phpOMS\System\File\Local\File + * @group framework + */ public function testNodeChangedAt() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } @@ -838,6 +878,10 @@ class FileTest extends \PHPUnit\Framework\TestCase \unlink($testFile); } + /** + * @covers phpOMS\System\File\Local\File + * @group framework + */ public function testNodeOwner() : void { $testFile = __DIR__ . '/dirtest/test.txt'; @@ -846,6 +890,10 @@ class FileTest extends \PHPUnit\Framework\TestCase self::assertNotEmpty($file->getOwner()); } + /** + * @covers phpOMS\System\File\Local\File + * @group framework + */ public function testNodePermission() : void { $testFile = __DIR__ . '/dirtest/test.txt'; @@ -854,6 +902,10 @@ class FileTest extends \PHPUnit\Framework\TestCase self::assertGreaterThan(0, $file->getPermission()); } + /** + * @covers phpOMS\System\File\Local\File + * @group framework + */ public function testDirname() : void { $testFile = __DIR__ . '/dirtest/test.txt'; @@ -862,6 +914,10 @@ class FileTest extends \PHPUnit\Framework\TestCase self::assertEquals('dirtest', $file->getDirname()); } + /** + * @covers phpOMS\System\File\Local\File + * @group framework + */ public function testName() : void { $testFile = __DIR__ . '/dirtest/test.txt'; @@ -870,6 +926,10 @@ class FileTest extends \PHPUnit\Framework\TestCase self::assertEquals('test', $file->getName()); } + /** + * @covers phpOMS\System\File\Local\File + * @group framework + */ public function testBaseame() : void { $testFile = __DIR__ . '/dirtest/test.txt'; @@ -878,6 +938,10 @@ class FileTest extends \PHPUnit\Framework\TestCase self::assertEquals('test.txt', $file->getBasename()); } + /** + * @covers phpOMS\System\File\Local\File + * @group framework + */ public function testDirpath() : void { $testFile = __DIR__ . '/dirtest/test.txt'; @@ -886,6 +950,10 @@ class FileTest extends \PHPUnit\Framework\TestCase self::assertEquals(__DIR__ . '/dirtest', $file->getDirPath()); } + /** + * @covers phpOMS\System\File\Local\File + * @group framework + */ public function testParentOutput() : void { $testFile = __DIR__ . '/dirtest/test.txt'; @@ -894,40 +962,52 @@ class FileTest extends \PHPUnit\Framework\TestCase self::assertEquals(__DIR__ . '/dirtest', $file->getDirPath()); } + /** + * @covers phpOMS\System\File\Local\File + * @group framework + */ public function testNodeCreate() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } $file = new File($testFile); $file->createNode(); - self::assertTrue(\file_exists($testFile)); + self::assertTrue(\is_file($testFile)); \unlink($testFile); } + /** + * @covers phpOMS\System\File\Local\File + * @group framework + */ public function testNodeDelete() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } $file = new File($testFile); $file->createNode(); - self::assertTrue(\file_exists($testFile)); + self::assertTrue(\is_file($testFile)); self::assertTrue($file->deleteNode()); - self::assertFalse(\file_exists($testFile)); + self::assertFalse(\is_file($testFile)); } + /** + * @covers phpOMS\System\File\Local\File + * @group framework + */ public function testNodeCopy() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } @@ -935,17 +1015,21 @@ class FileTest extends \PHPUnit\Framework\TestCase $file->createNode(); self::assertTrue($file->copyNode(__DIR__ . '/test2.txt')); - self::assertTrue(\file_exists($testFile)); - self::assertTrue(\file_exists(__DIR__ . '/test2.txt')); + self::assertTrue(\is_file($testFile)); + self::assertTrue(\is_file(__DIR__ . '/test2.txt')); \unlink($testFile); \unlink(__DIR__ . '/test2.txt'); } + /** + * @covers phpOMS\System\File\Local\File + * @group framework + */ public function testNodeMove() : void { $testFile = __DIR__ . '/test.txt'; - if (\file_exists($testFile)) { + if (\is_file($testFile)) { \unlink($testFile); } @@ -953,12 +1037,16 @@ class FileTest extends \PHPUnit\Framework\TestCase $file->createNode(); self::assertTrue($file->moveNode(__DIR__ . '/test2.txt')); - self::assertFalse(\file_exists($testFile)); - self::assertTrue(\file_exists(__DIR__ . '/test2.txt')); + self::assertFalse(\is_file($testFile)); + self::assertTrue(\is_file(__DIR__ . '/test2.txt')); \unlink(__DIR__ . '/test2.txt'); } + /** + * @covers phpOMS\System\File\Local\File + * @group framework + */ public function testNodeExists() : void { $file = new File(__DIR__ . '/dirtest/test.txt'); @@ -968,6 +1056,10 @@ class FileTest extends \PHPUnit\Framework\TestCase self::assertFalse($file2->isExisting()); } + /** + * @covers phpOMS\System\File\Local\File + * @group framework + */ public function testNodeParent() : void { $file = new File(__DIR__ . '/dirtest/test.txt'); @@ -975,6 +1067,10 @@ class FileTest extends \PHPUnit\Framework\TestCase self::assertEquals('Local', $file->getParent()->getName()); } + /** + * @covers phpOMS\System\File\Local\File + * @group framework + */ public function testNodeDirectory() : void { $file = new File(__DIR__ . '/dirtest/test.txt'); diff --git a/tests/System/File/Local/LocalStorageTest.php b/tests/System/File/Local/LocalStorageTest.php index 10aaaced2..ae5b29a0c 100644 --- a/tests/System/File/Local/LocalStorageTest.php +++ b/tests/System/File/Local/LocalStorageTest.php @@ -447,7 +447,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase { $testFile = __DIR__ . '/test.txt'; self::assertFalse(LocalStorage::put($testFile, 'test', ContentPutMode::REPLACE)); - self::assertfalse(\file_exists($testFile)); + self::assertfalse(\is_file($testFile)); } /** @@ -459,7 +459,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase { $testFile = __DIR__ . '/test.txt'; self::assertFalse(LocalStorage::put($testFile, 'test', ContentPutMode::APPEND)); - self::assertfalse(\file_exists($testFile)); + self::assertfalse(\is_file($testFile)); } /** @@ -471,7 +471,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase { $testFile = __DIR__ . '/test.txt'; self::assertFalse(LocalStorage::put($testFile, 'test', ContentPutMode::PREPEND)); - self::assertfalse(\file_exists($testFile)); + self::assertfalse(\is_file($testFile)); } /** @@ -904,6 +904,10 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase \unlink($newPath); } + /** + * @covers phpOMS\System\File\Local\LocalStorage + * @group framework + */ public function testSanitize() : void { self::assertEquals(':/some/test/[path', LocalStorage::sanitize(':#&^$/some%/test/[path!')); diff --git a/tests/System/File/PermissionExceptionTest.php b/tests/System/File/PermissionExceptionTest.php index 60ecef9fa..5f7e469c5 100644 --- a/tests/System/File/PermissionExceptionTest.php +++ b/tests/System/File/PermissionExceptionTest.php @@ -21,6 +21,10 @@ use phpOMS\System\File\PermissionException; */ class PermissionExceptionTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\System\File\PermissionException + * @group framework + */ public function testConstructor() : void { $e = new PermissionException('test.file'); diff --git a/tests/System/OperatingSystemTest.php b/tests/System/OperatingSystemTest.php index 8258f1b93..d449b19bc 100644 --- a/tests/System/OperatingSystemTest.php +++ b/tests/System/OperatingSystemTest.php @@ -24,6 +24,10 @@ use phpOMS\System\SystemType; */ class OperatingSystemTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\System\OperatingSystem + * @group framework + */ public function testSystem() : void { self::assertNotEquals(SystemType::UNKNOWN, OperatingSystem::getSystem()); diff --git a/tests/System/Search/StringSearchTest.php b/tests/System/Search/StringSearchTest.php index 5623842bd..f5d27cc2c 100644 --- a/tests/System/Search/StringSearchTest.php +++ b/tests/System/Search/StringSearchTest.php @@ -23,31 +23,55 @@ use phpOMS\System\Search\StringSearch; */ class StringSearchTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\System\Search\StringSearch + * @group framework + */ public function testKnutMorrisPrattSearch() : void { self::assertEquals(15, StringSearch::knuthMorrisPrattSearch('ABCDABD', 'ABC ABCDAB ABCDABCDABDE')); } + /** + * @covers phpOMS\System\Search\StringSearch + * @group framework + */ public function testInvalidKnutMorrisPrattSearch() : void { self::assertEquals(-1, StringSearch::knuthMorrisPrattSearch('ABCDABDZ', 'ABC ABCDAB ABCDABCDABDE')); } + /** + * @covers phpOMS\System\Search\StringSearch + * @group framework + */ public function testBoyerMooreHorspoolSimpleSearch() : void { self::assertEquals(15, StringSearch::boyerMooreHorspoolSimpleSearch('ABCDABD', 'ABC ABCDAB ABCDABCDABDE')); } + /** + * @covers phpOMS\System\Search\StringSearch + * @group framework + */ public function testInvalidBoyerMooreHorspoolSimpleSearch() : void { self::assertEquals(-1, StringSearch::boyerMooreHorspoolSimpleSearch('ABCDABDZ', 'ABC ABCDAB ABCDABCDABDE')); } + /** + * @covers phpOMS\System\Search\StringSearch + * @group framework + */ public function testBoyerMooreHorspoolSearch() : void { self::assertEquals(15, StringSearch::boyerMooreHorspoolSearch('ABCDABD', 'ABC ABCDAB ABCDABCDABDE')); } + /** + * @covers phpOMS\System\Search\StringSearch + * @group framework + */ public function testInvalidBoyerMooreHorspoolSearch() : void { self::assertEquals(-1, StringSearch::boyerMooreHorspoolSearch('ABCDABDZ', 'ABC ABCDAB ABCDABCDABDE')); diff --git a/tests/Uri/ArgumentTest.php b/tests/Uri/ArgumentTest.php index e600f76b0..bf3ea41b0 100644 --- a/tests/Uri/ArgumentTest.php +++ b/tests/Uri/ArgumentTest.php @@ -77,6 +77,10 @@ class ArgumentTest extends \PHPUnit\Framework\TestCase ); } + /** + * @covers phpOMS\Uri\Argument + * @group framework + */ public function testPathInputOutput() : void { $obj = new Argument(':modules/admin/test/path.php ?para1=abc ?para2=2 #frag'); @@ -85,6 +89,10 @@ class ArgumentTest extends \PHPUnit\Framework\TestCase self::assertEquals('modules/admin/new/path', $obj->getPath()); } + /** + * @covers phpOMS\Uri\Argument + * @group framework + */ public function testSchemeInputOutput() : void { $obj = new Argument(':modules/admin/test/path.php ?para1=abc ?para2=2 #frag'); @@ -93,6 +101,10 @@ class ArgumentTest extends \PHPUnit\Framework\TestCase self::assertEquals('scheme', $obj->getScheme()); } + /** + * @covers phpOMS\Uri\Argument + * @group framework + */ public function testUserInputOutput() : void { $obj = new Argument(':modules/admin/test/path.php ?para1=abc ?para2=2 #frag'); @@ -101,6 +113,10 @@ class ArgumentTest extends \PHPUnit\Framework\TestCase self::assertEquals('user', $obj->getUser()); } + /** + * @covers phpOMS\Uri\Argument + * @group framework + */ public function testPassInputOutput() : void { $obj = new Argument(':modules/admin/test/path.php ?para1=abc ?para2=2 #frag'); @@ -109,6 +125,10 @@ class ArgumentTest extends \PHPUnit\Framework\TestCase self::assertEquals('pass', $obj->getPass()); } + /** + * @covers phpOMS\Uri\Argument + * @group framework + */ public function testHostInputOutput() : void { $obj = new Argument(':modules/admin/test/path.php ?para1=abc ?para2=2 #frag'); @@ -117,6 +137,10 @@ class ArgumentTest extends \PHPUnit\Framework\TestCase self::assertEquals('host', $obj->getHost()); } + /** + * @covers phpOMS\Uri\Argument + * @group framework + */ public function testPortInputOutput() : void { $obj = new Argument(':modules/admin/test/path.php ?para1=abc ?para2=2 #frag'); diff --git a/tests/Uri/HttpUriTest.php b/tests/Uri/HttpUriTest.php index 6419bed56..84e6cd991 100644 --- a/tests/Uri/HttpUriTest.php +++ b/tests/Uri/HttpUriTest.php @@ -70,6 +70,10 @@ class HttpUriTest extends \PHPUnit\Framework\TestCase self::assertEquals('ftp', $obj->getScheme()); } + /** + * @covers phpOMS\Uri\HttpUri + * @group framework + */ public function testPortInputOutput() : void { $obj = new HttpUri('https://www.google.com:21/test/path.php?para1=abc¶2=2#frag'); @@ -186,6 +190,10 @@ class HttpUriTest extends \PHPUnit\Framework\TestCase self::assertEquals('a', $obj->getRootPath()); } + /** + * @covers phpOMS\Uri\HttpUri + * @group framework + */ public function testPathInputOutput() : void { $obj = new HttpUri('https://www.google.com/test/path.php?para1=abc¶2=2#frag'); diff --git a/tests/Uri/InvalidUriExceptionTest.php b/tests/Uri/InvalidUriExceptionTest.php index d43324d00..3434cd0ac 100644 --- a/tests/Uri/InvalidUriExceptionTest.php +++ b/tests/Uri/InvalidUriExceptionTest.php @@ -23,6 +23,10 @@ use phpOMS\Uri\InvalidUriException; */ class InvalidUriExceptionTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\Uri\InvalidUriException + * @group framework + */ public function testException() : void { self::assertInstanceOf(\UnexpectedValueException::class, new InvalidUriException('')); diff --git a/tests/Utils/Barcode/C128AbstractTest.php b/tests/Utils/Barcode/C128AbstractTest.php index c4d9cb8b6..15038fc44 100644 --- a/tests/Utils/Barcode/C128AbstractTest.php +++ b/tests/Utils/Barcode/C128AbstractTest.php @@ -28,12 +28,20 @@ class C128AbstractTest extends \PHPUnit\Framework\TestCase $this->obj = new class() extends C128Abstract {}; } + /** + * @covers phpOMS\Utils\Barcode\C128Abstract + * @group framework + */ public function testSetGet() : void { $this->obj->setContent('abc'); self::assertEquals('abc', $this->obj->getContent()); } + /** + * @covers phpOMS\Utils\Barcode\C128Abstract + * @group framework + */ public function testInvalidDimensionWidth() : void { $this->expectException(\OutOfBoundsException::class); @@ -41,6 +49,10 @@ class C128AbstractTest extends \PHPUnit\Framework\TestCase $this->obj->setDimension(-2, 1); } + /** + * @covers phpOMS\Utils\Barcode\C128Abstract + * @group framework + */ public function testInvalidDimensionHeight() : void { $this->expectException(\OutOfBoundsException::class); @@ -48,6 +60,10 @@ class C128AbstractTest extends \PHPUnit\Framework\TestCase $this->obj->setDimension(1, -2); } + /** + * @covers phpOMS\Utils\Barcode\C128Abstract + * @group framework + */ public function testInvalidOrientation() : void { $this->expectException(\phpOMS\Stdlib\Base\Exception\InvalidEnumValue::class); diff --git a/tests/Utils/Barcode/C128aTest.php b/tests/Utils/Barcode/C128aTest.php index 6acde9ed8..10654b473 100644 --- a/tests/Utils/Barcode/C128aTest.php +++ b/tests/Utils/Barcode/C128aTest.php @@ -31,10 +31,14 @@ class C128aTest extends \PHPUnit\Framework\TestCase } } + /** + * @covers phpOMS\Utils\Barcode\C128a + * @group framework + */ public function testImagePng() : void { $path = __DIR__ . '/c128a.png'; - if (\file_exists($path)) { + if (\is_file($path)) { \unlink($path); } @@ -44,10 +48,14 @@ class C128aTest extends \PHPUnit\Framework\TestCase self::assertFileExists($path); } + /** + * @covers phpOMS\Utils\Barcode\C128a + * @group framework + */ public function testImageJpg() : void { $path = __DIR__ . '/c128a.jpg'; - if (\file_exists($path)) { + if (\is_file($path)) { \unlink($path); } @@ -57,10 +65,14 @@ class C128aTest extends \PHPUnit\Framework\TestCase self::assertFileExists($path); } + /** + * @covers phpOMS\Utils\Barcode\C128a + * @group framework + */ public function testOrientationAndMargin() : void { $path = __DIR__ . '/c128a_vertical.png'; - if (\file_exists($path)) { + if (\is_file($path)) { \unlink($path); } @@ -71,6 +83,10 @@ class C128aTest extends \PHPUnit\Framework\TestCase self::assertFileExists($path); } + /** + * @covers phpOMS\Utils\Barcode\C128a + * @group framework + */ public function testValidString() : void { self::assertTrue(C128a::isValidString('ABCDEFG0123+-')); diff --git a/tests/Utils/Barcode/C128bTest.php b/tests/Utils/Barcode/C128bTest.php index 5eefd5d71..afb0206ad 100644 --- a/tests/Utils/Barcode/C128bTest.php +++ b/tests/Utils/Barcode/C128bTest.php @@ -31,10 +31,14 @@ class C128bTest extends \PHPUnit\Framework\TestCase } } + /** + * @covers phpOMS\Utils\Barcode\C128b + * @group framework + */ public function testImagePng() : void { $path = __DIR__ . '/c128b.png'; - if (\file_exists($path)) { + if (\is_file($path)) { \unlink($path); } @@ -44,10 +48,14 @@ class C128bTest extends \PHPUnit\Framework\TestCase self::assertFileExists($path); } + /** + * @covers phpOMS\Utils\Barcode\C128b + * @group framework + */ public function testImageJpg() : void { $path = __DIR__ . '/c128b.jpg'; - if (\file_exists($path)) { + if (\is_file($path)) { \unlink($path); } @@ -57,10 +65,14 @@ class C128bTest extends \PHPUnit\Framework\TestCase self::assertFileExists($path); } + /** + * @covers phpOMS\Utils\Barcode\C128b + * @group framework + */ public function testOrientationAndMargin() : void { $path = __DIR__ . '/c128b_vertical.png'; - if (\file_exists($path)) { + if (\is_file($path)) { \unlink($path); } @@ -71,6 +83,10 @@ class C128bTest extends \PHPUnit\Framework\TestCase self::assertFileExists($path); } + /** + * @covers phpOMS\Utils\Barcode\C128b + * @group framework + */ public function testValidString() : void { self::assertTrue(C128b::isValidString('ABCDE~FG0123+-')); diff --git a/tests/Utils/Barcode/C128cTest.php b/tests/Utils/Barcode/C128cTest.php index 2dbd83e66..211a896f1 100644 --- a/tests/Utils/Barcode/C128cTest.php +++ b/tests/Utils/Barcode/C128cTest.php @@ -31,10 +31,14 @@ class C128cTest extends \PHPUnit\Framework\TestCase } } + /** + * @covers phpOMS\Utils\Barcode\C128c + * @group framework + */ public function testImagePng() : void { $path = __DIR__ . '/c128c.png'; - if (\file_exists($path)) { + if (\is_file($path)) { \unlink($path); } @@ -44,10 +48,14 @@ class C128cTest extends \PHPUnit\Framework\TestCase self::assertFileExists($path); } + /** + * @covers phpOMS\Utils\Barcode\C128c + * @group framework + */ public function testImageJpg() : void { $path = __DIR__ . '/c128c.jpg'; - if (\file_exists($path)) { + if (\is_file($path)) { \unlink($path); } @@ -57,10 +65,14 @@ class C128cTest extends \PHPUnit\Framework\TestCase self::assertFileExists($path); } + /** + * @covers phpOMS\Utils\Barcode\C128c + * @group framework + */ public function testOrientationAndMargin() : void { $path = __DIR__ . '/c128c_vertical.png'; - if (\file_exists($path)) { + if (\is_file($path)) { \unlink($path); } diff --git a/tests/Utils/Barcode/C25Test.php b/tests/Utils/Barcode/C25Test.php index 821d681e0..15924fe48 100644 --- a/tests/Utils/Barcode/C25Test.php +++ b/tests/Utils/Barcode/C25Test.php @@ -31,10 +31,14 @@ class C25Test extends \PHPUnit\Framework\TestCase } } + /** + * @covers phpOMS\Utils\Barcode\C25 + * @group framework + */ public function testImagePng() : void { $path = __DIR__ . '/c25.png'; - if (\file_exists($path)) { + if (\is_file($path)) { \unlink($path); } @@ -44,10 +48,14 @@ class C25Test extends \PHPUnit\Framework\TestCase self::assertFileExists($path); } + /** + * @covers phpOMS\Utils\Barcode\C25 + * @group framework + */ public function testImageJpg() : void { $path = __DIR__ . '/c25.jpg'; - if (\file_exists($path)) { + if (\is_file($path)) { \unlink($path); } @@ -57,10 +65,14 @@ class C25Test extends \PHPUnit\Framework\TestCase self::assertFileExists($path); } + /** + * @covers phpOMS\Utils\Barcode\C25 + * @group framework + */ public function testOrientationAndMargin() : void { $path = __DIR__ . '/c25_vertical.png'; - if (\file_exists($path)) { + if (\is_file($path)) { \unlink($path); } @@ -71,12 +83,20 @@ class C25Test extends \PHPUnit\Framework\TestCase self::assertFileExists($path); } + /** + * @covers phpOMS\Utils\Barcode\C25 + * @group framework + */ public function testValidString() : void { self::assertTrue(C25::isValidString('1234567890')); self::assertFalse(C25::isValidString('1234567A890')); } + /** + * @covers phpOMS\Utils\Barcode\C25 + * @group framework + */ public function testInvalidOrientation() : void { $this->expectException(\InvalidArgumentException::class); diff --git a/tests/Utils/Barcode/C39Test.php b/tests/Utils/Barcode/C39Test.php index 887b40fc8..7bdae6b21 100644 --- a/tests/Utils/Barcode/C39Test.php +++ b/tests/Utils/Barcode/C39Test.php @@ -31,10 +31,14 @@ class C39Test extends \PHPUnit\Framework\TestCase } } + /** + * @covers phpOMS\Utils\Barcode\C39 + * @group framework + */ public function testImagePng() : void { $path = __DIR__ . '/c39.png'; - if (\file_exists($path)) { + if (\is_file($path)) { \unlink($path); } @@ -44,10 +48,14 @@ class C39Test extends \PHPUnit\Framework\TestCase self::assertFileExists($path); } + /** + * @covers phpOMS\Utils\Barcode\C39 + * @group framework + */ public function testImageJpg() : void { $path = __DIR__ . '/c39.jpg'; - if (\file_exists($path)) { + if (\is_file($path)) { \unlink($path); } @@ -57,10 +65,14 @@ class C39Test extends \PHPUnit\Framework\TestCase self::assertFileExists($path); } + /** + * @covers phpOMS\Utils\Barcode\C39 + * @group framework + */ public function testOrientationAndMargin() : void { $path = __DIR__ . '/c39_vertical.png'; - if (\file_exists($path)) { + if (\is_file($path)) { \unlink($path); } @@ -71,6 +83,10 @@ class C39Test extends \PHPUnit\Framework\TestCase self::assertFileExists($path); } + /** + * @covers phpOMS\Utils\Barcode\C39 + * @group framework + */ public function testValidString() : void { self::assertTrue(C39::isValidString('ABCDEFG0123+-')); diff --git a/tests/Utils/Barcode/CodebarTest.php b/tests/Utils/Barcode/CodebarTest.php index f2df75a19..269cb8964 100644 --- a/tests/Utils/Barcode/CodebarTest.php +++ b/tests/Utils/Barcode/CodebarTest.php @@ -31,10 +31,14 @@ class CodebarTest extends \PHPUnit\Framework\TestCase } } + /** + * @covers phpOMS\Utils\Barcode\Codebar + * @group framework + */ public function testImagePng() : void { $path = __DIR__ . '/codebar.png'; - if (\file_exists($path)) { + if (\is_file($path)) { \unlink($path); } @@ -44,10 +48,14 @@ class CodebarTest extends \PHPUnit\Framework\TestCase self::assertFileExists($path); } + /** + * @covers phpOMS\Utils\Barcode\Codebar + * @group framework + */ public function testImageJpg() : void { $path = __DIR__ . '/codebar.jpg'; - if (\file_exists($path)) { + if (\is_file($path)) { \unlink($path); } @@ -57,10 +65,14 @@ class CodebarTest extends \PHPUnit\Framework\TestCase self::assertFileExists($path); } + /** + * @covers phpOMS\Utils\Barcode\Codebar + * @group framework + */ public function testOrientationAndMargin() : void { $path = __DIR__ . '/ccodebar_vertical.png'; - if (\file_exists($path)) { + if (\is_file($path)) { \unlink($path); } @@ -71,6 +83,10 @@ class CodebarTest extends \PHPUnit\Framework\TestCase self::assertFileExists($path); } + /** + * @covers phpOMS\Utils\Barcode\Codebar + * @group framework + */ public function testValidString() : void { self::assertTrue(Codebar::isValidString('412163')); diff --git a/tests/Utils/IO/Json/InvalidJsonExceptionTest.php b/tests/Utils/IO/Json/InvalidJsonExceptionTest.php index 90211f0a0..daf59652c 100644 --- a/tests/Utils/IO/Json/InvalidJsonExceptionTest.php +++ b/tests/Utils/IO/Json/InvalidJsonExceptionTest.php @@ -21,6 +21,10 @@ use phpOMS\Utils\IO\Json\InvalidJsonException; */ class InvalidJsonExceptionTest extends \PHPUnit\Framework\TestCase { + /** + * @covers phpOMS\Utils\IO\Json\InvalidJsonException + * @group framework + */ public function testException() : void { self::assertInstanceOf(\UnexpectedValueException::class, new InvalidJsonException('')); diff --git a/tests/Utils/IO/Spreadsheet/SpreadsheetDatabaseMapperTest.php b/tests/Utils/IO/Spreadsheet/SpreadsheetDatabaseMapperTest.php index f21d393fc..5079bf2ac 100644 --- a/tests/Utils/IO/Spreadsheet/SpreadsheetDatabaseMapperTest.php +++ b/tests/Utils/IO/Spreadsheet/SpreadsheetDatabaseMapperTest.php @@ -45,7 +45,7 @@ class SpreadsheetDatabaseMapperTest extends \PHPUnit\Framework\TestCase return; } - if (\file_exists(__DIR__ . '/spreadsheet.db')) { + if (\is_file(__DIR__ . '/spreadsheet.db')) { \unlink(__DIR__ . '/spreadsheet.db'); } @@ -56,7 +56,7 @@ class SpreadsheetDatabaseMapperTest extends \PHPUnit\Framework\TestCase protected function tearDown() : void { - if (\file_exists(__DIR__ . '/spreadsheet.db')) { + if (\is_file(__DIR__ . '/spreadsheet.db')) { \unlink(__DIR__ . '/spreadsheet.db'); } } @@ -359,7 +359,7 @@ class SpreadsheetDatabaseMapperTest extends \PHPUnit\Framework\TestCase */ public function testSelectOds() : void { - if (\file_exists(__DIR__ . '/select.ods')) { + if (\is_file(__DIR__ . '/select.ods')) { \unlink(__DIR__ . '/select.ods'); } @@ -399,7 +399,7 @@ class SpreadsheetDatabaseMapperTest extends \PHPUnit\Framework\TestCase self::assertTrue($this->compareSelectInsertSheet(__DIR__ . '/select.ods', __DIR__ . '/insert.ods')); - if (\file_exists(__DIR__ . '/select.ods')) { + if (\is_file(__DIR__ . '/select.ods')) { \unlink(__DIR__ . '/select.ods'); } } @@ -411,7 +411,7 @@ class SpreadsheetDatabaseMapperTest extends \PHPUnit\Framework\TestCase */ public function testSelectXls() : void { - if (\file_exists(__DIR__ . '/select.xls')) { + if (\is_file(__DIR__ . '/select.xls')) { \unlink(__DIR__ . '/select.xls'); } @@ -451,7 +451,7 @@ class SpreadsheetDatabaseMapperTest extends \PHPUnit\Framework\TestCase self::assertTrue($this->compareSelectInsertSheet(__DIR__ . '/select.xls', __DIR__ . '/insert.xls')); - if (\file_exists(__DIR__ . '/select.xls')) { + if (\is_file(__DIR__ . '/select.xls')) { \unlink(__DIR__ . '/select.xls'); } } @@ -463,7 +463,7 @@ class SpreadsheetDatabaseMapperTest extends \PHPUnit\Framework\TestCase */ public function testSelectXlsx() : void { - if (\file_exists(__DIR__ . '/select.xlsx')) { + if (\is_file(__DIR__ . '/select.xlsx')) { \unlink(__DIR__ . '/select.xlsx'); } @@ -503,7 +503,7 @@ class SpreadsheetDatabaseMapperTest extends \PHPUnit\Framework\TestCase self::assertTrue($this->compareSelectInsertSheet(__DIR__ . '/select.xlsx', __DIR__ . '/insert.xlsx')); - if (\file_exists(__DIR__ . '/select.xlsx')) { + if (\is_file(__DIR__ . '/select.xlsx')) { \unlink(__DIR__ . '/select.xlsx'); } } diff --git a/tests/Utils/StringCompareTest.php b/tests/Utils/StringCompareTest.php index bec92253e..c6bdd1683 100644 --- a/tests/Utils/StringCompareTest.php +++ b/tests/Utils/StringCompareTest.php @@ -95,6 +95,10 @@ class StringCompareTest extends \PHPUnit\Framework\TestCase self::assertEquals(2, StringCompare::valueWords('This is a test', 'This is not test')); } + /** + * @covers phpOMS\Utils\StringCompare + * @group framework + */ public function testJaro() : void { self::assertEqualsWithDelta(0.944444, StringCompare::jaro('MARTHA', 'MARHTA'), 0.01); @@ -102,6 +106,10 @@ class StringCompareTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(0.896296, StringCompare::jaro('JELLYFISH', 'SMELLYFISH'), 0.01); } + /** + * @covers phpOMS\Utils\StringCompare + * @group framework + */ public function testJaroEmpty() : void { self::assertEquals(1.0, StringCompare::jaro('', '')); diff --git a/tests/Utils/TaskSchedule/SchedulerAbstractTest.php b/tests/Utils/TaskSchedule/SchedulerAbstractTest.php index ea084c5dd..575fc95c4 100644 --- a/tests/Utils/TaskSchedule/SchedulerAbstractTest.php +++ b/tests/Utils/TaskSchedule/SchedulerAbstractTest.php @@ -30,7 +30,7 @@ class SchedulerAbstractTest extends \PHPUnit\Framework\TestCase */ public function testDefault() : void { - self::assertTrue(SchedulerAbstract::getBin() === '' || \file_exists(SchedulerAbstract::getBin())); + self::assertTrue(SchedulerAbstract::getBin() === '' || \is_file(SchedulerAbstract::getBin())); } /** diff --git a/tests/Validation/ValidatorTest.php b/tests/Validation/ValidatorTest.php index 33d5cbe0f..608398662 100644 --- a/tests/Validation/ValidatorTest.php +++ b/tests/Validation/ValidatorTest.php @@ -28,7 +28,7 @@ class ValidatorTest extends \PHPUnit\Framework\TestCase { /** * @testdox A string can be checked if it contains a substring - * @covers phpOMS\Validation\Validator + * @covers phpOMS\Validation\Validator * @group framework */ public function testValidationContains() : void @@ -39,7 +39,7 @@ class ValidatorTest extends \PHPUnit\Framework\TestCase /** * @testdox A string can be checked if it has a certain length - * @covers phpOMS\Validation\Validator + * @covers phpOMS\Validation\Validator * @group framework */ public function testValidationLength() : void @@ -51,7 +51,7 @@ class ValidatorTest extends \PHPUnit\Framework\TestCase /** * @testdox A value can be checked if it is in range - * @covers phpOMS\Validation\Validator + * @covers phpOMS\Validation\Validator * @group framework */ public function testValidationLimit() : void @@ -63,7 +63,7 @@ class ValidatorTest extends \PHPUnit\Framework\TestCase /** * @testdox A value can be checked to be of a defined type - * @covers phpOMS\Validation\Validator + * @covers phpOMS\Validation\Validator * @group framework */ public function testValidationType() : void @@ -74,7 +74,7 @@ class ValidatorTest extends \PHPUnit\Framework\TestCase /** * @testdox The error message and error code have the expected default values - * @covers phpOMS\Validation\Validator + * @covers phpOMS\Validation\Validator * @group framework */ public function testValidationError() : void @@ -86,7 +86,7 @@ class ValidatorTest extends \PHPUnit\Framework\TestCase /** * @testdox Custom validators can be specified in order to validate a value - * @covers phpOMS\Validation\Validator + * @covers phpOMS\Validation\Validator * @group framework */ public function testValidators() : void @@ -99,7 +99,7 @@ class ValidatorTest extends \PHPUnit\Framework\TestCase /** * @testdox A value can be checked to match a regular expression - * @covers phpOMS\Validation\Validator + * @covers phpOMS\Validation\Validator * @group framework */ public function testMatching() : void @@ -110,16 +110,28 @@ class ValidatorTest extends \PHPUnit\Framework\TestCase self::assertFalse(Validator::matches('ThisTestVar', '/ThisTest$/')); } + /** + * @covers phpOMS\Validation\Validator + * @group framework + */ public function testErrorMessage() : void { self::assertEquals('', Validator::getMessage()); } + /** + * @covers phpOMS\Validation\Validator + * @group framework + */ public function testErrorCode() : void { self::assertEquals(0, Validator::getErrorCode()); } + /** + * @covers phpOMS\Validation\Validator + * @group framework + */ public function testResetError() : void { Validator::resetError();