mirror of
https://github.com/Karaka-Management/oms-Attribute.git
synced 2026-02-12 07:28:41 +00:00
Test fixes
This commit is contained in:
parent
e89c03cb59
commit
cfe56d2a4f
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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') ?? '';
|
||||||
|
|
|
||||||
|
|
@ -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') ?? '',
|
||||||
|
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
# Structure
|
|
||||||
|
|
||||||
## ER
|
|
||||||
|
|
||||||

|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 107 KiB |
|
|
@ -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,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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'],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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',
|
||||||
|
|
|
||||||
|
|
@ -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',
|
||||||
|
|
|
||||||
|
|
@ -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",
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user