Skip to content

Commit

Permalink
[BUGFIX] Value of 0.00 is not rendered when used in view helper
Browse files Browse the repository at this point in the history
Resolves: #23
  • Loading branch information
brotkrueml committed Nov 3, 2019
1 parent 9b97d5c commit da490f9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
7 changes: 1 addition & 6 deletions Classes/Core/ViewHelpers/AbstractTypeViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public function render()
protected function checkSpecificTypeAttribute(): void
{
$specificTypeFromArguments = (string)($this->arguments[static::ARGUMENT_SPECIFIC_TYPE] ?? '');
unset($this->arguments[static::ARGUMENT_SPECIFIC_TYPE]);

if (empty($specificTypeFromArguments)) {
return;
Expand All @@ -114,8 +115,6 @@ protected function checkSpecificTypeAttribute(): void
}

$this->specificType = $specificTypeFromArguments;

unset($this->arguments[static::ARGUMENT_SPECIFIC_TYPE]);
}

protected function checkAsAttribute(): void
Expand Down Expand Up @@ -181,10 +180,6 @@ protected function assignArgumentsToItem(): void
unset($this->arguments[static::ARGUMENT_ID]);

foreach ($this->arguments as $name => $value) {
if (empty($value)) {
continue;
}

$model->setProperty($name, $value);
}

Expand Down
9 changes: 9 additions & 0 deletions Tests/Unit/Core/Model/AbstractTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,15 @@ public function dataProviderForToArrayReturnsCorrectResult(): iterable
],
];

yield 'Value is the number 0.10 as float' => [
'name',
0.10,
[
'@type' => 'FixtureThing',
'name' => '0.1',
],
];

yield 'Value is a model' => [
'image',
(new FixtureImage())
Expand Down
16 changes: 16 additions & 0 deletions Tests/Unit/ViewHelpers/Type/ThingViewHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,22 @@ public function fluidTemplatesProvider(): iterable
</schema:type.thing>',
'<script type="application/ld+json">{"@context":"http://schema.org","@type":"WebPage","mainEntity":{"@type":"Thing","@id":"parentThing","name":"parent name","subjectOf":{"@type":"Person","@id":"childThing","name":"child name","url":"https://example.org/child"},"url":"http://example.org/"}}</script>',
];

yield 'Property value of 0.00 is rendered' => [
'<schema:type.offer
price="0.00"
priceCurrency="EUR"
/>',
'<script type="application/ld+json">{"@context":"http://schema.org","@type":"Offer","price":"0","priceCurrency":"EUR"}</script>',
];

yield 'Property value of 0.01 is rendered' => [
'<schema:type.offer
price="0.01"
priceCurrency="EUR"
/>',
'<script type="application/ld+json">{"@context":"http://schema.org","@type":"Offer","price":"0.01","priceCurrency":"EUR"}</script>',
];
}

/**
Expand Down

0 comments on commit da490f9

Please sign in to comment.