mirror of
https://github.com/Karaka-Management/oms-Attribute.git
synced 2026-01-30 17:38:40 +00:00
update
This commit is contained in:
parent
95af17ec60
commit
b66a28e782
|
|
@ -79,6 +79,15 @@ trait AttributeHolderTrait
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a certain attribute type exists by name
|
||||
*
|
||||
* @param string $attrName Attribute name to check
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function hasAttributeType(string $attrName) : bool
|
||||
{
|
||||
foreach ($this->attributes as $attribute) {
|
||||
|
|
|
|||
|
|
@ -104,9 +104,9 @@ class AttributeValue implements \JsonSerializable
|
|||
/**
|
||||
* Localization
|
||||
*
|
||||
* @var null|BaseStringL11n
|
||||
* @var string|BaseStringL11n
|
||||
*/
|
||||
public ?BaseStringL11n $l11n = null;
|
||||
public string | BaseStringL11n $l11n = '';
|
||||
|
||||
/**
|
||||
* Set l11n
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ namespace Modules\Attribute\Models;
|
|||
use phpOMS\Stdlib\Base\Enum;
|
||||
|
||||
/**
|
||||
* Permision state enum.
|
||||
* Permission category enum.
|
||||
*
|
||||
* @package Modules\Attribute\Models
|
||||
* @license OMS License 2.0
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ $l11n = $this->data['defaultlocalization'] ?? new NullLocalization();
|
|||
data-add-tpl="#attributeTable tbody .oms-add-tpl-attribute">
|
||||
<div class="portlet-head"><?= $this->getHtml('Attribute', 'Attribute', 'Backend'); ?></div>
|
||||
<div class="portlet-body">
|
||||
<input type="hidden" id="iAttributeRef" name="ref" value="<?= $this->refId ?>" disabled>
|
||||
<input type="hidden" id="iAttributeRef" name="ref" value="<?= $this->refId; ?>" disabled>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="iAttributeId"><?= $this->getHtml('ID', '0', '0'); ?></label>
|
||||
|
|
@ -81,7 +81,7 @@ $l11n = $this->data['defaultlocalization'] ?? new NullLocalization();
|
|||
<section class="portlet">
|
||||
<div class="portlet-head"><?= $this->getHtml('Attributes', 'Attribute', 'Backend'); ?><i class="g-icon download btn end-xs">download</i></div>
|
||||
<div class="slider">
|
||||
<table id="attributeTable" class="default"
|
||||
<table id="attributeTable" class="default sticky"
|
||||
data-tag="form"
|
||||
data-ui-element="tr"
|
||||
data-add-tpl=".oms-add-tpl-attribute"
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ final class AttributeTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
self::assertEquals(
|
||||
[
|
||||
'id' => 0,
|
||||
'id' => 0,
|
||||
'ref' => 0,
|
||||
],
|
||||
$array
|
||||
|
|
@ -63,7 +63,7 @@ final class AttributeTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
self::assertEquals(
|
||||
[
|
||||
'id' => 0,
|
||||
'id' => 0,
|
||||
'ref' => 0,
|
||||
],
|
||||
$array
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ final class AttributeTypeTest extends \PHPUnit\Framework\TestCase
|
|||
{
|
||||
public function testGetDefaultString() : void
|
||||
{
|
||||
$type = new AttributeType();
|
||||
$type = new AttributeType();
|
||||
$type->defaults[] = new AttributeValue();
|
||||
$type->defaults[0]->setValue('abc', AttributeValueType::_STRING);
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ final class AttributeTypeTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
public function testGetDefaultInt() : void
|
||||
{
|
||||
$type = new AttributeType();
|
||||
$type = new AttributeType();
|
||||
$type->defaults[] = new AttributeValue();
|
||||
$type->defaults[0]->setValue(1, AttributeValueType::_INT);
|
||||
|
||||
|
|
@ -45,7 +45,7 @@ final class AttributeTypeTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
public function testGetDefaultFloatInt() : void
|
||||
{
|
||||
$type = new AttributeType();
|
||||
$type = new AttributeType();
|
||||
$type->defaults[] = new AttributeValue();
|
||||
$type->defaults[0]->setValue(1, AttributeValueType::_FLOAT_INT);
|
||||
|
||||
|
|
@ -54,16 +54,16 @@ final class AttributeTypeTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
public function testGetDefaultBool() : void
|
||||
{
|
||||
$type = new AttributeType();
|
||||
$type = new AttributeType();
|
||||
$type->defaults[] = new AttributeValue();
|
||||
$type->defaults[0]->setValue(false, AttributeValueType::_BOOL);
|
||||
|
||||
self::assertEquals(false, $type->getDefaultByValue(false)->getValue());
|
||||
self::assertFalse($type->getDefaultByValue(false)->getValue());
|
||||
}
|
||||
|
||||
public function testGetDefaultFloat() : void
|
||||
{
|
||||
$type = new AttributeType();
|
||||
$type = new AttributeType();
|
||||
$type->defaults[] = new AttributeValue();
|
||||
$type->defaults[0]->setValue(1.23, AttributeValueType::_FLOAT);
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ final class AttributeTypeTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
public function testGetDefaultDateTime() : void
|
||||
{
|
||||
$type = new AttributeType();
|
||||
$type = new AttributeType();
|
||||
$type->defaults[] = new AttributeValue();
|
||||
$type->defaults[0]->setValue($val = new \DateTime('now'), AttributeValueType::_DATETIME);
|
||||
|
||||
|
|
@ -81,7 +81,7 @@ final class AttributeTypeTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
public function testDefaultId() : void
|
||||
{
|
||||
$type = new AttributeType();
|
||||
$type = new AttributeType();
|
||||
$type->defaults[] = new AttributeValue();
|
||||
|
||||
self::assertTrue($type->hasDefaultId(0));
|
||||
|
|
@ -94,11 +94,11 @@ final class AttributeTypeTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
self::assertEquals(
|
||||
[
|
||||
'id' => 0,
|
||||
'name' => '',
|
||||
'id' => 0,
|
||||
'name' => '',
|
||||
'validationPattern' => '',
|
||||
'custom' => false,
|
||||
'isRequired' => false,
|
||||
'custom' => false,
|
||||
'isRequired' => false,
|
||||
],
|
||||
$type->toArray()
|
||||
);
|
||||
|
|
@ -110,11 +110,11 @@ final class AttributeTypeTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
self::assertEquals(
|
||||
[
|
||||
'id' => 0,
|
||||
'name' => '',
|
||||
'id' => 0,
|
||||
'name' => '',
|
||||
'validationPattern' => '',
|
||||
'custom' => false,
|
||||
'isRequired' => false,
|
||||
'custom' => false,
|
||||
'isRequired' => false,
|
||||
],
|
||||
$type->jsonSerialize()
|
||||
);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ namespace Modules\Admin\tests\Models;
|
|||
|
||||
use Modules\Attribute\Models\AttributeValue;
|
||||
use Modules\Attribute\Models\AttributeValueType;
|
||||
use Modules\Attribute\Models\AttributeValueValue;
|
||||
|
||||
/**
|
||||
* @testdox Modules\Admin\tests\Models\AttributeValueTest: Attribute model
|
||||
|
|
@ -54,7 +53,7 @@ final class AttributeValueTest extends \PHPUnit\Framework\TestCase
|
|||
$value = new AttributeValue();
|
||||
$value->setValue(false, AttributeValueType::_BOOL);
|
||||
|
||||
self::assertEquals(false, $value->getValue());
|
||||
self::assertFalse($value->getValue());
|
||||
}
|
||||
|
||||
public function testGetDefaultFloat() : void
|
||||
|
|
@ -78,11 +77,11 @@ final class AttributeValueTest extends \PHPUnit\Framework\TestCase
|
|||
$value = new AttributeValue();
|
||||
self::assertEquals(
|
||||
[
|
||||
'id' => 0,
|
||||
'name' => '',
|
||||
'id' => 0,
|
||||
'name' => '',
|
||||
'validationPattern' => '',
|
||||
'custom' => false,
|
||||
'isRequired' => false,
|
||||
'custom' => false,
|
||||
'isRequired' => false,
|
||||
],
|
||||
$value->toArray()
|
||||
);
|
||||
|
|
@ -93,11 +92,11 @@ final class AttributeValueTest extends \PHPUnit\Framework\TestCase
|
|||
$value = new AttributeValue();
|
||||
self::assertEquals(
|
||||
[
|
||||
'id' => 0,
|
||||
'name' => '',
|
||||
'id' => 0,
|
||||
'name' => '',
|
||||
'validationPattern' => '',
|
||||
'custom' => false,
|
||||
'isRequired' => false,
|
||||
'custom' => false,
|
||||
'isRequired' => false,
|
||||
],
|
||||
$value->jsonSerialize()
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user