Skip to content

Commit 76d2d48

Browse files
authored
Cast total to string before setting value in refund inputs (#485)
| Q | A | --------------- | ----- | Branch? | 2.0 | Bug fix? | yes | New feature? | no | Related tickets | none Setting a value on an input field requires it to be a string. Without this fix you can end up with this error: ```log Behat\Testwork\Call\Exception\FatalThrowableError: Type error: Symfony\Component\Panther\DomCrawler\Field\InputFormField::setTextValue(): Argument #1 ($value) must be of type ?string, float given, called in vendor/symfony/panther/src/DomCrawler/Field/InputFormField.php on line 29 in vendor/symfony/panther/src/DomCrawler/Field/FormFieldTrait.php:57 Stack trace: #0 vendor/symfony/panther/src/DomCrawler/Field/InputFormField.php(29): Symfony\Component\Panther\DomCrawler\Field\InputFormField->setTextValue(10.0) #1 vendor/robertfausk/mink-panther-driver/src/PantherDriver.php(559): Symfony\Component\Panther\DomCrawler\Field\InputFormField->setValue(10.0) #2 vendor/friends-of-behat/mink/src/Element/NodeElement.php(105): Behat\Mink\Driver\PantherDriver->setValue('((//html/descen...', 10.0) #3 vendor/sylius/refund-plugin/tests/Behat/Page/Admin/OrderRefundsPage.php(47): Behat\Mink\Element\NodeElement->setValue(10.0) #4 vendor/sylius/refund-plugin/tests/Behat/Context/Ui/RefundingContext.php(54): ```
2 parents 6af7c11 + bcaf105 commit 76d2d48

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tests/Behat/Page/Admin/OrderRefundsPage.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function pickUnitWithProductToRefund(string $productName, int $unitNumber
4444
/** @var double $total */
4545
$total -= $refunded;
4646

47-
$units[$unitNumber]->find('css','td:nth-child(3) input')->setValue($total);
47+
$units[$unitNumber]->find('css','td:nth-child(3) input')->setValue((string) $total);
4848
}
4949

5050
public function pickPartOfUnitWithProductToRefund(string $productName, int $unitNumber, string $amount): void
@@ -71,7 +71,7 @@ public function pickOrderShipment(?string $shippingMethodName = null): void
7171
$total = (double) substr($total, 1) - (double) substr($refunded, 1);
7272
}
7373

74-
$orderShipment->find('css','td:nth-child(3) input')->setValue($total);
74+
$orderShipment->find('css','td:nth-child(3) input')->setValue((string) $total);
7575
}
7676

7777
public function pickPartOfOrderShipmentToRefund(string $amount): void

0 commit comments

Comments
 (0)