diff --git a/Application/ApplicationManager.php b/Application/ApplicationManager.php index bac390484..2d1114338 100644 --- a/Application/ApplicationManager.php +++ b/Application/ApplicationManager.php @@ -160,8 +160,6 @@ final class ApplicationManager * * @return void * - * @throws InvalidModuleException Throws this exception in case the installer doesn't exist - * * @since 1.0.0 */ public function reInit(string $appPath) : void @@ -216,7 +214,7 @@ final class ApplicationManager * @param bool $useCache Use Cache * @param string $basePath Base path for the applications * - * @return array + * @return array * * @since 1.0.0 */ diff --git a/Application/InstallerAbstract.php b/Application/InstallerAbstract.php index 9cb33bdfb..59b243ce5 100644 --- a/Application/InstallerAbstract.php +++ b/Application/InstallerAbstract.php @@ -29,6 +29,12 @@ use phpOMS\System\File\Local\Directory; */ abstract class InstallerAbstract { + /** + * Path of the file + * + * @var string + * @since 1.0.0 + */ public const PATH = ''; /** diff --git a/Application/StatusAbstract.php b/Application/StatusAbstract.php index 6a1b08033..91a26a031 100644 --- a/Application/StatusAbstract.php +++ b/Application/StatusAbstract.php @@ -31,6 +31,12 @@ use phpOMS\Utils\Parser\Php\ArrayParser; */ abstract class StatusAbstract { + /** + * Path of the file + * + * @var string + * @since 1.0.0 + */ public const PATH = ''; /** diff --git a/Application/UninstallerAbstract.php b/Application/UninstallerAbstract.php index 690a425c8..3ed34de3f 100644 --- a/Application/UninstallerAbstract.php +++ b/Application/UninstallerAbstract.php @@ -28,6 +28,14 @@ use phpOMS\DataStorage\Database\Schema\Builder as SchemaBuilder; */ abstract class UninstallerAbstract { + /** + * Path of the file + * + * @var string + * @since 1.0.0 + */ + public const PATH = ''; + /** * Install module. * diff --git a/Module/InstallerAbstract.php b/Module/InstallerAbstract.php index e63f63e38..ecbfeff35 100644 --- a/Module/InstallerAbstract.php +++ b/Module/InstallerAbstract.php @@ -29,6 +29,14 @@ use phpOMS\DataStorage\Database\Schema\Builder as SchemaBuilder; */ abstract class InstallerAbstract { + /** + * Path of the file + * + * @var string + * @since 1.0.0 + */ + public const PATH = ''; + /** * Install module. * @@ -58,7 +66,7 @@ abstract class InstallerAbstract */ protected static function createTables(DatabasePool $dbPool, ModuleInfo $info) : void { - $path = \dirname($info->getPath()) . '/Admin/Install/db.json'; + $path = static::PATH . '/Install/db.json'; if (!\is_file($path)) { return; } @@ -86,8 +94,10 @@ abstract class InstallerAbstract */ protected static function activate(DatabasePool $dbPool, ModuleInfo $info) : void { - /** @var StatusAbstract $class */ - $class = '\Modules\\' . $info->getDirectory() . '\Admin\Status'; + $classPath = \substr(\realpath(static::PATH) . '/Status', \strlen(\realpath(__DIR__ . '/../../'))); + + /** @var StatusAbstract $class */ + $class = \str_replace('/', '\\', $classPath); $class::activate($dbPool, $info); } @@ -103,7 +113,10 @@ abstract class InstallerAbstract */ public static function reInit(ModuleInfo $info, ApplicationInfo $appInfo = null) : void { - $class = '\Modules\\' . $info->getDirectory() . '\Admin\Status'; + $classPath = \substr(\realpath(static::PATH) . '/Status', \strlen(\realpath(__DIR__ . '/../../'))); + + /** @var StatusAbstract $class */ + $class = \str_replace('/', '\\', $classPath); $class::activateRoutes($info, $appInfo); $class::activateHooks($info, $appInfo); } diff --git a/Module/StatusAbstract.php b/Module/StatusAbstract.php index a5d5d40a2..56d534116 100644 --- a/Module/StatusAbstract.php +++ b/Module/StatusAbstract.php @@ -35,6 +35,14 @@ use phpOMS\Utils\Parser\Php\ArrayParser; */ abstract class StatusAbstract { + /** + * Path of the file + * + * @var string + * @since 1.0.0 + */ + public const PATH = ''; + /** * Deactivate module. * @@ -65,7 +73,7 @@ abstract class StatusAbstract */ public static function activateRoutes(ModuleInfo $info, ApplicationInfo $appInfo = null) : void { - $directories = new Directory(\dirname($info->getPath()) . '/Admin/Routes'); + $directories = new Directory(static::PATH . '/Routes'); /** @var Directory|File $child */ foreach ($directories as $child) { @@ -145,7 +153,7 @@ abstract class StatusAbstract */ public static function activateHooks(ModuleInfo $info, ApplicationInfo $appInfo = null) : void { - $directories = new Directory(\dirname($info->getPath()) . '/Admin/Hooks'); + $directories = new Directory(static::PATH . '/Hooks'); /** @var Directory|File $child */ foreach ($directories as $child) { @@ -199,7 +207,7 @@ abstract class StatusAbstract */ public static function deactivateRoutes(ModuleInfo $info, ApplicationInfo $appInfo = null) : void { - $directories = new Directory(\dirname($info->getPath()) . '/Admin/Routes'); + $directories = new Directory(static::PATH . '/Routes'); /** @var Directory|File $child */ foreach ($directories as $child) { @@ -275,7 +283,7 @@ abstract class StatusAbstract */ public static function deactivateHooks(ModuleInfo $info, ApplicationInfo $appInfo = null) : void { - $directories = new Directory(\dirname($info->getPath()) . '/Admin/Hooks'); + $directories = new Directory(static::PATH . '/Hooks'); /** @var Directory|File $child */ foreach ($directories as $child) { diff --git a/Module/UninstallerAbstract.php b/Module/UninstallerAbstract.php index 0826e38e5..afdef6a88 100644 --- a/Module/UninstallerAbstract.php +++ b/Module/UninstallerAbstract.php @@ -28,6 +28,14 @@ use phpOMS\DataStorage\Database\Schema\Builder as SchemaBuilder; */ abstract class UninstallerAbstract { + /** + * Path of the file + * + * @var string + * @since 1.0.0 + */ + public const PATH = ''; + /** * Install module. * @@ -58,7 +66,10 @@ abstract class UninstallerAbstract protected static function deactivate(DatabasePool $dbPool, ModuleInfo $info) : void { /** @var StatusAbstract $class */ - $class = '\Modules\\' . $info->getDirectory() . '\Admin\Status'; + $classPath = \substr(\realpath(static::PATH) . '/Status', \strlen(\realpath(__DIR__ . '/../../'))); + + /** @var StatusAbstract $class */ + $class = \str_replace('/', '\\', $classPath); $class::deactivate($dbPool, $info); } @@ -74,8 +85,7 @@ abstract class UninstallerAbstract */ public static function dropTables(DatabasePool $dbPool, ModuleInfo $info) : void { - $path = \dirname($info->getPath()) . '/Admin/Install/db.json'; - + $path = static::PATH . '/Install/db.json'; if (!\is_file($path)) { return; } diff --git a/Stdlib/Graph/Graph.php b/Stdlib/Graph/Graph.php index efe174229..16a598ea9 100644 --- a/Stdlib/Graph/Graph.php +++ b/Stdlib/Graph/Graph.php @@ -555,13 +555,13 @@ class Graph $cNode = \array_pop($stack); $nodes[] = $cNode; - if (!isset($visited[$cNode->getId()]) || !$visited[$cNode->getId()]) { + if (!isset($visited[$cNode->getId()]) || $visited[$cNode->getId()] === false) { $visited[$cNode->getId()] = true; } $neighbors = $cNode->getNeighbors(); foreach ($neighbors as $neighbor) { - if (!isset($visited[$cNode->getId()]) || !$visited[$cNode->getId()]) { + if (!isset($visited[$cNode->getId()]) || $visited[$cNode->getId()] === false) { $stack[] = $neighbor; } } diff --git a/tests/Application/Testapp/Admin/Installer.php b/tests/Application/Testapp/Admin/Installer.php index aff5dec23..0acc23a51 100644 --- a/tests/Application/Testapp/Admin/Installer.php +++ b/tests/Application/Testapp/Admin/Installer.php @@ -26,5 +26,11 @@ use phpOMS\Application\InstallerAbstract; */ final class Installer extends InstallerAbstract { - public const PATH = __DIR__; + /** + * Path of the file + * + * @var string + * @since 1.0.0 + */ + public const PATH = __DIR__; } diff --git a/tests/Application/Testapp/Admin/Uninstaller.php b/tests/Application/Testapp/Admin/Uninstaller.php index a6c987390..a8e0e0299 100644 --- a/tests/Application/Testapp/Admin/Uninstaller.php +++ b/tests/Application/Testapp/Admin/Uninstaller.php @@ -24,7 +24,13 @@ use phpOMS\Application\UninstallerAbstract; * @link https://orange-management.org * @since 1.0.0 */ -final class Uninstaller extends UninstallerAbstract +final class Installer extends InstallerAbstract { - public const PATH = __DIR__; + /** + * Path of the file + * + * @var string + * @since 1.0.0 + */ + public const PATH = __DIR__; } diff --git a/tests/DataStorage/Cache/Connection/RedisCacheTest.php b/tests/DataStorage/Cache/Connection/RedisCacheTest.php index 7d8e2b416..d05061d51 100644 --- a/tests/DataStorage/Cache/Connection/RedisCacheTest.php +++ b/tests/DataStorage/Cache/Connection/RedisCacheTest.php @@ -150,7 +150,11 @@ class RedisCacheTest extends \PHPUnit\Framework\TestCase { $this->cache->set('key1', 'testVal1'); $this->cache->set('key2', 'testVal2'); - self::assertEquals(['testVal1', 'testVal2'], $this->cache->getLike('key\d')); + + $result = $this->cache->getLike('key\d'); + self::assertEquals(2, \count($result)); + self::assertTrue(\in_array('testVal1', $result)) + self::assertTrue(\in_array('testVal2', $result)) } public function testExpiredGetLike() : void diff --git a/tests/Message/Mail/MailHandlerTest.php b/tests/Message/Mail/MailHandlerTest.php index b392bd3bc..20a4ecf6e 100644 --- a/tests/Message/Mail/MailHandlerTest.php +++ b/tests/Message/Mail/MailHandlerTest.php @@ -41,12 +41,12 @@ class MailHandlerTest extends \PHPUnit\Framework\TestCase public function testSendTextWithMail() : void { - if (!\file_exists('/usr/sbin/sendmail') && empty(\ini_get('sendmail_path'))) { + $this->handler->setMailer(SubmitType::MAIL); + + if (!\file_exists($this->handler->mailerTool)) { self::markTestSkipped(); } - $this->handler->setMailer(SubmitType::MAIL); - $mail = new Email(); $mail->setFrom('test1@orange-management.email', 'Dennis Eichhorn'); $mail->addTo('test@orange-management.email', 'Dennis Eichhorn'); @@ -62,12 +62,12 @@ class MailHandlerTest extends \PHPUnit\Framework\TestCase public function testSendTextWithSendmail() : void { - if (!\file_exists('/usr/sbin/sendmail') && empty(\ini_get('sendmail_path'))) { + $this->handler->setMailer(SubmitType::SENDMAIL); + + if (!\file_exists($this->handler->mailerTool)) { self::markTestSkipped(); } - $this->handler->setMailer(SubmitType::SENDMAIL); - $mail = new Email(); $mail->setFrom('test1@orange-management.email', 'Dennis Eichhorn'); $mail->addTo('test@orange-management.email', 'Dennis Eichhorn'); @@ -83,12 +83,12 @@ class MailHandlerTest extends \PHPUnit\Framework\TestCase public function testSendHtmlWithMail() : void { - if (!\file_exists('/usr/sbin/sendmail') && empty(\ini_get('sendmail_path'))) { + $this->handler->setMailer(SubmitType::MAIL); + + if (!\file_exists($this->handler->mailerTool)) { self::markTestSkipped(); } - $this->handler->setMailer(SubmitType::MAIL); - $mail = new Email(); $mail->setFrom('test1@orange-management.email', 'Dennis Eichhorn'); $mail->addTo('test@orange-management.email', 'Dennis Eichhorn'); @@ -109,12 +109,12 @@ class MailHandlerTest extends \PHPUnit\Framework\TestCase public function testSendHtmlWithSendmail() : void { - if (!\file_exists('/usr/sbin/sendmail') && empty(\ini_get('sendmail_path'))) { + $this->handler->setMailer(SubmitType::SENDMAIL); + + if (!\file_exists($this->handler->mailerTool)) { self::markTestSkipped(); } - $this->handler->setMailer(SubmitType::SENDMAIL); - $mail = new Email(); $mail->setFrom('test1@orange-management.email', 'Dennis Eichhorn'); $mail->addTo('test@orange-management.email', 'Dennis Eichhorn'); diff --git a/tests/Module/Testmodule/Admin/Installer.php b/tests/Module/Testmodule/Admin/Installer.php index 5ff2eeb0a..df22b5ce7 100644 --- a/tests/Module/Testmodule/Admin/Installer.php +++ b/tests/Module/Testmodule/Admin/Installer.php @@ -26,4 +26,11 @@ use phpOMS\Module\InstallerAbstract; */ final class Installer extends InstallerAbstract { + /** + * Path of the file + * + * @var string + * @since 1.0.0 + */ + public const PATH = __DIR__; }