Skip to content

Commit

Permalink
Merge pull request #38 from snowio/attribute-lowercase
Browse files Browse the repository at this point in the history
Make attribute codes be lowercase
  • Loading branch information
Liam Toohey authored Oct 21, 2021
2 parents 485bb5f + e518d07 commit fc19561
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/AttributeData.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function equals($attribute): bool

private function __construct(string $attributeCode, string $frontendInput)
{
$this->attributeCode = $attributeCode;
$this->attributeCode = strtolower($attributeCode);
$this->frontendInput = $frontendInput;
}
}
2 changes: 1 addition & 1 deletion src/AttributeSet/AttributeData.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ final class AttributeData implements ValueObject
public static function of(string $code): self
{
$attributeData = new self;
$attributeData->code = $code;
$attributeData->code = strtolower($code);
return $attributeData;
}

Expand Down
9 changes: 9 additions & 0 deletions test/unit/AttributeDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ public function testToJson()
'default_frontend_label' => 'Diameter',
'scope' => AttributeScope::GLOBAL,
], $attribute->toJson());

$attribute = AttributeData::of('Diameter', FrontendInput::TEXT, 'Diameter');
self::assertEquals([
'attribute_code' => 'diameter',
'is_required' => false,
'frontend_input' => 'text',
'default_frontend_label' => 'Diameter',
'scope' => AttributeScope::GLOBAL,
], $attribute->toJson());
}

public function testWithers()
Expand Down
2 changes: 1 addition & 1 deletion test/unit/AttributeSet/AttributeGroupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function testWithers()
->withAttributes(AttributeDataSet::of([
AttributeData::of('size')->withSortOrder(1),
AttributeData::of('color')->withSortOrder(3),
AttributeData::of('density')->withSortOrder(1),
AttributeData::of('Density')->withSortOrder(1),
]))->withAttribute(AttributeData::of('volume')->withSortOrder(19));

self::assertTrue(AttributeDataSet::of([
Expand Down

0 comments on commit fc19561

Please sign in to comment.