diff --git a/Models/AttributeHolderTrait.php b/Models/AttributeHolderTrait.php index 323b1c1..a0a4913 100755 --- a/Models/AttributeHolderTrait.php +++ b/Models/AttributeHolderTrait.php @@ -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) { diff --git a/Models/AttributeValue.php b/Models/AttributeValue.php index dd3d12b..9835c11 100755 --- a/Models/AttributeValue.php +++ b/Models/AttributeValue.php @@ -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 diff --git a/Models/PermissionCategory.php b/Models/PermissionCategory.php index d32475a..9c3fd04 100755 --- a/Models/PermissionCategory.php +++ b/Models/PermissionCategory.php @@ -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 diff --git a/Theme/Backend/Components/attributes.tpl.php b/Theme/Backend/Components/attributes.tpl.php index b5b87eb..d80cae8 100644 --- a/Theme/Backend/Components/attributes.tpl.php +++ b/Theme/Backend/Components/attributes.tpl.php @@ -33,7 +33,7 @@ $l11n = $this->data['defaultlocalization'] ?? new NullLocalization(); data-add-tpl="#attributeTable tbody .oms-add-tpl-attribute">
getHtml('Attribute', 'Attribute', 'Backend'); ?>
- +
@@ -81,7 +81,7 @@ $l11n = $this->data['defaultlocalization'] ?? new NullLocalization();
getHtml('Attributes', 'Attribute', 'Backend'); ?>download
- 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 diff --git a/tests/Models/AttributeTypeTest.php b/tests/Models/AttributeTypeTest.php index d766022..288624b 100644 --- a/tests/Models/AttributeTypeTest.php +++ b/tests/Models/AttributeTypeTest.php @@ -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() ); diff --git a/tests/Models/AttributeValueTest.php b/tests/Models/AttributeValueTest.php index a4a33ff..02965aa 100644 --- a/tests/Models/AttributeValueTest.php +++ b/tests/Models/AttributeValueTest.php @@ -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() );