Test fixes
Some checks failed
Image optimization / general_image_workflow (push) Has been cancelled
CI / general_module_workflow_php (push) Has been cancelled
CI / general_module_workflow_js (push) Has been cancelled

This commit is contained in:
Dennis Eichhorn 2024-05-16 02:14:54 +00:00
parent e89c03cb59
commit cfe56d2a4f
12 changed files with 24 additions and 29 deletions

View File

@ -46,13 +46,13 @@
"null": false "null": false
}, },
"attribute_attr_type_required": { "attribute_attr_type_required": {
"description": "Every element must have this attribute type if set to true.", "comment": "Every element must have this attribute type if set to true.",
"name": "attribute_attr_type_required", "name": "attribute_attr_type_required",
"type": "TINYINT(1)", "type": "TINYINT(1)",
"null": false "null": false
}, },
"attribute_attr_type_pattern": { "attribute_attr_type_pattern": {
"description": "This is a regex validation pattern.", "comment": "This is a regex validation pattern.",
"name": "attribute_attr_type_pattern", "name": "attribute_attr_type_pattern",
"type": "VARCHAR(255)", "type": "VARCHAR(255)",
"null": false "null": false

View File

@ -153,7 +153,7 @@ trait ApiAttributeTraitController
$attrType = new AttributeType($request->getDataString('name') ?? ''); $attrType = new AttributeType($request->getDataString('name') ?? '');
$attrType->datatype = AttributeValueType::tryFromValue($request->getDataInt('datatype')) ?? AttributeValueType::_STRING; $attrType->datatype = AttributeValueType::tryFromValue($request->getDataInt('datatype')) ?? AttributeValueType::_STRING;
$attrType->custom = $request->getDataBool('custom') ?? false; $attrType->custom = $request->getDataBool('custom') ?? false;
$attrType->isRepeatable = $request->getDataBool('is_repeatable') ?? false; $attrType->isRepeatable = $request->getDataBool('is_repeatable') ?? false;
$attrType->isInternal = $request->getDataBool('internal') ?? false; $attrType->isInternal = $request->getDataBool('internal') ?? false;
$attrType->isRequired = $request->getDataBool('is_required') ?? false; $attrType->isRequired = $request->getDataBool('is_required') ?? false;
$attrType->validationPattern = $request->getDataString('validation_pattern') ?? ''; $attrType->validationPattern = $request->getDataString('validation_pattern') ?? '';

View File

@ -246,7 +246,7 @@ final class ApiController extends Controller
$attrType->datatype = AttributeValueType::tryFromValue($request->getDataInt('datatype')) ?? AttributeValueType::_STRING; $attrType->datatype = AttributeValueType::tryFromValue($request->getDataInt('datatype')) ?? AttributeValueType::_STRING;
$attrType->custom = $request->getDataBool('custom') ?? false; $attrType->custom = $request->getDataBool('custom') ?? false;
$attrType->isRequired = $request->getDataBool('is_required') ?? false; $attrType->isRequired = $request->getDataBool('is_required') ?? false;
$attrType->isRepeatable = $request->getDataBool('is_repeatable') ?? false; $attrType->isRepeatable = $request->getDataBool('is_repeatable') ?? false;
$attrType->validationPattern = $request->getDataString('validation_pattern') ?? ''; $attrType->validationPattern = $request->getDataString('validation_pattern') ?? '';
$attrType->setL11n( $attrType->setL11n(
$request->getDataString('title') ?? '', $request->getDataString('title') ?? '',

View File

@ -1,5 +0,0 @@
# Structure
## ER
![ER](Modules/News/Docs/Dev/img/er.png)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 KiB

View File

@ -240,7 +240,7 @@ class AttributeType implements \JsonSerializable
'custom' => $this->custom, 'custom' => $this->custom,
'isRequired' => $this->isRequired, 'isRequired' => $this->isRequired,
'isInternal' => $this->isInternal, 'isInternal' => $this->isInternal,
'isRepeatable' => $this->isRepeatable, 'isRepeatable' => $this->isRepeatable,
]; ];
} }

View File

@ -36,13 +36,13 @@ final class AttributeTypeMapper extends DataMapperFactory
* @since 1.0.0 * @since 1.0.0
*/ */
public const COLUMNS = [ public const COLUMNS = [
'attribute_attr_type_id' => ['name' => 'attribute_attr_type_id', 'type' => 'int', 'internal' => 'id'], 'attribute_attr_type_id' => ['name' => 'attribute_attr_type_id', 'type' => 'int', 'internal' => 'id'],
'attribute_attr_type_name' => ['name' => 'attribute_attr_type_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true], 'attribute_attr_type_name' => ['name' => 'attribute_attr_type_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true],
'attribute_attr_type_datatype' => ['name' => 'attribute_attr_type_datatype', 'type' => 'int', 'internal' => 'datatype'], 'attribute_attr_type_datatype' => ['name' => 'attribute_attr_type_datatype', 'type' => 'int', 'internal' => 'datatype'],
'attribute_attr_type_fields' => ['name' => 'attribute_attr_type_fields', 'type' => 'int', 'internal' => 'fields'], 'attribute_attr_type_fields' => ['name' => 'attribute_attr_type_fields', 'type' => 'int', 'internal' => 'fields'],
'attribute_attr_type_custom' => ['name' => 'attribute_attr_type_custom', 'type' => 'bool', 'internal' => 'custom'], 'attribute_attr_type_custom' => ['name' => 'attribute_attr_type_custom', 'type' => 'bool', 'internal' => 'custom'],
'attribute_attr_type_pattern' => ['name' => 'attribute_attr_type_pattern', 'type' => 'string', 'internal' => 'validationPattern'], 'attribute_attr_type_pattern' => ['name' => 'attribute_attr_type_pattern', 'type' => 'string', 'internal' => 'validationPattern'],
'attribute_attr_type_required' => ['name' => 'attribute_attr_type_required', 'type' => 'bool', 'internal' => 'isRequired'], 'attribute_attr_type_required' => ['name' => 'attribute_attr_type_required', 'type' => 'bool', 'internal' => 'isRequired'],
'attribute_attr_type_repeatable' => ['name' => 'attribute_attr_type_repeatable', 'type' => 'bool', 'internal' => 'isRepeatable'], 'attribute_attr_type_repeatable' => ['name' => 'attribute_attr_type_repeatable', 'type' => 'bool', 'internal' => 'isRepeatable'],
]; ];

