mirror of
https://github.com/filamentphp/filament.git
synced 2026-11-04 14:54:22 +08:00
41 lines
1.2 KiB
PHP
41 lines
1.2 KiB
PHP
<?php
|
|
|
|
use Filament\Forms\ComponentContainer;
|
|
use Filament\Forms\Components\Field;
|
|
use Illuminate\Support\Str;
|
|
use Tests\TestCase;
|
|
use Tests\Unit\Forms\Fixtures\Livewire;
|
|
|
|
uses(TestCase::class);
|
|
|
|
it('sets its state path from its name', function () {
|
|
$field = (new Field($name = Str::random()))
|
|
->container(ComponentContainer::make(Livewire::make()));
|
|
|
|
expect($field)
|
|
->getStatePath()->toBe($name);
|
|
});
|
|
|
|
it('sets its fallback label from its name', function () {
|
|
$field = (new Field($name = Str::random()))
|
|
->container(ComponentContainer::make(Livewire::make()));
|
|
|
|
expect($field)
|
|
->getLabel()->toBe(
|
|
(string) Str::of($name)
|
|
->afterLast('.')
|
|
->kebab()
|
|
->replace(['-', '_'], ' ')
|
|
->ucfirst(),
|
|
);
|
|
});
|
|
|
|
it('has state binding modifiers', function () {
|
|
$field = (new Field(Str::random()))
|
|
->container(ComponentContainer::make(Livewire::make()))
|
|
->stateBindingModifiers($modifiers = [Str::random(), Str::random()]);
|
|
|
|
expect($field)
|
|
->applyStateBindingModifiers($expression = Str::random())->toBe(implode('.', array_merge([$expression], $modifiers)));
|
|
});
|