From 13b31d919c589aa499a8c61b2aa220cb14969780 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Wed, 18 Oct 2023 12:23:02 +0000 Subject: [PATCH] Revert "fix tests" This reverts commit 4998ebb1f19ea8dce5455c00916f30cc49e195cb. --- .../Api/ApiControllerSettingsTrait.php | 103 ++++++++++++++++++ tests/Controller/ApiControllerTest.php | 2 + 2 files changed, 105 insertions(+) create mode 100755 tests/Controller/Api/ApiControllerSettingsTrait.php diff --git a/tests/Controller/Api/ApiControllerSettingsTrait.php b/tests/Controller/Api/ApiControllerSettingsTrait.php new file mode 100755 index 0000000..333553d --- /dev/null +++ b/tests/Controller/Api/ApiControllerSettingsTrait.php @@ -0,0 +1,103 @@ +app = new class() extends ApplicationAbstract + { + protected string $appName = 'Api'; + }; + + $this->app->dbPool = $GLOBALS['dbpool']; + $this->app->unitId = 1; + $this->app->accountManager = new AccountManager($GLOBALS['session']); + $this->app->appSettings = new CoreSettings(); + $this->app->moduleManager = new ModuleManager($this->app, __DIR__ . '/../../../../Modules/'); + $this->app->dispatcher = new Dispatcher($this->app); + $this->app->eventManager = new EventManager($this->app->dispatcher); + $this->app->eventManager->importFromFile(__DIR__ . '/../../../../Web/Api/Hooks.php'); + $this->app->sessionManager = new HttpSession(36000); + $this->app->l11nManager = new L11nManager(); + + $account = new Account(); + TestUtils::setMember($account, 'id', 1); + + $permission = new AccountPermission(); + $permission->unit = 1; + $permission->app = 2; + $permission->setPermission( + PermissionType::READ + | PermissionType::CREATE + | PermissionType::MODIFY + | PermissionType::DELETE + | PermissionType::PERMISSION + ); + + $account->addPermission($permission); + + $this->app->accountManager->add($account); + $this->app->router = new WebRouter(); + + $this->module = $this->app->moduleManager->get('Admin'); + + TestUtils::setMember($this->module, 'app', $this->app); + } + + use ApiControllerSettingsTrait; + use ApiControllerAccountTrait; + use ApiControllerGroupTrait; + use ApiControllerPermissionTrait; + use ApiControllerModuleTrait; + use ApiControllerApplicationTrait; +} diff --git a/tests/Controller/ApiControllerTest.php b/tests/Controller/ApiControllerTest.php index f896390..333553d 100755 --- a/tests/Controller/ApiControllerTest.php +++ b/tests/Controller/ApiControllerTest.php @@ -21,6 +21,7 @@ use Modules\Admin\tests\Controller\Api\ApiControllerApplicationTrait; use Modules\Admin\tests\Controller\Api\ApiControllerGroupTrait; use Modules\Admin\tests\Controller\Api\ApiControllerModuleTrait; use Modules\Admin\tests\Controller\Api\ApiControllerPermissionTrait; +use Modules\Admin\tests\Controller\Api\ApiControllerSettingsTrait; use phpOMS\Account\Account; use phpOMS\Account\AccountManager; use phpOMS\Account\PermissionType; @@ -93,6 +94,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase TestUtils::setMember($this->module, 'app', $this->app); } + use ApiControllerSettingsTrait; use ApiControllerAccountTrait; use ApiControllerGroupTrait; use ApiControllerPermissionTrait;