Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type declaration on toggle field type #1982

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/admin/resources/lang/es/order.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
'label' => 'Cantidad',

'hint' => [
'less_than_total' => "Está a punto de capturar un monto menor al valor total de la transacción",
'less_than_total' => 'Está a punto de capturar un monto menor al valor total de la transacción',
],
],

Expand Down
3 changes: 1 addition & 2 deletions packages/admin/resources/lang/nl/order.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
'label' => 'Bedrag',

'hint' => [
'less_than_total' => "Je staat op het punt een bedrag te incasseren dat minder is dan de totale transactiewaarde",
'less_than_total' => 'Je staat op het punt een bedrag te incasseren dat minder is dan de totale transactiewaarde',
],
],

Expand Down Expand Up @@ -290,4 +290,3 @@
],

];

1 change: 0 additions & 1 deletion packages/admin/resources/lang/nl/widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,3 @@
],
],
];

2 changes: 1 addition & 1 deletion packages/core/src/FieldTypes/Toggle.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function jsonSerialize(): mixed
/**
* Create a new instance of Toggle field type.
*
* @param string $value
* @param bool|string $value
*/
public function __construct($value = false)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
return [
'shipping_methods' => [
'customer_groups' => [
'description' => "Asocia grupos de clientes a este método de envío para determinar su disponibilidad.",
'description' => 'Asocia grupos de clientes a este método de envío para determinar su disponibilidad.',
],
],
'shipping_rates' => [
Expand Down
24 changes: 24 additions & 0 deletions tests/core/Unit/FieldTypes/ToggleFieldTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

uses(\Lunar\Tests\Core\TestCase::class);
use Lunar\Exceptions\FieldTypeException;
use Lunar\FieldTypes\Toggle;

test('can set value', function () {
$field = new Toggle;
$field->setValue(false);

expect($field->getValue())->toEqual(false);
});

test('can set value in constructor', function () {
$field = new Toggle(true);

expect($field->getValue())->toEqual(true);
});

test('check it does not allow array', function () {
$this->expectException(FieldTypeException::class);

new Toggle(['foo']);
});