always pass

This commit is contained in:
Dennis Eichhorn 2022-03-17 22:38:28 +01:00
parent b034c617fd
commit c560be94ba
8 changed files with 41 additions and 37 deletions

View File

@ -118,7 +118,7 @@ final class ApplicationManager
// @var class-string<InstallerAbstract> $class // @var class-string<InstallerAbstract> $class
$class = \str_replace('/', '\\', $classPath); $class = \str_replace('/', '\\', $classPath);
$class::install($this->app->dbPool, $info, $this->app->appSettings); $class::install($this->app, $info, $this->app->appSettings);
return true; return true;
} catch (\Throwable $t) { } catch (\Throwable $t) {
@ -150,7 +150,7 @@ final class ApplicationManager
// @var class-string<UninstallerAbstract> $class // @var class-string<UninstallerAbstract> $class
$class = \str_replace('/', '\\', $classPath); $class = \str_replace('/', '\\', $classPath);
$class::uninstall($this->app->dbPool, $info, $this->app->appSettings); $class::uninstall($this->app, $info, $this->app->appSettings);
$this->uninstallFiles($source); $this->uninstallFiles($source);

View File

@ -41,7 +41,7 @@ abstract class InstallerAbstract
/** /**
* Install app. * Install app.
* *
* @param DatabasePool $dbPool Database instance * @param ApplicationAbstract $app Application
* @param ApplicationInfo $info App info * @param ApplicationInfo $info App info
* @param SettingsInterface $cfgHandler Settings/Configuration handler * @param SettingsInterface $cfgHandler Settings/Configuration handler
* *
@ -49,10 +49,10 @@ abstract class InstallerAbstract
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public static function install(DatabasePool $dbPool, ApplicationInfo $info, SettingsInterface $cfgHandler) : void public static function install(ApplicationAbstract $app, ApplicationInfo $info, SettingsInterface $cfgHandler) : void
{ {
self::createTables($dbPool, $info); self::createTables($app->dbPool, $info);
self::activate($dbPool, $info); self::activate($app, $info);
self::installTheme(static::PATH . '/..', 'Default'); self::installTheme(static::PATH . '/..', 'Default');
} }
@ -125,14 +125,14 @@ abstract class InstallerAbstract
/** /**
* Activate after install. * Activate after install.
* *
* @param DatabasePool $dbPool Database instance * @param ApplicationAbstract $app Application
* @param ApplicationInfo $info App info * @param ApplicationInfo $info App info
* *
* @return void * @return void
* *
* @since 1.0.0 * @since 1.0.0
*/ */
protected static function activate(DatabasePool $dbPool, ApplicationInfo $info) : void protected static function activate(ApplicationAbstract $app, ApplicationInfo $info) : void
{ {
if (($path = \realpath(static::PATH)) === false) { if (($path = \realpath(static::PATH)) === false) {
return; // @codeCoverageIgnore return; // @codeCoverageIgnore
@ -147,7 +147,7 @@ abstract class InstallerAbstract
throw new \UnexpectedValueException($class); // @codeCoverageIgnore throw new \UnexpectedValueException($class); // @codeCoverageIgnore
} }
$class::activate($dbPool, $info); $class::activate($app, $info);
} }
/** /**

View File

@ -14,6 +14,7 @@ declare(strict_types=1);
namespace phpOMS\Module; namespace phpOMS\Module;
use phpOMS\Application\ApplicationAbstract;
use phpOMS\Application\ApplicationInfo; use phpOMS\Application\ApplicationInfo;
use phpOMS\Autoloader; use phpOMS\Autoloader;
use phpOMS\Config\SettingsInterface; use phpOMS\Config\SettingsInterface;
@ -41,7 +42,7 @@ abstract class InstallerAbstract
/** /**
* Install module. * Install module.
* *
* @param DatabasePool $dbPool Database instance * @param ApplicationAbstract $app Application
* @param ModuleInfo $info Module info * @param ModuleInfo $info Module info
* @param SettingsInterface $cfgHandler Settings/Configuration handler * @param SettingsInterface $cfgHandler Settings/Configuration handler
* *
@ -49,10 +50,10 @@ abstract class InstallerAbstract
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public static function install(DatabasePool $dbPool, ModuleInfo $info, SettingsInterface $cfgHandler) : void public static function install(ApplicationAbstract $app, ModuleInfo $info, SettingsInterface $cfgHandler) : void
{ {
self::createTables($dbPool, $info); self::createTables($app->dbPool, $info);
self::activate($dbPool, $info); self::activate($app, $info);
} }
/** /**
@ -86,14 +87,14 @@ abstract class InstallerAbstract
/** /**
* Activate after install. * Activate after install.
* *
* @param DatabasePool $dbPool Database instance * @param ApplicationAbstract $app Application
* @param ModuleInfo $info Module info * @param ModuleInfo $info Module info
* *
* @return void * @return void
* *
* @since 1.0.0 * @since 1.0.0
*/ */
protected static function activate(DatabasePool $dbPool, ModuleInfo $info) : void protected static function activate(ApplicationAbstract $app, ModuleInfo $info) : void
{ {
if (($path = \realpath(static::PATH)) === false) { if (($path = \realpath(static::PATH)) === false) {
return; // @codeCoverageIgnore return; // @codeCoverageIgnore
@ -108,7 +109,7 @@ abstract class InstallerAbstract
throw new \UnexpectedValueException($class); // @codeCoverageIgnore throw new \UnexpectedValueException($class); // @codeCoverageIgnore
} }
$class::activate($dbPool, $info); $class::activate($app, $info);
} }
/** /**

View File

@ -398,7 +398,7 @@ final class ModuleManager
} }
/** @var $class DeactivateAbstract */ /** @var $class DeactivateAbstract */
$class::deactivate($this->app->dbPool, $info); $class::deactivate($this->app, $info);
} }
/** /**
@ -450,7 +450,7 @@ final class ModuleManager
} }
/** @var $class ActivateAbstract */ /** @var $class ActivateAbstract */
$class::activate($this->app->dbPool, $info); $class::activate($this->app, $info);
} }
/** /**
@ -568,7 +568,7 @@ final class ModuleManager
} }
/** @var $class UninstallerAbstract */ /** @var $class UninstallerAbstract */
$class::uninstall($this->app->dbPool, $info); $class::uninstall($this->app, $info);
if (isset($this->installed[$module])) { if (isset($this->installed[$module])) {
unset($this->installed[$module]); unset($this->installed[$module]);
@ -607,7 +607,7 @@ final class ModuleManager
} }
/** @var InstallerAbstract $class */ /** @var InstallerAbstract $class */
$class::install($this->app->dbPool, $info, $this->app->appSettings); $class::install($this->app, $info, $this->app->appSettings);
} }
/** /**
@ -631,7 +631,7 @@ final class ModuleManager
$from = \str_replace('/', '\\', $from); $from = \str_replace('/', '\\', $from);
$class = $from . '\\Admin\\Install\\' . $for; $class = $from . '\\Admin\\Install\\' . $for;
$class::install($this->modulePath, $this->app); $class::install($this->app, $this->modulePath);
} }
/** /**

View File

@ -14,6 +14,7 @@ declare(strict_types=1);
namespace phpOMS\Module; namespace phpOMS\Module;
use phpOMS\Application\ApplicationAbstract;
use phpOMS\Application\ApplicationInfo; use phpOMS\Application\ApplicationInfo;
use phpOMS\DataStorage\Database\DatabasePool; use phpOMS\DataStorage\Database\DatabasePool;
use phpOMS\System\File\Local\Directory; use phpOMS\System\File\Local\Directory;
@ -46,14 +47,14 @@ abstract class StatusAbstract
/** /**
* Deactivate module. * Deactivate module.
* *
* @param DatabasePool $dbPool Database instance * @param ApplicationAbstract $app Application
* @param ModuleInfo $info Module info * @param ModuleInfo $info Module info
* *
* @return void * @return void
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public static function activate(DatabasePool $dbPool, ModuleInfo $info) : void public static function activate(ApplicationAbstract $app, ModuleInfo $info) : void
{ {
self::activateRoutes($info); self::activateRoutes($info);
self::activateHooks($info); self::activateHooks($info);
@ -176,14 +177,14 @@ abstract class StatusAbstract
/** /**
* Deactivate module. * Deactivate module.
* *
* @param DatabasePool $dbPool Database instance * @param ApplicationAbstract $app Application
* @param ModuleInfo $info Module info * @param ModuleInfo $info Module info
* *
* @return void * @return void
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public static function deactivate(DatabasePool $dbPool, ModuleInfo $info) : void public static function deactivate(ApplicationAbstract $app, ModuleInfo $info) : void
{ {
self::deactivateRoutes($info); self::deactivateRoutes($info);
self::deactivateHooks($info); self::deactivateHooks($info);

View File

@ -14,6 +14,7 @@ declare(strict_types=1);
namespace phpOMS\Module; namespace phpOMS\Module;
use phpOMS\Application\ApplicationAbstract;
use phpOMS\DataStorage\Database\DatabasePool; use phpOMS\DataStorage\Database\DatabasePool;
use phpOMS\DataStorage\Database\Query\Builder; use phpOMS\DataStorage\Database\Query\Builder;
use phpOMS\DataStorage\Database\Schema\Builder as SchemaBuilder; use phpOMS\DataStorage\Database\Schema\Builder as SchemaBuilder;
@ -39,31 +40,31 @@ abstract class UninstallerAbstract
/** /**
* Install module. * Install module.
* *
* @param DatabasePool $dbPool Database instance * @param ApplicationAbstract $app Application
* @param ModuleInfo $info Module info * @param ModuleInfo $info Module info
* *
* @return void * @return void
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public static function uninstall(DatabasePool $dbPool, ModuleInfo $info) : void public static function uninstall(ApplicationAbstract $app, ModuleInfo $info) : void
{ {
self::deactivate($dbPool, $info); self::deactivate($app, $info);
self::dropTables($dbPool, $info); self::dropTables($app->dbPool, $info);
self::unregisterFromDatabase($dbPool, $info); self::unregisterFromDatabase($app->dbPool, $info);
} }
/** /**
* Activate after install. * Activate after install.
* *
* @param DatabasePool $dbPool Database instance * @param ApplicationAbstract $app Application
* @param ModuleInfo $info Module info * @param ModuleInfo $info Module info
* *
* @return void * @return void
* *
* @since 1.0.0 * @since 1.0.0
*/ */
protected static function deactivate(DatabasePool $dbPool, ModuleInfo $info) : void protected static function deactivate(ApplicationAbstract $app, ModuleInfo $info) : void
{ {
if (($path = \realpath(static::PATH)) === false) { if (($path = \realpath(static::PATH)) === false) {
return; // @codeCoverageIgnore return; // @codeCoverageIgnore
@ -74,7 +75,7 @@ abstract class UninstallerAbstract
/** @var StatusAbstract $class */ /** @var StatusAbstract $class */
$class = \str_replace('/', '\\', $classPath); $class = \str_replace('/', '\\', $classPath);
$class::deactivate($dbPool, $info); $class::deactivate($app, $info);
} }
/** /**

View File

@ -229,7 +229,7 @@ final class UriFactory
\parse_str($urlStructure['query'], $urlStructure['query']); \parse_str($urlStructure['query'], $urlStructure['query']);
foreach ($urlStructure['query'] as $para => $query) { foreach ($urlStructure['query'] as $para => $query) {
if ($query === '' && \stripos($url, $para . '=') !== false) { if (($query === '' && \stripos($url, $para . '=') !== false) || $query === '---') {
unset($urlStructure['query'][$para]); unset($urlStructure['query'][$para]);
} }
} }
@ -249,7 +249,7 @@ final class UriFactory
. (isset($urlStructure['path']) && !empty($urlStructure['path']) . (isset($urlStructure['path']) && !empty($urlStructure['path'])
? $urlStructure['path'] : '') ? $urlStructure['path'] : '')
. (isset($urlStructure['query']) && !empty($urlStructure['query']) . (isset($urlStructure['query']) && !empty($urlStructure['query'])
? '?' . \http_build_query($urlStructure['query']) : '') ? '?' . \rtrim(\str_replace('=&', '&', \http_build_query($urlStructure['query'])), '=') : '')
. (isset($urlStructure['fragment']) && !empty($urlStructure['fragment']) . (isset($urlStructure['fragment']) && !empty($urlStructure['fragment'])
? '#' . \str_replace('\#', '#', $urlStructure['fragment']) : ''); ? '#' . \str_replace('\#', '#', $urlStructure['fragment']) : '');
@ -288,7 +288,7 @@ final class UriFactory
$parsed = \preg_replace_callback('(\{[\/#\?%@\.\$][a-zA-Z0-9\-]*\})', function ($match) use ($toMatch) { $parsed = \preg_replace_callback('(\{[\/#\?%@\.\$][a-zA-Z0-9\-]*\})', function ($match) use ($toMatch) {
$match = \substr($match[0], 1, \strlen($match[0]) - 2); $match = \substr($match[0], 1, \strlen($match[0]) - 2);
return $toMatch[$match] ?? self::$uri[$match] ?? ''; return $toMatch[$match] ?? self::$uri[$match] ?? '---';
}, $uri); }, $uri);
return self::unique($parsed ?? ''); return self::unique($parsed ?? '');

View File

@ -17,6 +17,7 @@ namespace phpOMS\tests\Module;
require_once __DIR__ . '/../Autoloader.php'; require_once __DIR__ . '/../Autoloader.php';
use Model\CoreSettings; use Model\CoreSettings;
use phpOMS\Application\ApplicationAbstract;
use phpOMS\DataStorage\Database\DatabasePool; use phpOMS\DataStorage\Database\DatabasePool;
use phpOMS\Module\InstallerAbstract; use phpOMS\Module\InstallerAbstract;
use phpOMS\Module\ModuleInfo; use phpOMS\Module\ModuleInfo;
@ -49,7 +50,7 @@ final class InstallerAbstractTest extends \PHPUnit\Framework\TestCase
$this->expectException(\UnexpectedValueException::class); $this->expectException(\UnexpectedValueException::class);
$this->installer::install( $this->installer::install(
new DatabasePool(), new class() extends ApplicationAbstract {},
new ModuleInfo(__DIR__), new ModuleInfo(__DIR__),
new CoreSettings() new CoreSettings()
); );