mirror of
https://github.com/Karaka-Management/oms-Support.git
synced 2026-01-11 17:18:40 +00:00
fix tests
This commit is contained in:
parent
c6fa654c15
commit
ee38d36f2a
|
|
@ -88,207 +88,5 @@
|
|||
"foreignKey": "support_ticket_id"
|
||||
}
|
||||
}
|
||||
},
|
||||
"support_attr_type": {
|
||||
"name": "support_attr_type",
|
||||
"fields": {
|
||||
"support_attr_type_id": {
|
||||
"name": "support_attr_type_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"support_attr_type_name": {
|
||||
"name": "support_attr_type_name",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
},
|
||||
"support_attr_type_fields": {
|
||||
"name": "support_attr_type_fields",
|
||||
"type": "INT(11)",
|
||||
"null": false
|
||||
},
|
||||
"support_attr_type_custom": {
|
||||
"name": "support_attr_type_custom",
|
||||
"type": "TINYINT(1)",
|
||||
"null": false
|
||||
},
|
||||
"support_attr_type_required": {
|
||||
"description": "Every ticket must have this attribute type if set to true.",
|
||||
"name": "support_attr_type_required",
|
||||
"type": "TINYINT(1)",
|
||||
"null": false
|
||||
},
|
||||
"support_attr_type_pattern": {
|
||||
"description": "This is a regex validation pattern.",
|
||||
"name": "support_attr_type_pattern",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"support_attr_type_l11n": {
|
||||
"name": "support_attr_type_l11n",
|
||||
"fields": {
|
||||
"support_attr_type_l11n_id": {
|
||||
"name": "support_attr_type_l11n_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"support_attr_type_l11n_title": {
|
||||
"name": "support_attr_type_l11n_title",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
},
|
||||
"support_attr_type_l11n_type": {
|
||||
"name": "support_attr_type_l11n_type",
|
||||
"type": "INT(11)",
|
||||
"null": false,
|
||||
"foreignTable": "support_attr_type",
|
||||
"foreignKey": "support_attr_type_id"
|
||||
},
|
||||
"support_attr_type_l11n_lang": {
|
||||
"name": "support_attr_type_l11n_lang",
|
||||
"type": "VARCHAR(2)",
|
||||
"null": false,
|
||||
"foreignTable": "language",
|
||||
"foreignKey": "language_639_1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"support_attr_value": {
|
||||
"name": "support_attr_value",
|
||||
"fields": {
|
||||
"support_attr_value_id": {
|
||||
"name": "support_attr_value_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"support_attr_value_default": {
|
||||
"name": "support_attr_value_default",
|
||||
"type": "TINYINT(1)",
|
||||
"null": false
|
||||
},
|
||||
"support_attr_value_valueStr": {
|
||||
"name": "support_attr_value_valueStr",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": true,
|
||||
"default": null
|
||||
},
|
||||
"support_attr_value_valueInt": {
|
||||
"name": "support_attr_value_valueInt",
|
||||
"type": "INT(11)",
|
||||
"null": true,
|
||||
"default": null
|
||||
},
|
||||
"support_attr_value_valueDec": {
|
||||
"name": "support_attr_value_valueDec",
|
||||
"type": "DECIMAL(19,5)",
|
||||
"null": true,
|
||||
"default": null
|
||||
},
|
||||
"support_attr_value_valueDat": {
|
||||
"name": "support_attr_value_valueDat",
|
||||
"type": "DATETIME",
|
||||
"null": true,
|
||||
"default": null
|
||||
}
|
||||
}
|
||||
},
|
||||
"support_attr_value_l11n": {
|
||||
"name": "support_attr_value_l11n",
|
||||
"fields": {
|
||||
"support_attr_value_l11n_id": {
|
||||
"name": "support_attr_value_l11n_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"support_attr_value_l11n_title": {
|
||||
"name": "support_attr_value_l11n_title",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
},
|
||||
"support_attr_value_l11n_value": {
|
||||
"name": "support_attr_value_l11n_value",
|
||||
"type": "INT(11)",
|
||||
"null": false,
|
||||
"foreignTable": "support_attr_value",
|
||||
"foreignKey": "support_attr_value_id"
|
||||
},
|
||||
"support_attr_value_l11n_lang": {
|
||||
"name": "support_attr_value_l11n_lang",
|
||||
"type": "VARCHAR(2)",
|
||||
"null": false,
|
||||
"foreignTable": "language",
|
||||
"foreignKey": "language_639_1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"support_ticket_attr_default": {
|
||||
"name": "support_ticket_attr_default",
|
||||
"fields": {
|
||||
"support_ticket_attr_default_id": {
|
||||
"name": "support_ticket_attr_default_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"support_ticket_attr_default_type": {
|
||||
"name": "support_ticket_attr_default_type",
|
||||
"type": "INT(11)",
|
||||
"null": false,
|
||||
"foreignTable": "support_attr_type",
|
||||
"foreignKey": "support_attr_type_id"
|
||||
},
|
||||
"support_ticket_attr_default_value": {
|
||||
"name": "support_ticket_attr_default_value",
|
||||
"type": "INT(11)",
|
||||
"null": false,
|
||||
"foreignTable": "support_attr_value",
|
||||
"foreignKey": "support_attr_value_id"
|
||||
}
|
||||
}
|
||||
},
|
||||
"support_ticket_attr": {
|
||||
"name": "support_ticket_attr",
|
||||
"fields": {
|
||||
"support_ticket_attr_id": {
|
||||
"name": "support_ticket_attr_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"support_ticket_attr_ticket": {
|
||||
"name": "support_ticket_attr_ticket",
|
||||
"type": "INT(11)",
|
||||
"null": false,
|
||||
"foreignTable": "support_ticket",
|
||||
"foreignKey": "support_ticket_id"
|
||||
},
|
||||
"support_ticket_attr_type": {
|
||||
"name": "support_ticket_attr_type",
|
||||
"type": "INT(11)",
|
||||
"null": false,
|
||||
"foreignTable": "support_attr_type",
|
||||
"foreignKey": "support_attr_type_id"
|
||||
},
|
||||
"support_ticket_attr_value": {
|
||||
"name": "support_ticket_attr_value",
|
||||
"type": "INT(11)",
|
||||
"null": true,
|
||||
"default": null,
|
||||
"foreignTable": "support_attr_value",
|
||||
"foreignKey": "support_attr_value_id"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -16,27 +16,15 @@ namespace Modules\Support\Controller;
|
|||
|
||||
use Modules\Admin\Models\NullAccount;
|
||||
use Modules\Support\Models\NullSupportApp;
|
||||
use Modules\Support\Models\NullTicketAttributeType;
|
||||
use Modules\Support\Models\NullTicketAttributeValue;
|
||||
use Modules\Support\Models\SupportApp;
|
||||
use Modules\Support\Models\SupportAppMapper;
|
||||
use Modules\Support\Models\Ticket;
|
||||
use Modules\Support\Models\TicketAttribute;
|
||||
use Modules\Support\Models\TicketAttributeMapper;
|
||||
use Modules\Support\Models\TicketAttributeType;
|
||||
use Modules\Support\Models\TicketAttributeTypeL11nMapper;
|
||||
use Modules\Support\Models\TicketAttributeTypeMapper;
|
||||
use Modules\Support\Models\TicketAttributeValue;
|
||||
use Modules\Support\Models\TicketAttributeValueL11nMapper;
|
||||
use Modules\Support\Models\TicketAttributeValueMapper;
|
||||
use Modules\Support\Models\TicketElement;
|
||||
use Modules\Support\Models\TicketElementMapper;
|
||||
use Modules\Support\Models\TicketMapper;
|
||||
use Modules\Tasks\Models\TaskMapper;
|
||||
use Modules\Tasks\Models\TaskStatus;
|
||||
use Modules\Tasks\Models\TaskType;
|
||||
use phpOMS\Localization\BaseStringL11n;
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
use phpOMS\Message\Http\RequestStatusCode;
|
||||
use phpOMS\Message\RequestAbstract;
|
||||
use phpOMS\Message\ResponseAbstract;
|
||||
|
|
@ -386,370 +374,4 @@ final class ApiController extends Controller
|
|||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to create ticket attribute
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiTicketAttributeCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
if (!empty($val = $this->validateTicketAttributeCreate($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidCreateResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
@todo: If value data is in attribute create, create attribute value
|
||||
|
||||
if () {
|
||||
$attrValue = $this->createTicketAttributeValueFromRequest($request);
|
||||
$this->createModel($request->header->account, $attrValue, TicketAttributeValueMapper::class, 'attr_value', $request->getOrigin());
|
||||
}
|
||||
*/
|
||||
|
||||
$attribute = $this->createTicketAttributeFromRequest($request);
|
||||
$this->createModel($request->header->account, $attribute, TicketAttributeMapper::class, 'attribute', $request->getOrigin());
|
||||
$this->createStandardCreateResponse($request, $response, $attribute);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to create ticket attribute from request.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return TicketAttribute
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function createTicketAttributeFromRequest(RequestAbstract $request) : TicketAttribute
|
||||
{
|
||||
$attribute = new TicketAttribute();
|
||||
$attribute->ticket = (int) $request->getData('ticket');
|
||||
$attribute->type = new NullTicketAttributeType((int) $request->getData('type'));
|
||||
$attribute->value = new NullTicketAttributeValue((int) $request->getData('value'));
|
||||
|
||||
return $attribute;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate ticket attribute create request
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return array<string, bool>
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function validateTicketAttributeCreate(RequestAbstract $request) : array
|
||||
{
|
||||
$val = [];
|
||||
if (($val['type'] = !$request->hasData('type'))
|
||||
|| ($val['value'] = !$request->hasData('value'))
|
||||
|| ($val['ticket'] = !$request->hasData('ticket'))
|
||||
) {
|
||||
return $val;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to create ticket attribute l11n
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiTicketAttributeTypeL11nCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
if (!empty($val = $this->validateTicketAttributeTypeL11nCreate($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidCreateResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$attrL11n = $this->createTicketAttributeTypeL11nFromRequest($request);
|
||||
$this->createModel($request->header->account, $attrL11n, TicketAttributeTypeL11nMapper::class, 'attr_type_l11n', $request->getOrigin());
|
||||
$this->createStandardCreateResponse($request, $response, $attrL11n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to create ticket attribute l11n from request.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return BaseStringL11n
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function createTicketAttributeTypeL11nFromRequest(RequestAbstract $request) : BaseStringL11n
|
||||
{
|
||||
$attrL11n = new BaseStringL11n();
|
||||
$attrL11n->ref = $request->getDataInt('type') ?? 0;
|
||||
$attrL11n->setLanguage(
|
||||
$request->getDataString('language') ?? $request->header->l11n->language
|
||||
);
|
||||
$attrL11n->content = $request->getDataString('title') ?? '';
|
||||
|
||||
return $attrL11n;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate ticket attribute l11n create request
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return array<string, bool>
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function validateTicketAttributeTypeL11nCreate(RequestAbstract $request) : array
|
||||
{
|
||||
$val = [];
|
||||
if (($val['title'] = !$request->hasData('title'))
|
||||
|| ($val['type'] = !$request->hasData('type'))
|
||||
) {
|
||||
return $val;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to create ticket attribute type
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiTicketAttributeTypeCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
if (!empty($val = $this->validateTicketAttributeTypeCreate($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidCreateResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$attrType = $this->createTicketAttributeTypeFromRequest($request);
|
||||
$this->createModel($request->header->account, $attrType, TicketAttributeTypeMapper::class, 'attr_type', $request->getOrigin());
|
||||
$this->createStandardCreateResponse($request, $response, $attrType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to create ticket attribute from request.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return TicketAttributeType
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function createTicketAttributeTypeFromRequest(RequestAbstract $request) : TicketAttributeType
|
||||
{
|
||||
$attrType = new TicketAttributeType();
|
||||
$attrType->setL11n($request->getDataString('title') ?? '', $request->getDataString('language') ?? ISO639x1Enum::_EN);
|
||||
$attrType->fields = $request->getDataInt('fields') ?? 0;
|
||||
$attrType->custom = $request->getDataBool('custom') ?? false;
|
||||
|
||||
return $attrType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate ticket attribute create request
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return array<string, bool>
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function validateTicketAttributeTypeCreate(RequestAbstract $request) : array
|
||||
{
|
||||
$val = [];
|
||||
if (($val['title'] = !$request->hasData('title'))
|
||||
) {
|
||||
return $val;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to create ticket attribute value
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiTicketAttributeValueCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
if (!empty($val = $this->validateTicketAttributeValueCreate($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidCreateResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$attrValue = $this->createTicketAttributeValueFromRequest($request);
|
||||
$this->createModel($request->header->account, $attrValue, TicketAttributeValueMapper::class, 'attr_value', $request->getOrigin());
|
||||
|
||||
if ($attrValue->isDefault) {
|
||||
$this->createModelRelation(
|
||||
$request->header->account,
|
||||
(int) $request->getData('type'),
|
||||
$attrValue->id,
|
||||
TicketAttributeTypeMapper::class, 'defaults', '', $request->getOrigin()
|
||||
);
|
||||
}
|
||||
|
||||
$this->createStandardCreateResponse($request, $response, $attrValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to create ticket attribute value from request.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return TicketAttributeValue
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function createTicketAttributeValueFromRequest(RequestAbstract $request) : TicketAttributeValue
|
||||
{
|
||||
/** @var TicketAttributeType $type */
|
||||
$type = TicketAttributeTypeMapper::get()
|
||||
->where('id', $request->getDataInt('type') ?? 0)
|
||||
->execute();
|
||||
|
||||
$attrValue = new TicketAttributeValue();
|
||||
$attrValue->isDefault = $request->getDataBool('default') ?? false;
|
||||
$attrValue->setValue($request->getDataString('value'), $type->datatype);
|
||||
|
||||
if ($request->hasData('title')) {
|
||||
$attrValue->setL11n($request->getDataString('title') ?? '', $request->getDataString('language') ?? ISO639x1Enum::_EN);
|
||||
}
|
||||
|
||||
return $attrValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate ticket attribute value create request
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return array<string, bool>
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function validateTicketAttributeValueCreate(RequestAbstract $request) : array
|
||||
{
|
||||
$val = [];
|
||||
if (($val['type'] = !$request->hasData('type'))
|
||||
|| ($val['value'] = !$request->hasData('value'))
|
||||
) {
|
||||
return $val;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to create ticket attribute l11n
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiTicketAttributeValueL11nCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
if (!empty($val = $this->validateTicketAttributeValueL11nCreate($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidCreateResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$attrL11n = $this->createTicketAttributeValueL11nFromRequest($request);
|
||||
$this->createModel($request->header->account, $attrL11n, TicketAttributeValueL11nMapper::class, 'attr_value_l11n', $request->getOrigin());
|
||||
$this->createStandardCreateResponse($request, $response, $attrL11n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to create ticket attribute l11n from request.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return BaseStringL11n
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function createTicketAttributeValueL11nFromRequest(RequestAbstract $request) : BaseStringL11n
|
||||
{
|
||||
$attrL11n = new BaseStringL11n();
|
||||
$attrL11n->ref = $request->getDataInt('value') ?? 0;
|
||||
$attrL11n->setLanguage(
|
||||
$request->getDataString('language') ?? $request->header->l11n->language
|
||||
);
|
||||
$attrL11n->content = $request->getDataString('title') ?? '';
|
||||
|
||||
return $attrL11n;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate ticket attribute l11n create request
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return array<string, bool>
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function validateTicketAttributeValueL11nCreate(RequestAbstract $request) : array
|
||||
{
|
||||
$val = [];
|
||||
if (($val['title'] = !$request->hasData('title'))
|
||||
|| ($val['value'] = !$request->hasData('value'))
|
||||
) {
|
||||
return $val;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,40 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Support\Models;
|
||||
|
||||
use phpOMS\Stdlib\Base\Enum;
|
||||
|
||||
/**
|
||||
* Attribute value type enum.
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
abstract class AttributeValueType extends Enum
|
||||
{
|
||||
public const _INT = 1;
|
||||
|
||||
public const _STRING = 2;
|
||||
|
||||
public const _FLOAT = 3;
|
||||
|
||||
public const _DATETIME = 4;
|
||||
|
||||
public const _BOOL = 5;
|
||||
|
||||
public const _FLOAT_INT = 6;
|
||||
}
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Support\Models;
|
||||
|
||||
/**
|
||||
* Null model
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullTicketAttribute extends TicketAttribute
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $id Model id
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $id = 0)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize() : mixed
|
||||
{
|
||||
return ['id' => $this->id];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Support\Models;
|
||||
|
||||
/**
|
||||
* Null model
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullTicketAttributeType extends TicketAttributeType
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $id Model id
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $id = 0)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize() : mixed
|
||||
{
|
||||
return ['id' => $this->id];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Support\Models;
|
||||
|
||||
/**
|
||||
* Null model
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullTicketAttributeValue extends TicketAttributeValue
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $id Model id
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $id = 0)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize() : mixed
|
||||
{
|
||||
return ['id' => $this->id];
|
||||
}
|
||||
}
|
||||
|
|
@ -71,14 +71,6 @@ class Ticket
|
|||
*/
|
||||
public ?Account $for = null;
|
||||
|
||||
/**
|
||||
* Attributes.
|
||||
*
|
||||
* @var int[]|TicketAttribute[]
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private array $attributes = [];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
|
@ -183,32 +175,6 @@ class Ticket
|
|||
return $this->ticketElements[$id] ?? new NullTicketElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add attribute to item
|
||||
*
|
||||
* @param TicketAttribute $attribute Note
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function addAttribute(TicketAttribute $attribute) : void
|
||||
{
|
||||
$this->attributes[] = $attribute;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get attributes
|
||||
*
|
||||
* @return int[]|TicketAttribute[]
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getAttributes() : array
|
||||
{
|
||||
return $this->attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
@ -220,7 +186,6 @@ class Ticket
|
|||
'app' => $this->app,
|
||||
'for' => $this->for,
|
||||
'ticketElements' => $this->ticketElements,
|
||||
'attributes' => $this->attributes,
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,90 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Support\Models;
|
||||
|
||||
/**
|
||||
* Ticket class.
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class TicketAttribute implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* Id.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public int $id = 0;
|
||||
|
||||
/**
|
||||
* Ticket this attribute belongs to
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public int $ticket = 0;
|
||||
|
||||
/**
|
||||
* Attribute type the attribute belongs to
|
||||
*
|
||||
* @var TicketAttributeType
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public TicketAttributeType $type;
|
||||
|
||||
/**
|
||||
* Attribute value the attribute belongs to
|
||||
*
|
||||
* @var TicketAttributeValue
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public TicketAttributeValue $value;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->type = new TicketAttributeType();
|
||||
$this->value = new TicketAttributeValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toArray() : array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'ticket' => $this->ticket,
|
||||
'type' => $this->type,
|
||||
'value' => $this->value,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize() : mixed
|
||||
{
|
||||
return $this->toArray();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Support\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* Ticket mapper class.
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @template T of TicketAttribute
|
||||
* @extends DataMapperFactory<T>
|
||||
*/
|
||||
final class TicketAttributeMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
*
|
||||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const COLUMNS = [
|
||||
'support_ticket_attr_id' => ['name' => 'support_ticket_attr_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'support_ticket_attr_ticket' => ['name' => 'support_ticket_attr_ticket', 'type' => 'int', 'internal' => 'ticket'],
|
||||
'support_ticket_attr_type' => ['name' => 'support_ticket_attr_type', 'type' => 'int', 'internal' => 'type'],
|
||||
'support_ticket_attr_value' => ['name' => 'support_ticket_attr_value', 'type' => 'int', 'internal' => 'value'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Has one relation.
|
||||
*
|
||||
* @var array<string, array{mapper:class-string, external:string, by?:string, column?:string, conditional?:bool}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const OWNS_ONE = [
|
||||
'type' => [
|
||||
'mapper' => TicketAttributeTypeMapper::class,
|
||||
'external' => 'support_ticket_attr_type',
|
||||
],
|
||||
'value' => [
|
||||
'mapper' => TicketAttributeValueMapper::class,
|
||||
'external' => 'support_ticket_attr_value',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const TABLE = 'support_ticket_attr';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const PRIMARYFIELD = 'support_ticket_attr_id';
|
||||
}
|
||||
|
|
@ -1,160 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Support\Models;
|
||||
|
||||
use phpOMS\Localization\BaseStringL11n;
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
|
||||
/**
|
||||
* Ticket Attribute Type class.
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class TicketAttributeType implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* Id
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public int $id = 0;
|
||||
|
||||
/**
|
||||
* Name/string identifier by which it can be found/categorized
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public string $name = ''; // @todo: currently not filled, should be used as identifier or if not required removed (at the moment it seems like it is useless?!)
|
||||
|
||||
/**
|
||||
* Which field data type is required (string, int, ...) in the value
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public int $fields = 0;
|
||||
|
||||
/**
|
||||
* Is a custom value allowed (e.g. custom string)
|
||||
*
|
||||
* @var bool
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public bool $custom = false;
|
||||
|
||||
public string $validationPattern = '';
|
||||
|
||||
public bool $isRequired = false;
|
||||
|
||||
/**
|
||||
* Datatype of the attribute
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public int $datatype = AttributeValueType::_STRING;
|
||||
|
||||
/**
|
||||
* Localization
|
||||
*
|
||||
* @var string | BaseStringL11n
|
||||
*/
|
||||
protected string | BaseStringL11n $l11n;
|
||||
|
||||
/**
|
||||
* Possible default attribute values
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected array $defaults = [];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $name Name/identifier of the attribute type
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(string $name = '')
|
||||
{
|
||||
$this->setL11n($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set l11n
|
||||
*
|
||||
* @param string|BaseStringL11n $l11n Tag article l11n
|
||||
* @param string $lang Language
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setL11n(string | BaseStringL11n $l11n, string $lang = ISO639x1Enum::_EN) : void
|
||||
{
|
||||
if ($l11n instanceof BaseStringL11n) {
|
||||
$this->l11n = $l11n;
|
||||
} elseif (isset($this->l11n) && $this->l11n instanceof BaseStringL11n) {
|
||||
$this->l11n->content = $l11n;
|
||||
$this->l11n->setLanguage($lang);
|
||||
} else {
|
||||
$this->l11n = new BaseStringL11n();
|
||||
$this->l11n->content = $l11n;
|
||||
$this->l11n->setLanguage($lang);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getL11n() : string
|
||||
{
|
||||
if (!isset($this->l11n)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->l11n instanceof BaseStringL11n ? $this->l11n->content : $this->l11n;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toArray() : array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'fields' => $this->fields,
|
||||
'custom' => $this->custom,
|
||||
'validationPattern' => $this->validationPattern,
|
||||
'isRequired' => $this->isRequired,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize() : mixed
|
||||
{
|
||||
return $this->toArray();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,69 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Support\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
use phpOMS\Localization\BaseStringL11n;
|
||||
|
||||
/**
|
||||
* Ticket mapper class.
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @template T of BaseStringL11n
|
||||
* @extends DataMapperFactory<T>
|
||||
*/
|
||||
final class TicketAttributeTypeL11nMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
*
|
||||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const COLUMNS = [
|
||||
'support_attr_type_l11n_id' => ['name' => 'support_attr_type_l11n_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'support_attr_type_l11n_title' => ['name' => 'support_attr_type_l11n_title', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true],
|
||||
'support_attr_type_l11n_type' => ['name' => 'support_attr_type_l11n_type', 'type' => 'int', 'internal' => 'ref'],
|
||||
'support_attr_type_l11n_lang' => ['name' => 'support_attr_type_l11n_lang', 'type' => 'string', 'internal' => 'language'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const TABLE = 'support_attr_type_l11n';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const PRIMARYFIELD = 'support_attr_type_l11n_id';
|
||||
|
||||
/**
|
||||
* Model to use by the mapper.
|
||||
*
|
||||
* @var class-string<T>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const MODEL = BaseStringL11n::class;
|
||||
}
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Support\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* Ticket mapper class.
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @template T of TicketAttributeType
|
||||
* @extends DataMapperFactory<T>
|
||||
*/
|
||||
final class TicketAttributeTypeMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
*
|
||||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const COLUMNS = [
|
||||
'support_attr_type_id' => ['name' => 'support_attr_type_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'support_attr_type_name' => ['name' => 'support_attr_type_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true],
|
||||
'support_attr_type_fields' => ['name' => 'support_attr_type_fields', 'type' => 'int', 'internal' => 'fields'],
|
||||
'support_attr_type_custom' => ['name' => 'support_attr_type_custom', 'type' => 'bool', 'internal' => 'custom'],
|
||||
'support_attr_type_pattern' => ['name' => 'support_attr_type_pattern', 'type' => 'string', 'internal' => 'validationPattern'],
|
||||
'support_attr_type_required' => ['name' => 'support_attr_type_required', 'type' => 'bool', 'internal' => 'isRequired'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Has many relation.
|
||||
*
|
||||
* @var array<string, array{mapper:class-string, table:string, self?:?string, external?:?string, column?:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const HAS_MANY = [
|
||||
'l11n' => [
|
||||
'mapper' => TicketAttributeTypeL11nMapper::class,
|
||||
'table' => 'support_attr_type_l11n',
|
||||
'self' => 'support_attr_type_l11n_type',
|
||||
'column' => 'content',
|
||||
'external' => null,
|
||||
],
|
||||
'defaults' => [
|
||||
'mapper' => TicketAttributeValueMapper::class,
|
||||
'table' => 'support_ticket_attr_default',
|
||||
'self' => 'support_ticket_attr_default_type',
|
||||
'external' => 'support_ticket_attr_default_value',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const TABLE = 'support_attr_type';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const PRIMARYFIELD = 'support_attr_type_id';
|
||||
}
|
||||
|
|
@ -1,218 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Support\Models;
|
||||
|
||||
use phpOMS\Localization\BaseStringL11n;
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
|
||||
/**
|
||||
* Ticket attribute value class.
|
||||
*
|
||||
* The relation with the type/supplier is defined in the TicketAttribute class.
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class TicketAttributeValue implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* Id
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public int $id = 0;
|
||||
|
||||
/**
|
||||
* Depending attribute type
|
||||
*
|
||||
* @var null|int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public ?int $dependingAttributeType = null;
|
||||
|
||||
/**
|
||||
* Depending attribute value
|
||||
*
|
||||
* @var null|int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public ?int $dependingAttributeValue = null;
|
||||
|
||||
/**
|
||||
* Int value
|
||||
*
|
||||
* @var null|int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public ?int $valueInt = null;
|
||||
|
||||
/**
|
||||
* String value
|
||||
*
|
||||
* @var null|string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public ?string $valueStr = null;
|
||||
|
||||
/**
|
||||
* Decimal value
|
||||
*
|
||||
* @var null|float
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public ?float $valueDec = null;
|
||||
|
||||
/**
|
||||
* DateTime value
|
||||
*
|
||||
* @var null|\DateTimeInterface
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public ?\DateTimeInterface $valueDat = null;
|
||||
|
||||
/**
|
||||
* Is a default value which can be selected
|
||||
*
|
||||
* @var bool
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public bool $isDefault = false;
|
||||
|
||||
/**
|
||||
* Unit of the value
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public string $unit = '';
|
||||
|
||||
/**
|
||||
* Localization
|
||||
*
|
||||
* @var null|BaseStringL11n
|
||||
*/
|
||||
private ?BaseStringL11n $l11n = null;
|
||||
|
||||
/**
|
||||
* Set value
|
||||
*
|
||||
* @param null|int|string|float $value Value
|
||||
* @param int $datatype Datatype
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setValue(mixed $value, int $datatype) : void
|
||||
{
|
||||
if ($datatype === AttributeValueType::_STRING) {
|
||||
$this->valueStr = (string) $value;
|
||||
} elseif ($datatype === AttributeValueType::_INT
|
||||
|| $datatype === AttributeValueType::_FLOAT_INT
|
||||
|| $datatype === AttributeValueType::_BOOL
|
||||
) {
|
||||
$this->valueInt = (int) $value;
|
||||
} elseif ($datatype === AttributeValueType::_FLOAT) {
|
||||
$this->valueDec = (float) $value;
|
||||
} elseif ($datatype === AttributeValueType::_DATETIME) {
|
||||
$this->valueDat = new \DateTime((string) $value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get value
|
||||
*
|
||||
* @return null|int|string|float|\DateTimeInterface
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getValue() : mixed
|
||||
{
|
||||
if (!empty($this->valueStr)) {
|
||||
return $this->valueStr;
|
||||
} elseif (!empty($this->valueInt)) {
|
||||
return $this->valueInt;
|
||||
} elseif (!empty($this->valueDec)) {
|
||||
return $this->valueDec;
|
||||
} elseif ($this->valueDat instanceof \DateTimeInterface) {
|
||||
return $this->valueDat;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set l11n
|
||||
*
|
||||
* @param string|BaseStringL11n $l11n Tag article l11n
|
||||
* @param string $lang Language
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setL11n(string | BaseStringL11n $l11n, string $lang = ISO639x1Enum::_EN) : void
|
||||
{
|
||||
if ($l11n instanceof BaseStringL11n) {
|
||||
$this->l11n = $l11n;
|
||||
} elseif (isset($this->l11n) && $this->l11n instanceof BaseStringL11n) {
|
||||
$this->l11n->content = $l11n;
|
||||
$this->l11n->setLanguage($lang);
|
||||
} else {
|
||||
$this->l11n = new BaseStringL11n();
|
||||
$this->l11n->content = $l11n;
|
||||
$this->l11n->ref = $this->id;
|
||||
$this->l11n->setLanguage($lang);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get localization
|
||||
*
|
||||
* @return null|string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getL11n() : ?string
|
||||
{
|
||||
return $this->l11n instanceof BaseStringL11n ? $this->l11n->content : $this->l11n;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toArray() : array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'valueInt' => $this->valueInt,
|
||||
'valueStr' => $this->valueStr,
|
||||
'valueDec' => $this->valueDec,
|
||||
'valueDat' => $this->valueDat,
|
||||
'isDefault' => $this->isDefault,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize() : mixed
|
||||
{
|
||||
return $this->toArray();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,69 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Support\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
use phpOMS\Localization\BaseStringL11n;
|
||||
|
||||
/**
|
||||
* Item mapper class.
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @template T of BaseStringL11n
|
||||
* @extends DataMapperFactory<T>
|
||||
*/
|
||||
final class TicketAttributeValueL11nMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
*
|
||||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const COLUMNS = [
|
||||
'support_attr_value_l11n_id' => ['name' => 'support_attr_value_l11n_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'support_attr_value_l11n_title' => ['name' => 'support_attr_value_l11n_title', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true],
|
||||
'support_attr_value_l11n_value' => ['name' => 'support_attr_value_l11n_value', 'type' => 'int', 'internal' => 'ref'],
|
||||
'support_attr_value_l11n_lang' => ['name' => 'support_attr_value_l11n_lang', 'type' => 'string', 'internal' => 'language'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const TABLE = 'support_attr_value_l11n';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const PRIMARYFIELD = 'support_attr_value_l11n_id';
|
||||
|
||||
/**
|
||||
* Model to use by the mapper.
|
||||
*
|
||||
* @var class-string<T>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const MODEL = BaseStringL11n::class;
|
||||
}
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Support\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* Ticket mapper class.
|
||||
*
|
||||
* @package Modules\Support\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @template T of TicketAttributeValue
|
||||
* @extends DataMapperFactory<T>
|
||||
*/
|
||||
final class TicketAttributeValueMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
*
|
||||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const COLUMNS = [
|
||||
'support_attr_value_id' => ['name' => 'support_attr_value_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'support_attr_value_default' => ['name' => 'support_attr_value_default', 'type' => 'bool', 'internal' => 'isDefault'],
|
||||
'support_attr_value_valueStr' => ['name' => 'support_attr_value_valueStr', 'type' => 'string', 'internal' => 'valueStr'],
|
||||
'support_attr_value_valueInt' => ['name' => 'support_attr_value_valueInt', 'type' => 'int', 'internal' => 'valueInt'],
|
||||
'support_attr_value_valueDec' => ['name' => 'support_attr_value_valueDec', 'type' => 'float', 'internal' => 'valueDec'],
|
||||
'support_attr_value_valueDat' => ['name' => 'support_attr_value_valueDat', 'type' => 'DateTime', 'internal' => 'valueDat'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Has many relation.
|
||||
*
|
||||
* @var array<string, array{mapper:class-string, table:string, self?:?string, external?:?string, column?:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
/*
|
||||
public const HAS_MANY = [
|
||||
'l11n' => [
|
||||
'mapper' => EventAttributeValueL11nMapper::class,
|
||||
'table' => 'task_attr_value_l11n',
|
||||
'self' => 'task_attr_value_l11n_value',
|
||||
'column' => 'content',
|
||||
'external' => null,
|
||||
],
|
||||
];
|
||||
*/
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const TABLE = 'support_attr_value';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const PRIMARYFIELD = 'support_attr_value_id';
|
||||
}
|
||||
|
|
@ -70,13 +70,6 @@ final class TicketMapper extends DataMapperFactory
|
|||
'self' => 'support_ticket_element_ticket',
|
||||
'external' => null,
|
||||
],
|
||||
'attributes' => [
|
||||
'mapper' => TicketAttributeMapper::class,
|
||||
'table' => 'support_ticket_attr',
|
||||
'self' => 'support_ticket_attr_ticket',
|
||||
'conditional' => true,
|
||||
'external' => null,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,219 +0,0 @@
|
|||
<?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\Support\tests\Controller\Api;
|
||||
|
||||
use phpOMS\Localization\ISO3166TwoEnum;
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
use phpOMS\Message\Http\HttpRequest;
|
||||
use phpOMS\Message\Http\HttpResponse;
|
||||
use phpOMS\Message\Http\RequestStatusCode;
|
||||
use phpOMS\Uri\HttpUri;
|
||||
|
||||
trait ApiControllerAttributeTrait
|
||||
{
|
||||
/**
|
||||
* @covers Modules\Support\Controller\ApiController
|
||||
* @group module
|
||||
*/
|
||||
public function testApiTicketAttributeTypeCreate() : void
|
||||
{
|
||||
$response = new HttpResponse();
|
||||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->header->account = 1;
|
||||
$request->setData('title', 'EN:1');
|
||||
$request->setData('language', ISO639x1Enum::_EN);
|
||||
|
||||
$this->module->apiTicketAttributeTypeCreate($request, $response);
|
||||
self::assertGreaterThan(0, $response->get('')['response']->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Support\Controller\ApiController
|
||||
* @group module
|
||||
*/
|
||||
public function testApiTicketAttributeTypeL11nCreate() : void
|
||||
{
|
||||
$response = new HttpResponse();
|
||||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->header->account = 1;
|
||||
$request->setData('title', 'DE:2');
|
||||
$request->setData('type', '1');
|
||||
$request->setData('language', ISO639x1Enum::_DE);
|
||||
|
||||
$this->module->apiTicketAttributeTypeL11nCreate($request, $response);
|
||||
self::assertGreaterThan(0, $response->get('')['response']->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Support\Controller\ApiController
|
||||
* @group module
|
||||
*/
|
||||
public function testApiTicketAttributeValueIntCreate() : void
|
||||
{
|
||||
$response = new HttpResponse();
|
||||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->header->account = 1;
|
||||
$request->setData('default', '1');
|
||||
$request->setData('type', '1');
|
||||
$request->setData('value', '1');
|
||||
$request->setData('language', ISO639x1Enum::_DE);
|
||||
$request->setData('country', ISO3166TwoEnum::_DEU);
|
||||
|
||||
$this->module->apiTicketAttributeValueCreate($request, $response);
|
||||
self::assertGreaterThan(0, $response->get('')['response']->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Support\Controller\ApiController
|
||||
* @group module
|
||||
*/
|
||||
public function testApiTicketAttributeValueStrCreate() : void
|
||||
{
|
||||
$response = new HttpResponse();
|
||||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->header->account = 1;
|
||||
$request->setData('type', '1');
|
||||
$request->setData('value', '1');
|
||||
$request->setData('language', ISO639x1Enum::_DE);
|
||||
$request->setData('country', ISO3166TwoEnum::_DEU);
|
||||
|
||||
$this->module->apiTicketAttributeValueCreate($request, $response);
|
||||
self::assertGreaterThan(0, $response->get('')['response']->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Support\Controller\ApiController
|
||||
* @group module
|
||||
*/
|
||||
public function testApiTicketAttributeValueFloatCreate() : void
|
||||
{
|
||||
$response = new HttpResponse();
|
||||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->header->account = 1;
|
||||
$request->setData('type', '1');
|
||||
$request->setData('value', '1.1');
|
||||
$request->setData('language', ISO639x1Enum::_DE);
|
||||
$request->setData('country', ISO3166TwoEnum::_DEU);
|
||||
|
||||
$this->module->apiTicketAttributeValueCreate($request, $response);
|
||||
self::assertGreaterThan(0, $response->get('')['response']->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Support\Controller\ApiController
|
||||
* @group module
|
||||
*/
|
||||
public function testApiTicketAttributeValueDatCreate() : void
|
||||
{
|
||||
$response = new HttpResponse();
|
||||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->header->account = 1;
|
||||
$request->setData('type', '1');
|
||||
$request->setData('value', '2020-08-02');
|
||||
$request->setData('language', ISO639x1Enum::_DE);
|
||||
$request->setData('country', ISO3166TwoEnum::_DEU);
|
||||
|
||||
$this->module->apiTicketAttributeValueCreate($request, $response);
|
||||
self::assertGreaterThan(0, $response->get('')['response']->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Support\Controller\ApiController
|
||||
* @group module
|
||||
*/
|
||||
public function testApiTicketAttributeCreate() : void
|
||||
{
|
||||
$response = new HttpResponse();
|
||||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->header->account = 1;
|
||||
$request->setData('ticket', '1');
|
||||
$request->setData('value', '1');
|
||||
$request->setData('type', '1');
|
||||
|
||||
$this->module->apiTicketAttributeCreate($request, $response);
|
||||
self::assertGreaterThan(0, $response->get('')['response']->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Support\Controller\ApiController
|
||||
* @group module
|
||||
*/
|
||||
public function testApiTicketAttributeValueCreateInvalidData() : void
|
||||
{
|
||||
$response = new HttpResponse();
|
||||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->header->account = 1;
|
||||
$request->setData('invalid', '1');
|
||||
|
||||
$this->module->apiTicketAttributeValueCreate($request, $response);
|
||||
self::assertEquals(RequestStatusCode::R_400, $response->header->status);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Support\Controller\ApiController
|
||||
* @group module
|
||||
*/
|
||||
public function testApiTicketAttributeTypeCreateInvalidData() : void
|
||||
{
|
||||
$response = new HttpResponse();
|
||||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->header->account = 1;
|
||||
$request->setData('invalid', '1');
|
||||
|
||||
$this->module->apiTicketAttributeTypeCreate($request, $response);
|
||||
self::assertEquals(RequestStatusCode::R_400, $response->header->status);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Support\Controller\ApiController
|
||||
* @group module
|
||||
*/
|
||||
public function testApiTicketAttributeTypeL11nCreateInvalidData() : void
|
||||
{
|
||||
$response = new HttpResponse();
|
||||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->header->account = 1;
|
||||
$request->setData('invalid', '1');
|
||||
|
||||
$this->module->apiTicketAttributeTypeL11nCreate($request, $response);
|
||||
self::assertEquals(RequestStatusCode::R_400, $response->header->status);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Support\Controller\ApiController
|
||||
* @group module
|
||||
*/
|
||||
public function testApiTicketAttributeCreateInvalidData() : void
|
||||
{
|
||||
$response = new HttpResponse();
|
||||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->header->account = 1;
|
||||
$request->setData('invalid', '1');
|
||||
|
||||
$this->module->apiTicketAttributeCreate($request, $response);
|
||||
self::assertEquals(RequestStatusCode::R_400, $response->header->status);
|
||||
}
|
||||
}
|
||||
|
|
@ -16,7 +16,6 @@ namespace Modules\Support\tests\Controller;
|
|||
|
||||
use Model\CoreSettings;
|
||||
use Modules\Admin\Models\AccountPermission;
|
||||
use Modules\Support\tests\Controller\Api\ApiControllerAttributeTrait;
|
||||
use Modules\Support\tests\Controller\Api\ApiControllerTicketTrait;
|
||||
use phpOMS\Account\Account;
|
||||
use phpOMS\Account\AccountManager;
|
||||
|
|
@ -91,5 +90,4 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
use ApiControllerTicketTrait;
|
||||
use ApiControllerAttributeTrait;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,42 +0,0 @@
|
|||
<?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\Support\tests\Models;
|
||||
|
||||
use Modules\Support\Models\NullTicketAttribute;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class NullTicketAttributeTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @covers Modules\Support\Models\NullTicketAttribute
|
||||
* @group framework
|
||||
*/
|
||||
public function testNull() : void
|
||||
{
|
||||
self::assertInstanceOf('\Modules\Support\Models\TicketAttribute', new NullTicketAttribute());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Support\Models\NullTicketAttribute
|
||||
* @group framework
|
||||
*/
|
||||
public function testId() : void
|
||||
{
|
||||
$null = new NullTicketAttribute(2);
|
||||
self::assertEquals(2, $null->id);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
<?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\Support\tests\Models;
|
||||
|
||||
use Modules\Support\Models\NullTicketAttributeType;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class NullTicketAttributeTypeTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @covers Modules\Support\Models\NullTicketAttributeType
|
||||
* @group framework
|
||||
*/
|
||||
public function testNull() : void
|
||||
{
|
||||
self::assertInstanceOf('\Modules\Support\Models\TicketAttributeType', new NullTicketAttributeType());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Support\Models\NullTicketAttributeType
|
||||
* @group framework
|
||||
*/
|
||||
public function testId() : void
|
||||
{
|
||||
$null = new NullTicketAttributeType(2);
|
||||
self::assertEquals(2, $null->id);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
<?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\Support\tests\Models;
|
||||
|
||||
use Modules\Support\Models\NullTicketAttributeValue;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class NullTicketAttributeValueTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @covers Modules\Support\Models\NullTicketAttributeValue
|
||||
* @group framework
|
||||
*/
|
||||
public function testNull() : void
|
||||
{
|
||||
self::assertInstanceOf('\Modules\Support\Models\TicketAttributeValue', new NullTicketAttributeValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Support\Models\NullTicketAttributeValue
|
||||
* @group framework
|
||||
*/
|
||||
public function testId() : void
|
||||
{
|
||||
$null = new NullTicketAttributeValue(2);
|
||||
self::assertEquals(2, $null->id);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
<?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\Support\tests\Models;
|
||||
|
||||
use Modules\Support\Models\TicketAttribute;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class TicketAttributeTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
private TicketAttribute $attribute;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() : void
|
||||
{
|
||||
$this->attribute = new TicketAttribute();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Support\Models\TicketAttribute
|
||||
* @group module
|
||||
*/
|
||||
public function testDefault() : void
|
||||
{
|
||||
self::assertEquals(0, $this->attribute->id);
|
||||
self::assertInstanceOf('\Modules\Support\Models\TicketAttributeType', $this->attribute->type);
|
||||
self::assertInstanceOf('\Modules\Support\Models\TicketAttributeValue', $this->attribute->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Support\Models\TicketAttribute
|
||||
* @group module
|
||||
*/
|
||||
public function testSerialize() : void
|
||||
{
|
||||
$serialized = $this->attribute->jsonSerialize();
|
||||
|
||||
self::assertEquals(
|
||||
[
|
||||
'id',
|
||||
'ticket',
|
||||
'type',
|
||||
'value',
|
||||
],
|
||||
\array_keys($serialized)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
<?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\Support\tests\Models;
|
||||
|
||||
use Modules\Support\Models\TicketAttributeType;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class TicketAttributeTypeTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
private TicketAttributeType $type;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() : void
|
||||
{
|
||||
$this->type = new TicketAttributeType();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Support\Models\TicketAttributeType
|
||||
* @group module
|
||||
*/
|
||||
public function testDefault() : void
|
||||
{
|
||||
self::assertEquals(0, $this->type->id);
|
||||
self::assertEquals('', $this->type->getL11n());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Support\Models\TicketAttributeType
|
||||
* @group module
|
||||
*/
|
||||
public function testL11nInputOutput() : void
|
||||
{
|
||||
$this->type->setL11n('Test');
|
||||
self::assertEquals('Test', $this->type->getL11n());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Support\Models\TicketAttributeType
|
||||
* @group module
|
||||
*/
|
||||
public function testSerialize() : void
|
||||
{
|
||||
$this->type->name = 'Title';
|
||||
$this->type->fields = 2;
|
||||
$this->type->custom = true;
|
||||
$this->type->validationPattern = '\d*';
|
||||
$this->type->isRequired = true;
|
||||
|
||||
self::assertEquals(
|
||||
[
|
||||
'id' => 0,
|
||||
'name' => 'Title',
|
||||
'fields' => 2,
|
||||
'custom' => true,
|
||||
'validationPattern' => '\d*',
|
||||
'isRequired' => true,
|
||||
],
|
||||
$this->type->jsonSerialize()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,108 +0,0 @@
|
|||
<?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\Support\tests\Models;
|
||||
|
||||
use Modules\Support\Models\AttributeValueType;
|
||||
use Modules\Support\Models\TicketAttributeValue;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class TicketAttributeValueTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
private TicketAttributeValue $value;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() : void
|
||||
{
|
||||
$this->value = new TicketAttributeValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Support\Models\TicketAttributeValue
|
||||
* @group module
|
||||
*/
|
||||
public function testDefault() : void
|
||||
{
|
||||
self::assertEquals(0, $this->value->id);
|
||||
self::assertNull($this->value->getValue());
|
||||
self::assertFalse($this->value->isDefault);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Support\Models\TicketAttributeValue
|
||||
* @group module
|
||||
*/
|
||||
public function testValueIntInputOutput() : void
|
||||
{
|
||||
$this->value->setValue(1, AttributeValueType::_INT);
|
||||
self::assertEquals(1, $this->value->getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Support\Models\TicketAttributeValue
|
||||
* @group module
|
||||
*/
|
||||
public function testValueFloatInputOutput() : void
|
||||
{
|
||||
$this->value->setValue(1.1, AttributeValueType::_FLOAT);
|
||||
self::assertEquals(1.1, $this->value->getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Support\Models\TicketAttributeValue
|
||||
* @group module
|
||||
*/
|
||||
public function testValueStringInputOutput() : void
|
||||
{
|
||||
$this->value->setValue('test', AttributeValueType::_STRING);
|
||||
self::assertEquals('test', $this->value->getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Support\Models\TicketAttributeValue
|
||||
* @group module
|
||||
*/
|
||||
public function testValueDateInputOutput() : void
|
||||
{
|
||||
$dat = new \DateTime('now');
|
||||
$this->value->setValue('now', AttributeValueType::_DATETIME);
|
||||
self::assertEquals($dat->format('Y-m-d'), $this->value->getValue()->format('Y-m-d'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Support\Models\TicketAttributeValue
|
||||
* @group module
|
||||
*/
|
||||
public function testSerialize() : void
|
||||
{
|
||||
$this->value->setValue('test', AttributeValueType::_STRING);
|
||||
$this->value->isDefault = true;
|
||||
|
||||
self::assertEquals(
|
||||
[
|
||||
'id' => 0,
|
||||
'valueInt' => null,
|
||||
'valueStr' => 'test',
|
||||
'valueDec' => null,
|
||||
'valueDat' => null,
|
||||
'isDefault' => true,
|
||||
],
|
||||
$this->value->jsonSerialize()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -42,7 +42,6 @@ final class TicketTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertEquals(0, $this->ticket->id);
|
||||
self::assertNull($this->ticket->for);
|
||||
self::assertEquals([], $this->ticket->getTicketElements());
|
||||
self::assertEquals([], $this->ticket->getAttributes());
|
||||
self::assertInstanceOf('\Modules\Tasks\Models\Task', $this->ticket->task);
|
||||
self::assertInstanceOf('\Modules\Support\Models\TicketElement', $this->ticket->getTicketElement(999));
|
||||
self::assertInstanceOf('\Modules\Support\Models\SupportApp', $this->ticket->app);
|
||||
|
|
@ -54,11 +53,8 @@ final class TicketTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testElementInputOutput() : void
|
||||
{
|
||||
$element1 = new TicketElement();
|
||||
$element1->description = '1';
|
||||
|
||||
$element2 = new TicketElement();
|
||||
$element2->description = '2';
|
||||
$element1 = new TicketElement();
|
||||
$element2 = new TicketElement();
|
||||
|
||||
self::assertEquals(0, $this->ticket->addElement($element1));
|
||||
self::assertEquals(1, $this->ticket->addElement($element2));
|
||||
|
|
@ -73,8 +69,7 @@ final class TicketTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testElementRemove() : void
|
||||
{
|
||||
$element1 = new TicketElement();
|
||||
$element1->description = '1';
|
||||
$element1 = new TicketElement();
|
||||
|
||||
$this->ticket->addElement($element1);
|
||||
self::assertCount(1, $this->ticket->getTicketElements());
|
||||
|
|
@ -83,18 +78,6 @@ final class TicketTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertFalse($this->ticket->removeElement(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Support\Models\Ticket
|
||||
* @group module
|
||||
*/
|
||||
public function testAttributeInputOutput() : void
|
||||
{
|
||||
$attr = new TicketAttribute();
|
||||
$this->ticket->addAttribute($attr);
|
||||
|
||||
self::assertCount(1, $this->ticket->getAttributes());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Support\Models\Ticket
|
||||
* @group module
|
||||
|
|
@ -107,10 +90,9 @@ final class TicketTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
self::assertEquals(
|
||||
[
|
||||
'id' => 0,
|
||||
'for' => null,
|
||||
'ticketElements' => [],
|
||||
'attributes' => [],
|
||||
'id' => 0,
|
||||
'for' => null,
|
||||
'ticketElements' => [],
|
||||
],
|
||||
$serialized
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user