oms-Accounting/tests/Controller/Api/ApiControllerTaxKeyTrait.php
Dennis Eichhorn b9cc3b66b1 Revert "test fix"
This reverts commit 7c668cf9ca.
2023-10-18 12:21:23 +00:00

113 lines
3.5 KiB
PHP
Executable File

<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\Accounting\tests\Controller;
use Model\CoreSettings;
use Modules\Accounting\tests\Controller\Api\ApiControllerAccountTrait;
use Modules\Accounting\tests\Controller\Api\ApiControllerBatchEntryTrait;
use Modules\Accounting\tests\Controller\Api\ApiControllerCostCenterTrait;
use Modules\Accounting\tests\Controller\Api\ApiControllerCostObjectTrait;
use Modules\Accounting\tests\Controller\Api\ApiControllerEntryTrait;
use Modules\Accounting\tests\Controller\Api\ApiControllerTaxKeyTrait;
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\Localization\L11nManager;
use phpOMS\Module\ModuleAbstract;
use phpOMS\Module\ModuleManager;
use phpOMS\Router\WebRouter;
use phpOMS\Utils\TestUtils;
/**
* @testdox Modules\Accounting\tests\Controller\ApiControllerTest: Accounting api controller
*
* @internal
*/
final class ApiControllerTest extends \PHPUnit\Framework\TestCase
{
protected ApplicationAbstract $app;
/**
* @var \Modules\Accounting\Controller\ApiController
*/
protected ModuleAbstract $module;
/**
* {@inheritdoc}
*/
protected function setUp() : void
{
$this->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->l11nManager = new L11nManager();
$this->app->eventManager->importFromFile(__DIR__ . '/../../../../Web/Api/Hooks.php');
$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('Accounting');
TestUtils::setMember($this->module, 'app', $this->app);
}
use ApiControllerAccountTrait;
use ApiControllerCostCenterTrait;
use ApiControllerCostObjectTrait;
use ApiControllerTaxKeyTrait;
use ApiControllerEntryTrait;
use ApiControllerBatchEntryTrait;
}
public function testInvalidapiAccountL11nCreate() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request->header->account = 1;
$this->module->apiAccountL11nCreate($request, $response);
self::assertEquals(RequestStatusCode::R_400, $response->header->status);
}
}