mirror of
https://github.com/Karaka-Management/oms-Script.git
synced 2026-01-25 18:58:42 +00:00
add tests
This commit is contained in:
parent
9bbc8e5baf
commit
1c802072c2
26
tests/Admin/AdminTest.php
Normal file
26
tests/Admin/AdminTest.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?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\tests\Helper\Admin;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class AdminTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
protected const MODULE_NAME = 'Helper';
|
||||
protected const URI_LOAD = 'http://127.0.0.1/en/backend/helper';
|
||||
|
||||
use \Modules\tests\ModuleTestTrait;
|
||||
}
|
||||
79
tests/ControllerTestTemp.php
Normal file
79
tests/ControllerTestTemp.php
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
<?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\tests\Helper;
|
||||
|
||||
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;
|
||||
|
||||
require_once __DIR__ . '/../Autoloader.php';
|
||||
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
53
tests/EventCourse/EventCourse.lang.php
Normal file
53
tests/EventCourse/EventCourse.lang.php
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<?php declare(strict_types=1);
|
||||
return [
|
||||
'en' => [
|
||||
':language' => 'English',
|
||||
'Account' => 'Account',
|
||||
'Actual' => 'Actual',
|
||||
'Actuals' => 'Actuals',
|
||||
'AdditionalSupport' => 'Additional Support',
|
||||
'AdditionalSupportBudget' => 'Additional Support Budget',
|
||||
'AdviceBudget' => 'Advice Budget',
|
||||
'BriefingBudget' => 'Briefing & Training Budget',
|
||||
'Budget' => 'Budget',
|
||||
'CostCenter' => 'Cost Center',
|
||||
'CostObject' => 'Cost Object',
|
||||
'CourseBudget' => 'Course Budget',
|
||||
'Current' => 'Current',
|
||||
'Cutoff' => 'Cutoff',
|
||||
'Date' => 'Date',
|
||||
'Demo' => 'Demo',
|
||||
'DemoBudget' => 'Demo Budget',
|
||||
'Description' => 'Description',
|
||||
'Diff' => 'Diff',
|
||||
'DiffBudget%' => 'Diff Budget %',
|
||||
'DiffHistory%' => 'Diff History %',
|
||||
'End' => 'End',
|
||||
'EventCourse' => 'Event Course',
|
||||
'ExportCourseBudget' => 'Export Course Budget',
|
||||
'FiscalYearEnd' => 'Fiscal Year End',
|
||||
'FiscalYearStart' => 'Fiscal Year Start',
|
||||
'Forecast' => 'Forecast',
|
||||
'History' => 'History',
|
||||
'ID' => 'ID',
|
||||
'IMPLA' => 'IMPLA',
|
||||
'IMPLABudget' => 'IMPLA Budget',
|
||||
'MarketingSupport' => 'Marketing Support',
|
||||
'MarketingSupportBudget' => 'Marketing Support Budget',
|
||||
'Name' => 'Name',
|
||||
'Overview' => 'Overview',
|
||||
'Pending' => 'Pending',
|
||||
'Plan' => 'Plan',
|
||||
'Planning' => 'Planning',
|
||||
'Promotion' => 'Promotion',
|
||||
'PromotionBudget' => 'Promotion Budget',
|
||||
'Progress' => 'Progress',
|
||||
'Remaining' => 'Remaining',
|
||||
'RemainingForecast' => 'Remaining Forecast',
|
||||
'Roadshow' => 'Roadshow',
|
||||
'RoadshowBudget' => 'Roadshow Budget',
|
||||
'Start' => 'Start',
|
||||
'Total' => 'Total',
|
||||
'Type' => 'Type',
|
||||
],
|
||||
];
|
||||
0
tests/EventCourse/EventCourse.pdf.php
Normal file
0
tests/EventCourse/EventCourse.pdf.php
Normal file
441
tests/EventCourse/EventCourse.tpl.php
Normal file
441
tests/EventCourse/EventCourse.tpl.php
Normal file
|
|
@ -0,0 +1,441 @@
|
|||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* @var \phpOMS\Views\View $this
|
||||
*/
|
||||
$tcoll = $this->getData('tcoll');
|
||||
$rcoll = $this->getData('rcoll');
|
||||
$cLang = $this->getData('lang');
|
||||
$template = $this->getData('template');
|
||||
$report = $this->getData('report');
|
||||
|
||||
/** @noinspection PhpIncludeInspection */
|
||||
$reportLanguage = include __DIR__ . '/../../../../' . \ltrim($tcoll['lang']->getPath(), '/');
|
||||
$lang = $reportLanguage[$cLang];
|
||||
|
||||
require 'Worker.php';
|
||||
?>
|
||||
|
||||
<div class="tabview tab-2">
|
||||
<div class="box">
|
||||
<ul class="tab-links">
|
||||
<li><label for="c-tab-1"><?= $lang['Overview'] ?></label></li>
|
||||
<li><label for="c-tab-2"><?= $lang['Type'] ?></label></li>
|
||||
<li><label for="c-tab-3"><?= $lang['CostObject'] ?></label></li>
|
||||
<li><label for="c-tab-4"><?= $lang['CostCenter'] ?></label></li>
|
||||
<li><label for="c-tab-5"><?= $lang['Account'] ?></label></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="tab-content">
|
||||
<input type="radio" id="c-tab-1" name="tabular-2" checked>
|
||||
<div class="tab">
|
||||
<div class="box">
|
||||
<table class="default">
|
||||
<caption><?= $lang['Budget']; ?><i class="fa fa-download floatRight download btn"></i></caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="wf-100"><?= $lang['Description']; ?>
|
||||
<td><?= $lang['Budget']; ?>
|
||||
<td><?= $lang['Current']; ?>
|
||||
<td><?= $lang['Forecast']; ?>
|
||||
<td><?= $lang['History']; ?>
|
||||
<td><?= $lang['DiffBudget%']; ?>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><?= 'EventCourseInt' ?>
|
||||
<td><?= '?' ?>
|
||||
<td><?= \number_format($type['A'][$fiscal_end->format('Y')]['value'] ?? 0, 2, ',', '.') ?>
|
||||
<td><?= \number_format(0.00 / $month * 12, 2) ?>
|
||||
<td><?= \number_format(0.00, 2) ?>
|
||||
<td><?= '100.00%' ?>
|
||||
<tr>
|
||||
<td><?= 'EventCourse' ?>
|
||||
<td><?= '?' ?>
|
||||
<td><?= \number_format(($type['K'][$fiscal_end->format('Y')]['value'] ?? 0) + ($type['R'][$fiscal_end->format('Y')]['value'] ?? 0) + ($type['V'][$fiscal_end->format('Y')]['value'] ?? 0), 2, ',', '.') ?>
|
||||
<td><?= \number_format(0.00 / $month * 12, 2) ?>
|
||||
<td><?= \number_format(0.00, 2) ?>
|
||||
<td><?= '100.00%' ?>
|
||||
<tr>
|
||||
<td><?= 'Demo' ?>
|
||||
<td><?= '?' ?>
|
||||
<td><?= \number_format($type['D'][$fiscal_end->format('Y')]['value'] ?? 0, 2, ',', '.') ?>
|
||||
<td><?= \number_format(0.00 / $month * 12, 2) ?>
|
||||
<td><?= \number_format(0.00, 2) ?>
|
||||
<td><?= '100.00%' ?>
|
||||
<tr>
|
||||
<td><?= 'Briefing' ?>
|
||||
<td><?= '?' ?>
|
||||
<td><?= \number_format($type['E'][$fiscal_end->format('Y')]['value'] ?? 0, 2, ',', '.') ?>
|
||||
<td><?= \number_format(0.00 / $month * 12, 2) ?>
|
||||
<td><?= \number_format(0.00, 2) ?>
|
||||
<td><?= '100.00%' ?>
|
||||
<tr>
|
||||
<td><?= 'Advice' ?>
|
||||
<td><?= '?' ?>
|
||||
<td><?= \number_format($type['B'][$fiscal_end->format('Y')]['value'] ?? 0, 2, ',', '.') ?>
|
||||
<td><?= \number_format(0.00 / $month * 12, 2) ?>
|
||||
<td><?= \number_format(0.00, 2) ?>
|
||||
<td><?= '100.00%' ?>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="box">
|
||||
<table class="default">
|
||||
<caption><?= $lang['CostObject']; ?><i class="fa fa-download floatRight download btn"></i></caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<td><?= $lang['CostObject']; ?>
|
||||
<td class="wf-100"><?= $lang['Description']; ?>
|
||||
<td><?= $lang['History']; ?>
|
||||
<td><?= $lang['Current']; ?>
|
||||
<td><?= $lang['Forecast']; ?>
|
||||
<td><?= $lang['Diff']; ?>
|
||||
<tbody>
|
||||
<?php
|
||||
$sum_hist = 0.0;
|
||||
$sum_current = 0.0;
|
||||
$sum_forecast = 0.0;
|
||||
foreach ($types as $key => $stype) : ?>
|
||||
<tr>
|
||||
<td><?= $key ?>
|
||||
<td><?= $stype ?>
|
||||
<td><?= (\number_format($history = $type[$key][$fiscal_end_prev->format('Y')]['value'] ?? 0.0, 2, ',', '.')) ?>
|
||||
<td><?= (\number_format($current = $type[$key][$fiscal_end->format('Y')]['value'] ?? 0.0, 2, ',', '.')) ?>
|
||||
<td><?= (\number_format($forecast = ($type[$key][$fiscal_end->format('Y')]['value'] ?? 0.0) / \abs(((int) $fiscal_current->format('m') - ((int) $fiscal_end->format('m') + 1)) % 12 + 1) * 12, 2, ',', '.')) ?>
|
||||
<td><?= \number_format($history == 0 ? 0 : 100 * ($forecast - $history) / $history, 2, ',', '.') . '%' ?>
|
||||
<?php
|
||||
$sum_hist += $history;
|
||||
$sum_current += $current;
|
||||
$sum_forecast += $forecast;
|
||||
endforeach; ?>
|
||||
<tr>
|
||||
<td>
|
||||
<td><?= 'Total' ?>
|
||||
<td><?= \number_format($sum_hist, 2, ',', '.') ?>
|
||||
<td><?= \number_format($sum_current, 2, ',', '.') ?>
|
||||
<td><?= \number_format($sum_forecast, 2, ',', '.') ?>
|
||||
<td><?= \number_format($sum_hist === 0.0 ? 0 : (100 * $sum_forecast - $sum_hist) / $sum_hist, 2, ',', '.') . '%' ?>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="box">
|
||||
<table class="default">
|
||||
<caption><?= $lang['CostCenter']; ?><i class="fa fa-download floatRight download btn"></i></caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<td><?= $lang['CostCenter']; ?>
|
||||
<td class="wf-100"><?= $lang['Description']; ?>
|
||||
<td><?= $lang['History']; ?>
|
||||
<td><?= $lang['Current']; ?>
|
||||
<td><?= $lang['Forecast']; ?>
|
||||
<td><?= $lang['Diff']; ?>
|
||||
<tbody>
|
||||
<?php
|
||||
$sum_hist = 0.0;
|
||||
$sum_current = 0.0;
|
||||
$sum_forecast = 0.0;
|
||||
foreach ($costcenter as $key => $stype) : ?>
|
||||
<tr>
|
||||
<td><?= $key ?>
|
||||
<td><?= $ccDef[$key] ?>
|
||||
<td><?= (\number_format($history = $costcenter[$key][$fiscal_end_prev->format('Y')]['value'] ?? 0.0, 2, ',', '.')) ?>
|
||||
<td><?= (\number_format($current = $costcenter[$key][$fiscal_end->format('Y')]['value'] ?? 0.0, 2, ',', '.')) ?>
|
||||
<td><?= (\number_format($forecast = ($costcenter[$key][$fiscal_end->format('Y')]['value'] ?? 0.0) / \abs(((int) $fiscal_current->format('m') - ((int) $fiscal_end->format('m') + 1)) % 12 + 1) * 12, 2, ',', '.')) ?>
|
||||
<td><?= \number_format($history == 0 ? 0 : 100 * ($forecast - $history) / $history, 2, ',', '.') . '%' ?>
|
||||
<?php
|
||||
$sum_hist += $history;
|
||||
$sum_current += $current;
|
||||
$sum_forecast += $forecast;
|
||||
endforeach; ?>
|
||||
<tr>
|
||||
<td>
|
||||
<td><?= 'Total' ?>
|
||||
<td><?= \number_format($sum_hist, 2, ',', '.') ?>
|
||||
<td><?= \number_format($sum_current, 2, ',', '.') ?>
|
||||
<td><?= \number_format($sum_forecast, 2, ',', '.') ?>
|
||||
<td><?= \number_format($sum_hist === 0.0 ? 0 : 100 * ($sum_forecast - $sum_hist) / $sum_hist, 2, ',', '.') . '%' ?>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="box">
|
||||
<table class="default">
|
||||
<caption><?= $lang['Account']; ?><i class="fa fa-download floatRight download btn"></i></caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<td><?= $lang['Account']; ?>
|
||||
<td class="wf-100"><?= $lang['Description']; ?>
|
||||
<td><?= $lang['History']; ?>
|
||||
<td><?= $lang['Current']; ?>
|
||||
<td><?= $lang['Forecast']; ?>
|
||||
<td><?= $lang['Diff']; ?>
|
||||
<tbody>
|
||||
<?php
|
||||
$sum_hist = 0.0;
|
||||
$sum_current = 0.0;
|
||||
$sum_forecast = 0.0;
|
||||
foreach ($account as $key => $stype) : ?>
|
||||
<tr>
|
||||
<td><?= $key ?>
|
||||
<td><?= $acDef[$key] ?>
|
||||
<td><?= (\number_format($history = $account[$key][$fiscal_end_prev->format('Y')]['value'] ?? 0.0, 2, ',', '.')) ?>
|
||||
<td><?= (\number_format($current = $account[$key][$fiscal_end->format('Y')]['value'] ?? 0.0, 2, ',', '.')) ?>
|
||||
<td><?= (\number_format($forecast = ($account[$key][$fiscal_end->format('Y')]['value'] ?? 0.0) / \abs(((int) $fiscal_current->format('m') - ((int) $fiscal_end->format('m') + 1)) % 12 + 1) * 12, 2, ',', '.')) ?>
|
||||
<td><?= \number_format($history == 0 ? 0 : 100 * ($forecast - $history) / $history, 2, ',', '.') . '%' ?>
|
||||
<?php
|
||||
$sum_hist += $history;
|
||||
$sum_current += $current;
|
||||
$sum_forecast += $forecast;
|
||||
endforeach; ?>
|
||||
<tr>
|
||||
<td>
|
||||
<td><?= 'Total' ?>
|
||||
<td><?= \number_format($sum_hist, 2, ',', '.') ?>
|
||||
<td><?= \number_format($sum_current, 2, ',', '.') ?>
|
||||
<td><?= \number_format($sum_forecast, 2, ',', '.') ?>
|
||||
<td><?= \number_format($sum_hist === 0.0 ? 0 : 100 * ($sum_forecast - $sum_hist) / $sum_hist, 2, ',', '.') . '%' ?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<input type="radio" id="c-tab-2" name="tabular-2">
|
||||
<div class="tab">
|
||||
<section class="box">
|
||||
<table class="default">
|
||||
<caption><?= $lang['CostObject']; ?><i class="fa fa-download floatRight download btn"></i></caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<td><?= $lang['CostObject']; ?>
|
||||
<td><?= $lang['Date']; ?>
|
||||
<td class="wf-100"><?= $lang['Description']; ?>
|
||||
<td><?= $lang['Total']; ?>
|
||||
<tbody>
|
||||
<?php
|
||||
foreach ($costobject as $key => $co) :
|
||||
if (\strrpos($key, 'K', -\strlen($key)) !== false && isset($co[$fiscal_end->format('Y')]['value'])) : ?>
|
||||
<tr>
|
||||
<td><?= $key ?>
|
||||
<td>
|
||||
<td><?= $coDef[$key] ?? '' ?>
|
||||
<td><?= \number_format($co[$fiscal_end->format('Y')]['value'] ?? 0, 2, ',', '.') ?>
|
||||
<?php endif; endforeach; ?>
|
||||
<tr>
|
||||
<td>
|
||||
<td>
|
||||
<td><?= 'Total' ?>
|
||||
<td><?= \number_format($type['K'][$fiscal_end->format('Y')]['value'] ?? 0, 2, ',', '.') ?>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<section class="box">
|
||||
<table class="default">
|
||||
<caption><?= $lang['CostCenter']; ?><i class="fa fa-download floatRight download btn"></i></caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<td><?= $lang['CostCenter']; ?>
|
||||
<td class="wf-100"><?= $lang['Description']; ?>
|
||||
<td><?= $lang['Total']; ?>
|
||||
<tbody>
|
||||
<?php $loop = $type['K'][$fiscal_end->format('Y')]['cc'] ?? [];
|
||||
foreach ($loop as $key => $stype) : ?>
|
||||
<tr>
|
||||
<td><?= $key ?>
|
||||
<td><?= $ccDef[$key] ?? '' ?>
|
||||
<td><?= \number_format($stype, 2, ',', '.') ?>
|
||||
<?php endforeach; ?>
|
||||
<tr>
|
||||
<td>
|
||||
<td><?= 'Total' ?>
|
||||
<td><?= \number_format($type['K'][$fiscal_end->format('Y')]['value'] ?? 0, 2, ',', '.') ?>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<section class="box">
|
||||
<table class="default">
|
||||
<caption><?= $lang['Account']; ?><i class="fa fa-download floatRight download btn"></i></caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<td><?= $lang['Account']; ?>
|
||||
<td class="wf-100"><?= $lang['Description']; ?>
|
||||
<td><?= $lang['Total']; ?>
|
||||
<tbody>
|
||||
<?php $loop = $type['K'][$fiscal_end->format('Y')]['ac'] ?? [];
|
||||
foreach ($loop as $key => $stype) : ?>
|
||||
<tr>
|
||||
<td><?= $key ?>
|
||||
<td><?= $acDef[$key] ?? '' ?>
|
||||
<td><?= \number_format($stype, 2, ',', '.') ?>
|
||||
<?php endforeach; ?>
|
||||
<tr>
|
||||
<td>
|
||||
<td><?= 'Total' ?>
|
||||
<td><?= \number_format($type['K'][$fiscal_end->format('Y')]['value'] ?? 0, 2, ',', '.') ?>
|
||||
</table>
|
||||
</section>
|
||||
</div>
|
||||
<input type="radio" id="c-tab-3" name="tabular-2">
|
||||
<div class="tab">
|
||||
<section class="box">
|
||||
<table class="default">
|
||||
<caption><?= $lang['Account']; ?><i class="fa fa-download floatRight download btn"></i></caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<td><?= $lang['Account']; ?>
|
||||
<td class="wf-100"><?= $lang['Description']; ?>
|
||||
<td><?= $lang['Total']; ?>
|
||||
<tbody>
|
||||
<?php $loop = $costobject['K152333'][$fiscal_end->format('Y')]['ac'] ?? [];
|
||||
foreach ($loop as $key => $co) : ?>
|
||||
<tr>
|
||||
<td><?= $key ?>
|
||||
<td><?= $acDef[$key] ?? '' ?>
|
||||
<td><?= \number_format($co, 2, ',', '.') ?>
|
||||
<?php endforeach; ?>
|
||||
<tr>
|
||||
<td>
|
||||
<td><?= 'Total' ?>
|
||||
<td><?= \number_format($costobject['K152333'][$fiscal_end->format('Y')]['value'] ?? 0, 2, ',', '.') ?>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<section class="box">
|
||||
<table class="default">
|
||||
<caption><?= $lang['CostCenter']; ?><i class="fa fa-download floatRight download btn"></i></caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<td><?= $lang['CostCenter']; ?>
|
||||
<td class="wf-100"><?= $lang['Description']; ?>
|
||||
<td><?= $lang['Total']; ?>
|
||||
<tbody>
|
||||
<?php $loop = $costobject['K152333'][$fiscal_end->format('Y')]['cc'] ?? [];
|
||||
foreach ($loop as $key => $co) : ?>
|
||||
<tr>
|
||||
<td><?= $key ?>
|
||||
<td><?= $ccDef[$key] ?? '' ?>
|
||||
<td><?= \number_format($co, 2, ',', '.') ?>
|
||||
<?php endforeach; ?>
|
||||
<tr>
|
||||
<td>
|
||||
<td><?= 'Total' ?>
|
||||
<td><?= \number_format($costobject['K152333'][$fiscal_end->format('Y')]['value'] ?? 0, 2, ',', '.') ?>
|
||||
</table>
|
||||
</section>
|
||||
</div>
|
||||
<input type="radio" id="c-tab-4" name="tabular-2">
|
||||
<div class="tab">
|
||||
<section class="box">
|
||||
<table class="default">
|
||||
<caption><?= $lang['Account']; ?><i class="fa fa-download floatRight download btn"></i></caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<td><?= $lang['Account']; ?>
|
||||
<td class="wf-100"><?= $lang['Description']; ?>
|
||||
<td><?= $lang['Total']; ?>
|
||||
<tbody>
|
||||
<?php $loop = $costcenter[241][$fiscal_end->format('Y')]['ac'] ?? [];
|
||||
foreach ($loop as $key => $ac) : ?>
|
||||
<tr>
|
||||
<td><?= $key ?>
|
||||
<td><?= $acDef[$key] ?? '' ?>
|
||||
<td><?= \number_format($ac, 2, ',', '.') ?>
|
||||
<?php endforeach; ?>
|
||||
<tr>
|
||||
<td>
|
||||
<td><?= 'Total' ?>
|
||||
<td><?= \number_format($costcenter[241][$fiscal_end->format('Y')]['value'] ?? 0, 2, ',', '.') ?>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<section class="box">
|
||||
<table class="default">
|
||||
<caption><?= $lang['Type']; ?><i class="fa fa-download floatRight download btn"></i></caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<td><?= $lang['Type']; ?>
|
||||
<td class="wf-100"><?= $lang['Description']; ?>
|
||||
<td><?= $lang['Total']; ?>
|
||||
<tbody>
|
||||
<?php $loop = $costcenter[241][$fiscal_end->format('Y')]['type'] ?? [];
|
||||
foreach ($loop as $key => $co) : ?>
|
||||
<tr>
|
||||
<td><?= $key ?>
|
||||
<td><?= $types[$key] ?? '' ?>
|
||||
<td><?= \number_format($co, 2, ',', '.') ?>
|
||||
<?php endforeach; ?>
|
||||
<tr>
|
||||
<td>
|
||||
<td><?= 'Total' ?>
|
||||
<td><?= \number_format($costcenter[241][$fiscal_end->format('Y')]['value'] ?? 0, 2, ',', '.') ?>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<section class="box">
|
||||
<table class="default">
|
||||
<caption><?= $lang['CostObject']; ?><i class="fa fa-download floatRight download btn"></i></caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<td><?= $lang['CostObject']; ?>
|
||||
<td class="wf-100"><?= $lang['Description']; ?>
|
||||
<td><?= $lang['Total']; ?>
|
||||
<tbody>
|
||||
<?php $loop = $costcenter[241][$fiscal_end->format('Y')]['co'] ?? [];
|
||||
foreach ($loop as $key => $co) : ?>
|
||||
<tr>
|
||||
<td><?= $key ?>
|
||||
<td><?= $coDef[$key] ?? '' ?>
|
||||
<td><?= \number_format($co, 2, ',', '.') ?>
|
||||
<?php endforeach; ?>
|
||||
<tr>
|
||||
<td>
|
||||
<td><?= 'Total' ?>
|
||||
<td><?= \number_format($costcenter[241][$fiscal_end->format('Y')]['value'] ?? 0, 2, ',', '.') ?>
|
||||
</table>
|
||||
</section>
|
||||
</div>
|
||||
<input type="radio" id="c-tab-5" name="tabular-2">
|
||||
<div class="tab">
|
||||
<section class="box">
|
||||
<table class="default">
|
||||
<caption><?= $lang['Type']; ?><i class="fa fa-download floatRight download btn"></i></caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<td><?= $lang['Type']; ?>
|
||||
<td class="wf-100"><?= $lang['Description']; ?>
|
||||
<td><?= $lang['Total']; ?>
|
||||
<tbody>
|
||||
<?php $loop = $account[4480][$fiscal_end->format('Y')]['type'] ?? [];
|
||||
foreach ($loop as $key => $stype) : ?>
|
||||
<tr>
|
||||
<td><?= $key ?>
|
||||
<td><?= $types[$key] ?? '' ?>
|
||||
<td><?= \number_format($stype, 2, ',', '.') ?>
|
||||
<?php endforeach; ?>
|
||||
<tr>
|
||||
<td>
|
||||
<td><?= 'Total' ?>
|
||||
<td><?= \number_format($account[4480][$fiscal_end->format('Y')]['value'] ?? 0, 2, ',', '.') ?>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<section class="box">
|
||||
<table class="default">
|
||||
<caption><?= $lang['CostCenter']; ?><i class="fa fa-download floatRight download btn"></i></caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<td><?= $lang['CostCenter']; ?>
|
||||
<td class="wf-100"><?= $lang['Description']; ?>
|
||||
<td><?= $lang['Total']; ?>
|
||||
<tbody>
|
||||
<?php $loop = $account[4480][$fiscal_end->format('Y')]['cc'] ?? [];
|
||||
foreach ($loop as $key => $cc) : ?>
|
||||
<tr>
|
||||
<td><?= $key ?>
|
||||
<td><?= $ccDef[$key] ?? '' ?>
|
||||
<td><?= \number_format($cc, 2, ',', '.') ?>
|
||||
<?php endforeach; ?>
|
||||
<tr>
|
||||
<td>
|
||||
<td><?= 'Total' ?>
|
||||
<td><?= \number_format($account[4480][$fiscal_end->format('Y')]['value'] ?? 0, 2, ',', '.') ?>
|
||||
</table>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
1390
tests/EventCourse/EventCourse.xlsx.php
Normal file
1390
tests/EventCourse/EventCourse.xlsx.php
Normal file
File diff suppressed because it is too large
Load Diff
198
tests/EventCourse/Worker.php
Normal file
198
tests/EventCourse/Worker.php
Normal file
|
|
@ -0,0 +1,198 @@
|
|||
<?php declare(strict_types=1);
|
||||
$fiscal_end = new \phpOMS\Stdlib\Base\SmartDateTime('2016/06/30');
|
||||
$fiscal_current = new \phpOMS\Stdlib\Base\SmartDateTime('2015/09/30');
|
||||
$fiscal_start = new \phpOMS\Stdlib\Base\SmartDateTime('2015/07/01');
|
||||
$fiscal_start_prev = $fiscal_start->createModify(-1);
|
||||
$fiscal_end_prev = $fiscal_end->createModify(-1);
|
||||
|
||||
$acDef = [];
|
||||
$ccDef = [];
|
||||
$coDef = [];
|
||||
$acDef = [];
|
||||
$ccDef = [];
|
||||
$coDef = [];
|
||||
$courseList = [];
|
||||
$month = 1;
|
||||
|
||||
if (($path = \realpath($oPath = __DIR__ . '/' . $rcoll['crm.csv']->getPath())) !== false) {
|
||||
$file = \fopen($path, 'r');
|
||||
while (($line = \fgetcsv($file, 0, ';', '"')) !== false) {
|
||||
$courseList[$line[0]] = $line;
|
||||
}
|
||||
\fclose($file);
|
||||
}
|
||||
|
||||
if (($path = \realpath($oPath = __DIR__ . '/' . $rcoll['accounts.csv']->getPath())) !== false) {
|
||||
$file = \fopen($path, 'r');
|
||||
while (($line = \fgetcsv($file, 0, ';', '"')) !== false) {
|
||||
$acDef[$line[0]] = $line[1];
|
||||
}
|
||||
\fclose($file);
|
||||
}
|
||||
|
||||
if (($path = \realpath($oPath = __DIR__ . '/' . $rcoll['costcenters.csv']->getPath())) !== false) {
|
||||
$file = \fopen($path, 'r');
|
||||
while (($line = \fgetcsv($file, 0, ';', '"')) !== false) {
|
||||
$ccDef[$line[0]] = $line[1];
|
||||
}
|
||||
\fclose($file);
|
||||
}
|
||||
|
||||
if (($path = \realpath($oPath = __DIR__ . '/' . $rcoll['costobjects.csv']->getPath())) !== false) {
|
||||
$file = \fopen($path, 'r');
|
||||
while (($line = \fgetcsv($file, 0, ';', '"')) !== false) {
|
||||
$coDef[$line[0]] = $line[1];
|
||||
}
|
||||
\fclose($file);
|
||||
}
|
||||
|
||||
$accounts = [
|
||||
4450, 4455, 4480, 4482, 4483, 4484, 4485, 4490, 4653, 4671,
|
||||
];
|
||||
|
||||
$types = [
|
||||
'A' => 'EventCourseInt',
|
||||
'B' => 'Advice',
|
||||
'D' => 'Demo',
|
||||
'E' => 'Briefing',
|
||||
'I' => 'IMPLA',
|
||||
'K' => 'Course',
|
||||
'M' => 'MarketingSupport',
|
||||
'P' => 'Promotion',
|
||||
'R' => 'CourseRosbach',
|
||||
'S' => 'Roadshow',
|
||||
'U' => 'AdditionalSupport',
|
||||
'V' => 'Event',
|
||||
'' => 'Unknown',
|
||||
];
|
||||
|
||||
$account = [];
|
||||
$type = [];
|
||||
$costcenter = [];
|
||||
$costobject = [];
|
||||
|
||||
$total = [];
|
||||
|
||||
if (($path = \realpath($oPath = __DIR__ . '/' . $rcoll['entries.csv']->getPath())) !== false) {
|
||||
$file = \fopen($path, 'r');
|
||||
while (($line = \fgetcsv($file, 0, ',', '"')) !== false) {
|
||||
if (\in_array($line[10], $accounts)) {
|
||||
$date = new \phpOMS\Stdlib\Base\SmartDateTime($line[0]);
|
||||
$year = (int) $date->format('Y');
|
||||
$month = (int) $date->format('m');
|
||||
|
||||
$val_1 = (float) \str_replace(['.', ','], ['', '.'], $line[3]);
|
||||
$val_2 = (float) \str_replace(['.', ','], ['', '.'], $line[4]);
|
||||
$val = $val_1 - $val_2;
|
||||
|
||||
$t_name = empty($line[9]) ? '' : \substr($line[9], 0, 1);
|
||||
|
||||
if (!isset($account[$line[10]][$year][$month])) {
|
||||
$account[$line[10]][$year][$month] = 0.0;
|
||||
}
|
||||
|
||||
if (!isset($type[$t_name][$year][$month])) {
|
||||
$type[$t_name][$year][$month] = 0.0;
|
||||
}
|
||||
|
||||
if (!isset($costcenter[$line[8]][$year][$month])) {
|
||||
$costcenter[$line[8]][$year][$month] = 0.0;
|
||||
}
|
||||
|
||||
if (!isset($costobject[$line[9]][$year][$month])) {
|
||||
$costobject[$line[9]][$year][$month] = 0.0;
|
||||
}
|
||||
|
||||
$account[$line[10]][$year][$month] += $val;
|
||||
$type[$t_name][$year][$month] += $val;
|
||||
$costcenter[$line[8]][$year][$month] += $val;
|
||||
$costobject[$line[9]][$year][$month] += $val;
|
||||
|
||||
// Now
|
||||
if ($date->getTimestamp() >= $fiscal_start->getTimestamp() && $date->getTimestamp() <= $fiscal_current->getTimestamp()) {
|
||||
$fiscal_year = $fiscal_end->format('Y');
|
||||
} elseif ($date->getTimestamp() >= $fiscal_start_prev->getTimestamp() && $date->getTimestamp() <= $fiscal_end_prev->getTimestamp()) {
|
||||
$fiscal_year = $fiscal_end_prev->format('Y');
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($account[$line[10]][$fiscal_year]['value'])) {
|
||||
$account[$line[10]][$fiscal_year]['value'] = 0.0;
|
||||
}
|
||||
|
||||
if (!isset($account[$line[10]][$fiscal_year]['cc'][$line[8]])) {
|
||||
$account[$line[10]][$fiscal_year]['cc'][$line[8]] = 0.0;
|
||||
}
|
||||
|
||||
if (!isset($account[$line[10]][$fiscal_year]['type'][$t_name])) {
|
||||
$account[$line[10]][$fiscal_year]['type'][$t_name] = 0.0;
|
||||
}
|
||||
|
||||
if (!isset($account[$line[10]][$fiscal_year]['co'][$line[9]])) {
|
||||
$account[$line[10]][$fiscal_year]['co'][$line[9]] = 0.0;
|
||||
}
|
||||
|
||||
if (!isset($type[$t_name][$fiscal_year]['value'])) {
|
||||
$type[$t_name][$fiscal_year]['value'] = 0.0;
|
||||
}
|
||||
|
||||
if (!isset($type[$t_name][$fiscal_year]['cc'][$line[8]])) {
|
||||
$type[$t_name][$fiscal_year]['cc'][$line[8]] = 0.0;
|
||||
}
|
||||
|
||||
if (!isset($type[$t_name][$fiscal_year]['ac'][$line[10]])) {
|
||||
$type[$t_name][$fiscal_year]['ac'][$line[10]] = 0.0;
|
||||
}
|
||||
|
||||
if (!isset($costcenter[$line[8]][$fiscal_year]['value'])) {
|
||||
$costcenter[$line[8]][$fiscal_year]['value'] = 0.0;
|
||||
}
|
||||
|
||||
if (!isset($costcenter[$line[8]][$fiscal_year]['co'][$line[9]])) {
|
||||
$costcenter[$line[8]][$fiscal_year]['co'][$line[9]] = 0.0;
|
||||
}
|
||||
|
||||
if (!isset($costcenter[$line[8]][$fiscal_year]['ac'][$line[10]])) {
|
||||
$costcenter[$line[8]][$fiscal_year]['ac'][$line[10]] = 0.0;
|
||||
}
|
||||
|
||||
if (!isset($costcenter[$line[8]][$fiscal_year]['type'][$t_name])) {
|
||||
$costcenter[$line[8]][$fiscal_year]['type'][$t_name] = 0.0;
|
||||
}
|
||||
|
||||
if (!isset($costobject[$line[9]][$fiscal_year]['value'])) {
|
||||
$costobject[$line[9]][$fiscal_year]['value'] = 0.0;
|
||||
}
|
||||
|
||||
if (!isset($costobject[$line[9]][$fiscal_year]['ac'][$line[10]])) {
|
||||
$costobject[$line[9]][$fiscal_year]['ac'][$line[10]] = 0.0;
|
||||
}
|
||||
|
||||
if (!isset($costobject[$line[9]][$fiscal_year]['cc'][$line[8]])) {
|
||||
$costobject[$line[9]][$fiscal_year]['cc'][$line[8]] = 0.0;
|
||||
}
|
||||
|
||||
$account[$line[10]][$fiscal_year]['value'] += $val;
|
||||
$account[$line[10]][$fiscal_year]['cc'][$line[8]] += $val;
|
||||
$account[$line[10]][$fiscal_year]['type'][$t_name] += $val;
|
||||
$type[$t_name][$fiscal_year]['value'] += $val;
|
||||
$type[$t_name][$fiscal_year]['cc'][$line[8]] += $val;
|
||||
$type[$t_name][$fiscal_year]['ac'][$line[10]] += $val;
|
||||
$costcenter[$line[8]][$fiscal_year]['value'] += $val;
|
||||
$costcenter[$line[8]][$fiscal_year]['co'][$line[9]] += $val;
|
||||
$costcenter[$line[8]][$fiscal_year]['ac'][$line[10]] += $val;
|
||||
$costcenter[$line[8]][$fiscal_year]['type'][$t_name] += $val;
|
||||
$costobject[$line[9]][$fiscal_year]['value'] += $val;
|
||||
$costobject[$line[9]][$fiscal_year]['ac'][$line[10]] += $val;
|
||||
$costobject[$line[9]][$fiscal_year]['cc'][$line[8]] += $val;
|
||||
|
||||
if (!isset($total[$fiscal_year])) {
|
||||
$total[$fiscal_year] = 0.0;
|
||||
}
|
||||
|
||||
$total[$fiscal_year] += $val;
|
||||
}
|
||||
}
|
||||
\fclose($file);
|
||||
}
|
||||
101
tests/EventCourse/accounts.csv
Normal file
101
tests/EventCourse/accounts.csv
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
Account;Description
|
||||
1830;risus. Donec
|
||||
4659;non,
|
||||
2313;mauris a nunc.
|
||||
1795;commodo
|
||||
1090;sed sem
|
||||
7427;dictum ultricies ligula.
|
||||
7530;neque sed dictum
|
||||
4122;vitae odio
|
||||
2874;enim. Etiam
|
||||
2746;libero.
|
||||
5275;a
|
||||
5199;amet lorem semper
|
||||
4323;massa. Suspendisse eleifend.
|
||||
2538;fringilla
|
||||
5343;Sed
|
||||
1608;libero
|
||||
8505;neque sed dictum
|
||||
6757;eros turpis non
|
||||
6216;dignissim tempor
|
||||
5570;sem,
|
||||
8596;aliquet nec,
|
||||
5751;amet metus.
|
||||
3863;et
|
||||
2294;vel, faucibus
|
||||
8821;ipsum
|
||||
5234;dolor
|
||||
6867;porttitor eros
|
||||
6010;massa. Mauris vestibulum,
|
||||
5474;scelerisque scelerisque
|
||||
5205;Quisque
|
||||
4127;pede et risus.
|
||||
4786;Nam
|
||||
5580;penatibus et
|
||||
1164;cubilia
|
||||
3137;enim diam
|
||||
3272;Integer aliquam adipiscing
|
||||
3593;magna. Phasellus
|
||||
7403;massa. Suspendisse
|
||||
1166;congue a,
|
||||
3997;justo. Praesent luctus.
|
||||
4076;Quisque
|
||||
5795;vitae mauris
|
||||
5603;gravida
|
||||
8510;Integer in
|
||||
2714;leo. Morbi
|
||||
3503;vitae, aliquet
|
||||
4599;a
|
||||
5766;sit amet, consectetuer
|
||||
6602;elit pede, malesuada
|
||||
8262;Nulla
|
||||
2206;nec
|
||||
8548;ultrices posuere cubilia
|
||||
1747;Donec at
|
||||
4657;per inceptos hymenaeos.
|
||||
4144;Fusce
|
||||
2253;inceptos hymenaeos.
|
||||
6559;natoque penatibus
|
||||
5403;tellus sem mollis
|
||||
5340;nisl sem, consequat
|
||||
3017;nec enim.
|
||||
1619;Mauris
|
||||
6263;lobortis,
|
||||
2474;pellentesque massa lobortis
|
||||
2997;enim consequat purus.
|
||||
8454;neque
|
||||
4550;Ut
|
||||
2856;velit. Pellentesque ultricies
|
||||
7643;rutrum. Fusce dolor
|
||||
8509;a, facilisis non,
|
||||
6690;Nunc quis arcu
|
||||
7134;nibh.
|
||||
1466;et, eros.
|
||||
5825;libero
|
||||
7847;nulla. Integer
|
||||
2281;quis lectus.
|
||||
8009;Maecenas ornare
|
||||
3205;luctus
|
||||
1673;non enim commodo
|
||||
1586;diam
|
||||
8527;ante ipsum
|
||||
6356;nunc nulla vulputate
|
||||
5517;sem
|
||||
5490;vitae erat vel
|
||||
7156;velit in
|
||||
2058;in aliquet lobortis,
|
||||
8245;nisi.
|
||||
2943;habitant morbi tristique
|
||||
4782;nunc interdum
|
||||
7791;quis urna. Nunc
|
||||
7658;Ut sagittis lobortis
|
||||
3225;volutpat
|
||||
3573;lacus. Etiam
|
||||
4769;mattis ornare, lectus
|
||||
7816;nisi dictum augue
|
||||
7458;tincidunt. Donec vitae
|
||||
6948;enim.
|
||||
8309;cursus. Nunc
|
||||
2651;tempor
|
||||
8279;Ut
|
||||
7193;primis in faucibus
|
||||
|
0
tests/EventCourse/costcenters.csv
Normal file
0
tests/EventCourse/costcenters.csv
Normal file
|
|
0
tests/EventCourse/costobjects.csv
Normal file
0
tests/EventCourse/costobjects.csv
Normal file
|
|
0
tests/EventCourse/crm.csv
Normal file
0
tests/EventCourse/crm.csv
Normal file
|
|
0
tests/EventCourse/entries.csv
Normal file
0
tests/EventCourse/entries.csv
Normal file
|
|
183
tests/Models/ReportMapperTest.php
Normal file
183
tests/Models/ReportMapperTest.php
Normal file
|
|
@ -0,0 +1,183 @@
|
|||
<?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\tests\Helper\Models;
|
||||
|
||||
use Modules\Admin\Models\NullAccount;
|
||||
use Modules\Helper\Models\HelperStatus;
|
||||
use Modules\Helper\Models\Report;
|
||||
use Modules\Helper\Models\ReportMapper;
|
||||
use Modules\Helper\Models\Template;
|
||||
use Modules\Helper\Models\TemplateDataType;
|
||||
use Modules\Media\Models\Collection;
|
||||
use Modules\Media\Models\Media;
|
||||
|
||||
/**
|
||||
* @testdox Modules\tests\Helper\Models\ReportMapperTest: Report database mapper
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ReportMapperTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
private function createTemplate()
|
||||
{
|
||||
$template = new Template();
|
||||
|
||||
$template->setCreatedBy(new NullAccount(1));
|
||||
$template->setName('Report Template');
|
||||
$template->setStatus(HelperStatus::ACTIVE);
|
||||
$template->setDescription('Description');
|
||||
$template->setDatatype(TemplateDataType::OTHER);
|
||||
$template->setStandalone(false);
|
||||
$template->setExpected(['source1.csv', 'source2.csv']);
|
||||
|
||||
$collection = new Collection();
|
||||
$collection->setCreatedBy(new NullAccount(1));
|
||||
|
||||
$templateFiles = [
|
||||
[
|
||||
'extension' => 'php',
|
||||
'filename' => 'EventCourse.lang.php',
|
||||
'name' => 'EventCourse',
|
||||
'path' => '/Demo/Modules/Helper/EventCourse',
|
||||
'size' => 1,
|
||||
],
|
||||
[
|
||||
'extension' => 'php',
|
||||
'filename' => 'EventCourse.pdf.php',
|
||||
'name' => 'EventCourse',
|
||||
'path' => '/Demo/Modules/Helper/EventCourse',
|
||||
'size' => 1,
|
||||
],
|
||||
[
|
||||
'extension' => 'php',
|
||||
'filename' => 'EventCourse.tpl.php',
|
||||
'name' => 'EventCourse',
|
||||
'path' => '/Demo/Modules/Helper/EventCourse',
|
||||
'size' => 1,
|
||||
],
|
||||
[
|
||||
'extension' => 'php',
|
||||
'filename' => 'EventCourse.xlsx.php',
|
||||
'name' => 'EventCourse',
|
||||
'path' => '/Demo/Modules/Helper/EventCourse',
|
||||
'size' => 1,
|
||||
],
|
||||
[
|
||||
'extension' => 'php',
|
||||
'filename' => 'Worker.php',
|
||||
'name' => 'Worker',
|
||||
'path' => '/Demo/Modules/Helper/EventCourse',
|
||||
'size' => 1,
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($templateFiles as $file) {
|
||||
$media = new Media();
|
||||
$media->setCreatedBy(new NullAccount(1));
|
||||
$media->setExtension($file['extension']);
|
||||
$media->setPath(\trim($file['path'], '/') . '/' . $file['filename']);
|
||||
$media->setName($file['name']);
|
||||
$media->setSize($file['size']);
|
||||
|
||||
$collection->addSource($media);
|
||||
}
|
||||
|
||||
$template->setSource($collection);
|
||||
|
||||
return $template;
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The model can be created and read from the database
|
||||
* @covers Modules\Helper\Models\ReportMapper
|
||||
* @group module
|
||||
*/
|
||||
public function testCR() : void
|
||||
{
|
||||
$report = new Report();
|
||||
|
||||
$report->setCreatedBy(new NullAccount(1));
|
||||
$report->setTitle('Title');
|
||||
$report->setStatus(HelperStatus::ACTIVE);
|
||||
$report->setDescription('Description');
|
||||
$report->setTemplate($this->createTemplate());
|
||||
|
||||
$collection = new Collection();
|
||||
$collection->setCreatedBy(new NullAccount(1));
|
||||
|
||||
$reportFiles = [
|
||||
[
|
||||
'extension' => 'csv',
|
||||
'filename' => 'accounts.csv',
|
||||
'name' => 'accounts',
|
||||
'path' => 'Demo/Modules/Helper/EventCourse',
|
||||
'size' => 1,
|
||||
],
|
||||
[
|
||||
'extension' => 'csv',
|
||||
'filename' => 'costcenters.csv',
|
||||
'name' => 'costcenters',
|
||||
'path' => 'Demo/Modules/Helper/EventCourse',
|
||||
'size' => 1,
|
||||
],
|
||||
[
|
||||
'extension' => 'csv',
|
||||
'filename' => 'costobjects.csv',
|
||||
'name' => 'costobjects',
|
||||
'path' => 'Demo/Modules/Helper/EventCourse',
|
||||
'size' => 1,
|
||||
],
|
||||
[
|
||||
'extension' => 'csv',
|
||||
'filename' => 'crm.csv',
|
||||
'name' => 'crm',
|
||||
'path' => 'Demo/Modules/Helper/EventCourse',
|
||||
'size' => 1,
|
||||
],
|
||||
[
|
||||
'extension' => 'csv',
|
||||
'filename' => 'entries.csv',
|
||||
'name' => 'entries',
|
||||
'path' => 'Demo/Modules/Helper/EventCourse',
|
||||
'size' => 1,
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($reportFiles as $file) {
|
||||
$media = new Media();
|
||||
$media->setCreatedBy(new NullAccount(1));
|
||||
$media->setExtension($file['extension']);
|
||||
$media->setPath(\trim($file['path'], '/') . '/' . $file['filename']);
|
||||
$media->setName($file['name']);
|
||||
$media->setSize($file['size']);
|
||||
|
||||
$collection->addSource($media);
|
||||
}
|
||||
|
||||
$report->setSource($collection);
|
||||
|
||||
$id = ReportMapper::create($report);
|
||||
self::assertGreaterThan(0, $report->getId());
|
||||
self::assertEquals($id, $report->getId());
|
||||
|
||||
$reportR = ReportMapper::get($report->getId());
|
||||
self::assertEquals($report->getCreatedAt()->format('Y-m-d'), $reportR->getCreatedAt()->format('Y-m-d'));
|
||||
self::assertEquals($report->getCreatedBy()->getId(), $reportR->getCreatedBy()->getId());
|
||||
self::assertEquals($report->getDescription(), $reportR->getDescription());
|
||||
self::assertEquals($report->getTitle(), $reportR->getTitle());
|
||||
self::assertEquals($report->getStatus(), $reportR->getStatus());
|
||||
self::assertEquals($report->getTemplate()->getName(), $reportR->getTemplate()->getName());
|
||||
}
|
||||
}
|
||||
191
tests/Models/ReportTest.php
Normal file
191
tests/Models/ReportTest.php
Normal file
|
|
@ -0,0 +1,191 @@
|
|||
<?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\tests\Helper\Models;
|
||||
|
||||
use Modules\Admin\Models\NullAccount;
|
||||
use Modules\Helper\Models\HelperStatus;
|
||||
use Modules\Helper\Models\NullTemplate;
|
||||
use Modules\Helper\Models\Report;
|
||||
use Modules\Media\Models\NullCollection;
|
||||
|
||||
/**
|
||||
* @testdox Modules\tests\Helper\Models\ReportTest: Report model
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ReportTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
protected Report $report;
|
||||
|
||||
protected function setUp() : void
|
||||
{
|
||||
$this->report = new Report();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The model has the expected default values after initialization
|
||||
* @covers Modules\Helper\Models\Report
|
||||
* @group module
|
||||
*/
|
||||
public function testDefault() : void
|
||||
{
|
||||
self::assertEquals(0, $this->report->getId());
|
||||
self::assertEquals(0, $this->report->getCreatedBy()->getId());
|
||||
self::assertEquals((new \DateTime('now'))->format('Y-m-d'), $this->report->getCreatedAt()->format('Y-m-d'));
|
||||
self::assertEquals('', $this->report->getTitle());
|
||||
self::assertEquals(HelperStatus::INACTIVE, $this->report->getStatus());
|
||||
self::assertEquals('', $this->report->getDescription());
|
||||
self::assertEquals('', $this->report->getDescriptionRaw());
|
||||
self::assertEquals(0, $this->report->getTemplate()->getId());
|
||||
self::assertEquals(0, $this->report->getSource()->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The creator can be set and returned correctly
|
||||
* @covers Modules\Helper\Models\Report
|
||||
* @group module
|
||||
*/
|
||||
public function testCreatedByInputOutput() : void
|
||||
{
|
||||
$this->report->setCreatedBy(new NullAccount(1));
|
||||
self::assertEquals(1, $this->report->getCreatedBy()->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The title can be set and returned correctly
|
||||
* @covers Modules\Helper\Models\Report
|
||||
* @group module
|
||||
*/
|
||||
public function testTitleInputOutput() : void
|
||||
{
|
||||
$this->report->setTitle('Title');
|
||||
self::assertEquals('Title', $this->report->getTitle());
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The status can be set and returned correctly
|
||||
* @covers Modules\Helper\Models\Report
|
||||
* @group module
|
||||
*/
|
||||
public function testStatusInputOutput() : void
|
||||
{
|
||||
$this->report->setStatus(HelperStatus::ACTIVE);
|
||||
self::assertEquals(HelperStatus::ACTIVE, $this->report->getStatus());
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The description can be set and returned correctly
|
||||
* @covers Modules\Helper\Models\Report
|
||||
* @group module
|
||||
*/
|
||||
public function testDescriptionInputOutput() : void
|
||||
{
|
||||
$this->report->setDescription('Description');
|
||||
self::assertEquals('Description', $this->report->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The raw description can be set and returned correctly
|
||||
* @covers Modules\Helper\Models\Report
|
||||
* @group module
|
||||
*/
|
||||
public function testDescriptionRawInputOutput() : void
|
||||
{
|
||||
$this->report->setDescriptionRaw('DescriptionRaw');
|
||||
self::assertEquals('DescriptionRaw', $this->report->getDescriptionRaw());
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The template can be set and returned correctly
|
||||
* @covers Modules\Helper\Models\Report
|
||||
* @group module
|
||||
*/
|
||||
public function testTemplateInputOutput() : void
|
||||
{
|
||||
$this->report->setTemplate(new NullTemplate(11));
|
||||
self::assertEquals(11, $this->report->getTemplate()->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The source can be set and returned correctly
|
||||
* @covers Modules\Helper\Models\Report
|
||||
* @group module
|
||||
*/
|
||||
public function testSourceInputOutput() : void
|
||||
{
|
||||
$this->report->setSource(new NullCollection(4));
|
||||
self::assertEquals(4, $this->report->getSource()->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox Report data can be turned into an array
|
||||
* @covers Modules\Helper\Models\Report
|
||||
* @group module
|
||||
*/
|
||||
public function testToArray() : void
|
||||
{
|
||||
$this->report->setTemplate(new NullTemplate(11));
|
||||
$this->report->setTitle('testTitle');
|
||||
$this->report->setDescription('testDescription');
|
||||
$this->report->setDescriptionRaw('testDescriptionRaw');
|
||||
|
||||
$array = $this->report->toArray();
|
||||
$expected = [
|
||||
'id' => 0,
|
||||
'name' => 'testTitle',
|
||||
'description' => 'testDescription',
|
||||
'descriptionRaw' => 'testDescriptionRaw',
|
||||
'status' => HelperStatus::INACTIVE,
|
||||
];
|
||||
|
||||
foreach ($expected as $key => $e) {
|
||||
if (!isset($array[$key]) || $array[$key] !== $e) {
|
||||
self::assertTrue(false);
|
||||
}
|
||||
}
|
||||
|
||||
self::assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox Report data can be json serialized
|
||||
* @covers Modules\Helper\Models\Report
|
||||
* @group module
|
||||
*/
|
||||
public function testJsonSerialize() : void
|
||||
{
|
||||
$this->report->setTemplate(new NullTemplate(11));
|
||||
$this->report->setTitle('testTitle');
|
||||
$this->report->setDescription('testDescription');
|
||||
$this->report->setDescriptionRaw('testDescriptionRaw');
|
||||
|
||||
$array = $this->report->jsonSerialize();
|
||||
$expected = [
|
||||
'id' => 0,
|
||||
'name' => 'testTitle',
|
||||
'description' => 'testDescription',
|
||||
'descriptionRaw' => 'testDescriptionRaw',
|
||||
'status' => HelperStatus::INACTIVE,
|
||||
];
|
||||
|
||||
foreach ($expected as $key => $e) {
|
||||
if (!isset($array[$key]) || $array[$key] !== $e) {
|
||||
self::assertTrue(false);
|
||||
}
|
||||
}
|
||||
|
||||
self::assertTrue(true);
|
||||
}
|
||||
}
|
||||
131
tests/Models/TemplateMapperTest.php
Normal file
131
tests/Models/TemplateMapperTest.php
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
<?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\tests\Helper\Models;
|
||||
|
||||
use Modules\Admin\Models\NullAccount;
|
||||
use Modules\Helper\Models\HelperStatus;
|
||||
use Modules\Helper\Models\Template;
|
||||
use Modules\Helper\Models\TemplateDataType;
|
||||
use Modules\Helper\Models\TemplateMapper;
|
||||
use Modules\Media\Models\Collection;
|
||||
use Modules\Media\Models\Media;
|
||||
|
||||
/**
|
||||
* @testdox Modules\tests\Helper\Models\TemplateMapperTest: Template database mapper
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class TemplateMapperTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox The model can be created and read from the database
|
||||
* @covers Modules\Helper\Models\TemplateMapper
|
||||
* @group module
|
||||
*/
|
||||
public function testCR() : void
|
||||
{
|
||||
$template = new Template();
|
||||
|
||||
$template->setCreatedBy(new NullAccount(1));
|
||||
$template->setName('Title');
|
||||
$template->setStatus(HelperStatus::ACTIVE);
|
||||
$template->setDescription('Description');
|
||||
$template->setDescriptionRaw('DescriptionRaw');
|
||||
$template->setDatatype(TemplateDataType::OTHER);
|
||||
$template->setStandalone(false);
|
||||
$template->setExpected(['source1.csv', 'source2.csv']);
|
||||
|
||||
$collection = new Collection();
|
||||
$collection->setCreatedBy(new NullAccount(1));
|
||||
|
||||
$templateFiles = [
|
||||
[
|
||||
'extension' => 'php',
|
||||
'filename' => 'EventCourse.lang.php',
|
||||
'name' => 'EventCourse',
|
||||
'path' => '/Demo/Modules/Helper/EventCourse',
|
||||
'size' => 1,
|
||||
],
|
||||
[
|
||||
'extension' => 'php',
|
||||
'filename' => 'EventCourse.pdf.php',
|
||||
'name' => 'EventCourse',
|
||||
'path' => '/Demo/Modules/Helper/EventCourse',
|
||||
'size' => 1,
|
||||
],
|
||||
[
|
||||
'extension' => 'php',
|
||||
'filename' => 'EventCourse.tpl.php',
|
||||
'name' => 'EventCourse',
|
||||
'path' => '/Demo/Modules/Helper/EventCourse',
|
||||
'size' => 1,
|
||||
],
|
||||
[
|
||||
'extension' => 'php',
|
||||
'filename' => 'EventCourse.xlsx.php',
|
||||
'name' => 'EventCourse',
|
||||
'path' => '/Demo/Modules/Helper/EventCourse',
|
||||
'size' => 1,
|
||||
],
|
||||
[
|
||||
'extension' => 'php',
|
||||
'filename' => 'Worker.php',
|
||||
'name' => 'Worker',
|
||||
'path' => '/Demo/Modules/Helper/EventCourse',
|
||||
'size' => 1,
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($templateFiles as $file) {
|
||||
$media = new Media();
|
||||
$media->setCreatedBy(new NullAccount(1));
|
||||
$media->setExtension($file['extension']);
|
||||
$media->setPath(\trim($file['path'], '/') . '/' . $file['filename']);
|
||||
$media->setName($file['name']);
|
||||
$media->setSize($file['size']);
|
||||
|
||||
$collection->addSource($media);
|
||||
}
|
||||
|
||||
$template->setSource($collection);
|
||||
|
||||
$id = TemplateMapper::create($template);
|
||||
self::assertGreaterThan(0, $template->getId());
|
||||
self::assertEquals($id, $template->getId());
|
||||
|
||||
$templateR = TemplateMapper::get($template->getId());
|
||||
self::assertEquals($template->getCreatedAt()->format('Y-m-d'), $templateR->getCreatedAt()->format('Y-m-d'));
|
||||
self::assertEquals($template->getCreatedBy()->getId(), $templateR->getCreatedBy()->getId());
|
||||
self::assertEquals($template->getDescription(), $templateR->getDescription());
|
||||
self::assertEquals($template->getDescriptionRaw(), $templateR->getDescriptionRaw());
|
||||
self::assertEquals($template->getName(), $templateR->getName());
|
||||
self::assertEquals($template->getStatus(), $templateR->getStatus());
|
||||
self::assertEquals($template->isStandalone(), $templateR->isStandalone());
|
||||
self::assertEquals($template->getDatatype(), $templateR->getDatatype());
|
||||
self::assertEquals($template->getExpected(), $templateR->getExpected());
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The newest model can be read from the database
|
||||
* @covers Modules\Helper\Models\TemplateMapper
|
||||
* @group module
|
||||
*/
|
||||
public function testNewest() : void
|
||||
{
|
||||
$newest = TemplateMapper::getNewest(1);
|
||||
|
||||
self::assertCount(1, $newest);
|
||||
}
|
||||
}
|
||||
234
tests/Models/TemplateTest.php
Normal file
234
tests/Models/TemplateTest.php
Normal file
|
|
@ -0,0 +1,234 @@
|
|||
<?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\tests\Helper\Models;
|
||||
|
||||
use Modules\Admin\Models\NullAccount;
|
||||
use Modules\Helper\Models\HelperStatus;
|
||||
use Modules\Helper\Models\NullReport;
|
||||
use Modules\Helper\Models\Template;
|
||||
use Modules\Helper\Models\TemplateDataType;
|
||||
use Modules\Media\Models\NullCollection;
|
||||
use Modules\Organization\Models\NullUnit;
|
||||
|
||||
/**
|
||||
* @testdox Modules\tests\Helper\Models\TemplateTest: Template model
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class TemplateTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
protected Template $template;
|
||||
|
||||
protected function setUp() : void
|
||||
{
|
||||
$this->template = new Template();
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The model has the expected default values after initialization
|
||||
* @covers Modules\Helper\Models\Template
|
||||
* @group module
|
||||
*/
|
||||
public function testDefault() : void
|
||||
{
|
||||
self::assertEquals(0, $this->template->getId());
|
||||
self::assertEquals(0, $this->template->getUnit()->getId());
|
||||
self::assertEquals(0, $this->template->getCreatedBy()->getId());
|
||||
self::assertEquals((new \DateTime('now'))->format('Y-m-d'), $this->template->getCreatedAt()->format('Y-m-d'));
|
||||
self::assertEquals('', $this->template->getName());
|
||||
self::assertEquals(HelperStatus::INACTIVE, $this->template->getStatus());
|
||||
self::assertEquals('', $this->template->getDescription());
|
||||
self::assertEquals('', $this->template->getDescriptionRaw());
|
||||
self::assertEquals([], $this->template->getExpected());
|
||||
self::assertEquals(0, $this->template->getSource()->getId());
|
||||
self::assertFalse($this->template->isStandalone());
|
||||
self::assertEquals(TemplateDataType::OTHER, $this->template->getDatatype());
|
||||
self::assertInstanceOf(NullReport::class, $this->template->getNewestReport());
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The unit can be set and returned correctly
|
||||
* @covers Modules\Helper\Models\Template
|
||||
* @group module
|
||||
*/
|
||||
public function testUnitInputOutput() : void
|
||||
{
|
||||
$this->template->setUnit(new NullUnit(1));
|
||||
self::assertEquals(1, $this->template->getUnit()->getId());
|
||||
}
|
||||
/**
|
||||
* @testdox The creator can be set and returned correctly
|
||||
* @covers Modules\Helper\Models\Template
|
||||
* @group module
|
||||
*/
|
||||
public function testCreatedByInputOutput() : void
|
||||
{
|
||||
$this->template->setCreatedBy(new NullAccount(1));
|
||||
self::assertEquals(1, $this->template->getCreatedBy()->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The title can be set and returned correctly
|
||||
* @covers Modules\Helper\Models\Template
|
||||
* @group module
|
||||
*/
|
||||
public function testNameInputOutput() : void
|
||||
{
|
||||
$this->template->setName('Title');
|
||||
self::assertEquals('Title', $this->template->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The status can be set and returned correctly
|
||||
* @covers Modules\Helper\Models\Template
|
||||
* @group module
|
||||
*/
|
||||
public function testStatusInputOutput() : void
|
||||
{
|
||||
$this->template->setStatus(HelperStatus::ACTIVE);
|
||||
self::assertEquals(HelperStatus::ACTIVE, $this->template->getStatus());
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The template can be set as standalone and returned correctly
|
||||
* @covers Modules\Helper\Models\Template
|
||||
* @group module
|
||||
*/
|
||||
public function testStandalonInputOutput() : void
|
||||
{
|
||||
$this->template->setStandalone(true);
|
||||
self::assertTrue($this->template->isStandalone());
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The description can be set and returned correctly
|
||||
* @covers Modules\Helper\Models\Template
|
||||
* @group module
|
||||
*/
|
||||
public function testDescriptionInputOutput() : void
|
||||
{
|
||||
$this->template->setDescription('Description');
|
||||
self::assertEquals('Description', $this->template->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The raw description can be set and returned correctly
|
||||
* @covers Modules\Helper\Models\Template
|
||||
* @group module
|
||||
*/
|
||||
public function testDescriptionRawInputOutput() : void
|
||||
{
|
||||
$this->template->setDescriptionRaw('DescriptionRaw');
|
||||
self::assertEquals('DescriptionRaw', $this->template->getDescriptionRaw());
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The expected report files can be set and returned correctly
|
||||
* @covers Modules\Helper\Models\Template
|
||||
* @group module
|
||||
*/
|
||||
public function testExpectedInputOutput() : void
|
||||
{
|
||||
$this->template->setExpected(['source1.csv', 'source2.csv']);
|
||||
$this->template->addExpected('source3.csv');
|
||||
self::assertEquals(['source1.csv', 'source2.csv', 'source3.csv'], $this->template->getExpected());
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The source can be set and returned correctly
|
||||
* @covers Modules\Helper\Models\Template
|
||||
* @group module
|
||||
*/
|
||||
public function testSourceInputOutput() : void
|
||||
{
|
||||
$this->template->setSource(new NullCollection(4));
|
||||
self::assertEquals(4, $this->template->getSource()->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The data storage type can be set and returned correctly
|
||||
* @covers Modules\Helper\Models\Template
|
||||
* @group module
|
||||
*/
|
||||
public function testDatatypeInputOutput() : void
|
||||
{
|
||||
$this->template->setDatatype(TemplateDataType::GLOBAL_DB);
|
||||
self::assertEquals(TemplateDataType::GLOBAL_DB, $this->template->getDatatype());
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox Template data can be turned into an array
|
||||
* @covers Modules\Helper\Models\Template
|
||||
* @group module
|
||||
*/
|
||||
public function testToArray() : void
|
||||
{
|
||||
$this->template->setName('testName');
|
||||
$this->template->setDescription('testDescription');
|
||||
$this->template->setDescriptionRaw('testDescriptionRaw');
|
||||
$this->template->setStandalone(true);
|
||||
|
||||
$array = $this->template->toArray();
|
||||
$expected = [
|
||||
'id' => 0,
|
||||
'name' => 'testName',
|
||||
'description' => 'testDescription',
|
||||
'descriptionRaw' => 'testDescriptionRaw',
|
||||
'status' => HelperStatus::INACTIVE,
|
||||
'datatype' => TemplateDataType::OTHER,
|
||||
'standalone' => true,
|
||||
];
|
||||
|
||||
foreach ($expected as $key => $e) {
|
||||
if (!isset($array[$key]) || $array[$key] !== $e) {
|
||||
self::assertTrue(false);
|
||||
}
|
||||
}
|
||||
|
||||
self::assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox Template data can be json serialized
|
||||
* @covers Modules\Helper\Models\Template
|
||||
* @group module
|
||||
*/
|
||||
public function testJsonSerialize() : void
|
||||
{
|
||||
$this->template->setName('testName');
|
||||
$this->template->setDescription('testDescription');
|
||||
$this->template->setDescriptionRaw('testDescriptionRaw');
|
||||
$this->template->setStandalone(true);
|
||||
|
||||
$array = $this->template->jsonSerialize();
|
||||
$expected = [
|
||||
'id' => 0,
|
||||
'name' => 'testName',
|
||||
'description' => 'testDescription',
|
||||
'descriptionRaw' => 'testDescriptionRaw',
|
||||
'status' => HelperStatus::INACTIVE,
|
||||
'datatype' => TemplateDataType::OTHER,
|
||||
'standalone' => true,
|
||||
];
|
||||
|
||||
foreach ($expected as $key => $e) {
|
||||
if (!isset($array[$key]) || $array[$key] !== $e) {
|
||||
self::assertTrue(false);
|
||||
}
|
||||
}
|
||||
|
||||
self::assertTrue(true);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user