Skip to content

Commit

Permalink
Added tests for toggle field type
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronNeonDigital committed Oct 8, 2024
1 parent cd3260a commit 59a8fb9
Showing 1 changed file with 24 additions and 0 deletions.
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']);
});

0 comments on commit 59a8fb9

Please sign in to comment.