View File

@ -85,11 +85,11 @@ class AttributeView extends View
public function render(mixed ...$data) : string public function render(mixed ...$data) : string
{ {
/** @var array{0:\Modules\Attribute\Models\Attribute[]} $data */ /** @var array{0:\Modules\Attribute\Models\Attribute[]} $data */
$this->attributes = $data[0]; $this->attributes = $data[0] ?? [];
$this->attributeTypes = $data[1]; $this->attributeTypes = $data[1] ?? [];
$this->units = $data[2]; $this->units = $data[2] ?? [];
$this->apiUri = $data[3]; $this->apiUri = $data[3] ?? '';
$this->refId = $data[4]; $this->refId = $data[4] ?? 0;
return parent::render(); return parent::render();
} }

View File

@ -20,7 +20,7 @@ return ['Attribute' => [
'Datatype' => 'Datatype', 'Datatype' => 'Datatype',
'DefaultValues' => 'Default Values', 'DefaultValues' => 'Default Values',
'IsRequired' => 'Is required?', 'IsRequired' => 'Is required?',
'IsRepeatable' => 'Is repeatable?', 'IsRepeatable' => 'Is repeatable?',
'Name' => 'Name', 'Name' => 'Name',
'Pattern' => 'Pattern', 'Pattern' => 'Pattern',
'Status' => 'Status', 'Status' => 'Status',

View File

@ -20,7 +20,7 @@ return ['Attribute' => [
'Datatype' => 'Datatype', 'Datatype' => 'Datatype',
'DefaultValues' => 'Default Values', 'DefaultValues' => 'Default Values',
'IsRequired' => 'Is required?', 'IsRequired' => 'Is required?',
'IsRepeatable' => 'Is repeatable?', 'IsRepeatable' => 'Is repeatable?',
'Name' => 'Name', 'Name' => 'Name',
'Pattern' => 'Pattern', 'Pattern' => 'Pattern',
'Status' => 'Status', 'Status' => 'Status',

View File

@ -12,7 +12,7 @@
}, },
"creator": { "creator": {
"name": "Jingga", "name": "Jingga",
"website": "jingga.app" "website": "https://jingga.app"
}, },
"description": "Attribute module.", "description": "Attribute module.",
"directory": "Attribute", "directory": "Attribute",

View File

@ -35,7 +35,7 @@ final class AttributeTypeTest extends \PHPUnit\Framework\TestCase
public function testGetDefaultInt() : void public function testGetDefaultInt() : void
{ {
$type = new AttributeType(); $type = new AttributeType();
$type->datatype = AttributeValueType::_INT; $type->datatype = AttributeValueType::_INT;
$type->defaults[] = new AttributeValue(); $type->defaults[] = new AttributeValue();
@ -46,7 +46,7 @@ final class AttributeTypeTest extends \PHPUnit\Framework\TestCase
public function testGetDefaultFloatInt() : void public function testGetDefaultFloatInt() : void
{ {
$type = new AttributeType(); $type = new AttributeType();
$type->datatype = AttributeValueType::_FLOAT_INT; $type->datatype = AttributeValueType::_FLOAT_INT;
$type->defaults[] = new AttributeValue(); $type->defaults[] = new AttributeValue();
@ -57,7 +57,7 @@ final class AttributeTypeTest extends \PHPUnit\Framework\TestCase
public function testGetDefaultBool() : void public function testGetDefaultBool() : void
{ {
$type = new AttributeType(); $type = new AttributeType();
$type->datatype = AttributeValueType::_BOOL; $type->datatype = AttributeValueType::_BOOL;
$type->defaults[] = new AttributeValue(); $type->defaults[] = new AttributeValue();
@ -79,7 +79,7 @@ final class AttributeTypeTest extends \PHPUnit\Framework\TestCase
public function testGetDefaultDateTime() : void public function testGetDefaultDateTime() : void
{ {
$type = new AttributeType(); $type = new AttributeType();
$type->datatype = AttributeValueType::_DATETIME; $type->datatype = AttributeValueType::_DATETIME;
$type->defaults[] = new AttributeValue(); $type->defaults[] = new AttributeValue();