mirror of
https://github.com/Karaka-Management/oms-Script.git
synced 2026-01-11 20:38:42 +00:00
78 lines
2.3 KiB
PHP
78 lines
2.3 KiB
PHP
<?php
|
|
/**
|
|
* Orange Management
|
|
*
|
|
* PHP Version 7.4
|
|
*
|
|
* @package tests
|
|
* @copyright Dennis Eichhorn
|
|
* @license OMS License 1.0
|
|
* @version 1.0.0
|
|
* @link https://orange-management.org
|
|
*/
|
|
declare(strict_types=1);
|
|
|
|
namespace Modules\Helper\tests;
|
|
|
|
use Model\CoreSettings;
|
|
use Modules\Admin\Models\AccountPermission;
|
|
use phpOMS\Account\Account;
|
|
use phpOMS\Account\AccountManager;
|
|
use phpOMS\Account\PermissionType;
|
|
use phpOMS\Application\ApplicationAbstract;
|
|
use phpOMS\Dispatcher\Dispatcher;
|
|
use phpOMS\Event\EventManager;
|
|
use phpOMS\Module\ModuleManager;
|
|
use phpOMS\Router\WebRouter;
|
|
use phpOMS\Utils\TestUtils;
|
|
|
|
/**
|
|
* @internal
|
|
*/
|
|
class ControllerTest extends \PHPUnit\Framework\TestCase
|
|
{
|
|
protected $app = null;
|
|
protected $module = null;
|
|
|
|
protected function setUp() : void
|
|
{
|
|
$this->app = new class() extends ApplicationAbstract
|
|
{
|
|
protected string $appName = 'Api';
|
|
};
|
|
|
|
$this->app->dbPool = $GLOBALS['dbpool'];
|
|
$this->app->orgId = 1;
|
|
$this->app->appName = 'Backend';
|
|
$this->app->accountManager = new AccountManager($GLOBALS['session']);
|
|
$this->app->appSettings = new CoreSettings($this->app->dbPool->get());
|
|
$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');
|
|
|
|
$account = new Account();
|
|
TestUtils::setMember($account, 'id', 1);
|
|
|
|
$permission = new AccountPermission();
|
|
$permission->setUnit(1);
|
|
$permission->setApp('backend');
|
|
$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('Helper');
|
|
|
|
TestUtils::setMember($this->module, 'app', $this->app);
|
|
}
|
|
}
|