fix for v4

This commit is contained in:
Dan Harrin
2024-07-30 12:41:51 +01:00
70 changed files with 817 additions and 442 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ use Livewire\LivewireServiceProvider;
use Orchestra\Testbench\Concerns\CreatesApplication;
use Orchestra\Testbench\Foundation\Application;
$basePathLocator = new class()
$basePathLocator = new class
{
use CreatesApplication;
};
Generated
+276 -276
View File
File diff suppressed because it is too large Load Diff
@@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class() extends Migration
return new class extends Migration
{
/**
* Run the migrations.
@@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class() extends Migration
return new class extends Migration
{
/**
* Run the migrations.
@@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class() extends Migration
return new class extends Migration
{
/**
* Run the migrations.
@@ -11,8 +11,14 @@ return [
'form' => [
'file' => [
'label' => 'Archivo',
'placeholder' => 'Cargar un archivo CSV',
'rules' => [
'duplicate_columns' => '{0} El archivo no debe contener más de un encabezado de columna vacío.|{1,*} El archivo no debe contener encabezados de columna duplicados: :columns.',
],
],
'columns' => [
+2 -2
View File
@@ -515,12 +515,12 @@ class Action extends ViewComponent implements Arrayable
public function cancel(bool $shouldRollBackDatabaseTransaction = false): void
{
throw (new Cancel())->rollBackDatabaseTransaction($shouldRollBackDatabaseTransaction);
throw (new Cancel)->rollBackDatabaseTransaction($shouldRollBackDatabaseTransaction);
}
public function halt(bool $shouldRollBackDatabaseTransaction = false): void
{
throw (new Halt())->rollBackDatabaseTransaction($shouldRollBackDatabaseTransaction);
throw (new Halt)->rollBackDatabaseTransaction($shouldRollBackDatabaseTransaction);
}
/**
@@ -44,6 +44,6 @@ class ActionsServiceProvider extends PackageServiceProvider
}
}
Testable::mixin(new TestsActions());
Testable::mixin(new TestsActions);
}
}
@@ -4,7 +4,6 @@ namespace Filament\Actions\Concerns;
use Closure;
use Filament\Actions\Action;
use Filament\Actions\Exceptions\ActionNotResolvableException;
use Filament\Support\Enums\Alignment;
use Filament\Support\Enums\MaxWidth;
use Filament\Support\View\Components\Modal;
@@ -31,7 +31,7 @@ trait HasExtraModalWindowAttributes
*/
public function getExtraModalWindowAttributes(): array
{
$temporaryAttributeBag = new ComponentAttributeBag();
$temporaryAttributeBag = new ComponentAttributeBag;
foreach ($this->extraModalWindowAttributes as $extraModalWindowAttributes) {
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraModalWindowAttributes));
+1 -1
View File
@@ -78,7 +78,7 @@ class CreateAction extends Action
if ($translatableContentDriver = $livewire->makeFilamentTranslatableContentDriver()) {
$record = $translatableContentDriver->makeRecord($model, $data);
} else {
$record = new $model();
$record = new $model;
$record->fill($data);
}
@@ -71,7 +71,7 @@ class ExportCsv implements ShouldQueue
$processedRows = 0;
$successfulRows = 0;
$csv = Writer::createFromFileObject(new SplTempFileObject());
$csv = Writer::createFromFileObject(new SplTempFileObject);
$csv->setDelimiter($this->exporter::getCsvDelimiter());
$query = EloquentSerializeFacade::unserialize($this->query);
@@ -52,7 +52,7 @@ class PrepareCsvExport implements ShouldQueue
public function handle(): void
{
$csv = Writer::createFromFileObject(new SplTempFileObject());
$csv = Writer::createFromFileObject(new SplTempFileObject);
$csv->setOutputBOM(ByteSequence::BOM_UTF8);
$csv->setDelimiter($this->exporter::getCsvDelimiter());
$csv->insertOne(array_values($this->columnMap));
+1 -1
View File
@@ -323,7 +323,7 @@ class ImportAction extends Action
->action(function (): StreamedResponse {
$columns = $this->getImporter()::getColumns();
$csv = Writer::createFromFileObject(new SplTempFileObject());
$csv = Writer::createFromFileObject(new SplTempFileObject);
if (filled($csvDelimiter = $this->getCsvDelimiter())) {
$csv->setDelimiter($csvDelimiter);
@@ -22,7 +22,7 @@ class DownloadImportFailureCsv
abort_unless($import->user()->is(auth()->user()), 403);
}
$csv = Writer::createFromFileObject(new SplTempFileObject());
$csv = Writer::createFromFileObject(new SplTempFileObject);
$csv->setOutputBOM(ByteSequence::BOM_UTF8);
$columnHeaders = array_keys($import->failedRows()->first()->data);
+10 -1
View File
@@ -2,7 +2,6 @@
namespace Livewire\Features\SupportTesting {
use Illuminate\Support\Collection;
use Closure;
class Testable {
@@ -31,6 +30,16 @@ namespace Livewire\Features\SupportTesting {
public function assertFormComponentExists(string $componentKey, string | Closure $formName = 'form', ?Closure $checkComponentUsing = null): static {}
public function assertFormComponentDoesNotExist(string $componentKey, string $formName = 'form'): static {}
public function goToWizardStep(int $step, string $formName = 'form'): static {}
public function goToNextWizardStep(string $formName = 'form'): static {}
public function goToPreviousWizardStep(string $formName = 'form'): static {}
public function assertWizardStepExists(int $step, string $formName = 'form'): static {}
public function assertWizardCurrentStep(int $step, string $formName = 'form'): static {}
}
}
+50
View File
@@ -286,6 +286,56 @@ test('comments section is enabled' function () {
});
```
### Wizard
To go to a wizard's next step, use `goToNextWizardStep()`:
```php
use function Pest\Livewire\livewire;
it('moves to next wizard step', function () {
livewire(CreatePost::class)
->goToNextWizardStep()
->assertHasFormErrors(['title']);
});
```
You can also go to the previous step by calling `goToPreviousWizardStep()`:
```php
use function Pest\Livewire\livewire;
it('moves to next wizard step', function () {
livewire(CreatePost::class)
->goToPreviousWizardStep()
->assertHasFormErrors(['title']);
});
```
If you want to go to a specific step, use `goToWizardStep()`, then the `assertWizardCurrentStep` method which can ensure you are on the desired step without validation errors from the previous:
```php
use function Pest\Livewire\livewire;
it('moves to the wizards second step', function () {
livewire(CreatePost::class)
->goToWizardStep(2)
->assertWizardCurrentStep(2);
});
```
If you have multiple forms on a single Livewire component, any of the wizard test helpers can accept a `formName` parameter:
```php
use function Pest\Livewire\livewire;
it('moves to next wizard step only for fooForm', function () {
livewire(CreatePost::class)
->goToNextWizardStep(formName: 'fooForm')
->assertHasFormErrors(['title'], formName: 'fooForm');
});
```
## Actions
You can call an action by passing its form component name, and then the name of the action to `callFormComponentAction()`:
@@ -11,17 +11,69 @@ return [
],
'add' => [
'label' => 'Añadir a :label',
'modal' => [
'heading' => 'Añadir a :label',
'actions' => [
'add' => [
'label' => 'Añadir',
],
],
],
],
'add_between' => [
'label' => 'Insertar',
'label' => 'Insertar entre bloques',
'modal' => [
'heading' => 'Añadir a :label',
'actions' => [
'add' => [
'label' => 'Añadir',
],
],
],
],
'delete' => [
'label' => 'Borrar',
],
'edit' => [
'label' => 'Editar',
'modal' => [
'heading' => 'Editar bloque',
'actions' => [
'save' => [
'label' => 'Guardar cambios',
],
],
],
],
'reorder' => [
'label' => 'Mover',
],
@@ -31,7 +31,7 @@ trait HasExtraFieldWrapperAttributes
*/
public function getExtraFieldWrapperAttributes(): array
{
$temporaryAttributeBag = new ComponentAttributeBag();
$temporaryAttributeBag = new ComponentAttributeBag;
foreach ($this->extraFieldWrapperAttributes as $extraFieldWrapperAttributes) {
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraFieldWrapperAttributes));
@@ -31,7 +31,7 @@ trait HasExtraInputAttributes
*/
public function getExtraInputAttributes(): array
{
$temporaryAttributeBag = new ComponentAttributeBag();
$temporaryAttributeBag = new ComponentAttributeBag;
foreach ($this->extraInputAttributes as $extraInputAttributes) {
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraInputAttributes));
@@ -369,7 +369,7 @@ class DateTimePicker extends Field implements HasAffixActions
*/
public function getExtraTriggerAttributes(): array
{
$temporaryAttributeBag = new ComponentAttributeBag();
$temporaryAttributeBag = new ComponentAttributeBag;
foreach ($this->extraTriggerAttributes as $extraTriggerAttributes) {
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraTriggerAttributes));
+1 -1
View File
@@ -960,7 +960,7 @@ class Repeater extends Field implements CanConcealComponents, HasExtraItemAction
if ($translatableContentDriver) {
$record = $translatableContentDriver->makeRecord($relatedModel, $itemData);
} else {
$record = new $relatedModel();
$record = new $relatedModel;
$record->fill($itemData);
}
+2 -2
View File
@@ -49,7 +49,7 @@ class FormsServiceProvider extends PackageServiceProvider
}
}
Testable::mixin(new TestsForms());
Testable::mixin(new TestsFormComponentActions());
Testable::mixin(new TestsForms);
Testable::mixin(new TestsFormComponentActions);
}
}
+99
View File
@@ -7,6 +7,7 @@ use Filament\Forms\Components\Field;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Contracts\HasForms;
use Filament\Schema\Components\Component;
use Filament\Schema\Components\Wizard;
use Filament\Schema\Schema;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Arr;
@@ -401,4 +402,102 @@ class TestsForms
return $this;
};
}
public function assertWizardStepExists(): Closure
{
return function (int $step, string $formName = 'form'): static {
/** @phpstan-ignore-next-line */
$this->assertFormExists($formName);
/** @var Schema $form */
$form = $this->instance()->{$formName};
/** @var Wizard $wizard */
$wizard = $form->getComponent(fn (Component $component): bool => $component instanceof Wizard);
Assert::assertArrayHasKey(
$step - 1,
$wizard->getChildComponents(),
"Wizard does not have a step {$step}."
);
return $this;
};
}
public function assertWizardCurrentStep(): Closure
{
return function (int $step, string $formName = 'form'): static {
/** @phpstan-ignore-next-line */
$this->assertFormExists($formName);
/** @var Schema $form */
$form = $this->instance()->{$formName};
/** @var Wizard $wizard */
$wizard = $form->getComponent(fn (Component $component): bool => $component instanceof Wizard);
Assert::assertEquals(
$step,
$current = $wizard->getCurrentStepIndex() + 1,
"Failed asserting that wizard is on step {$step}, current step is {$current}."
);
return $this;
};
}
public function goToWizardStep(): Closure
{
return function (int $step, string $formName = 'form'): static {
/** @phpstan-ignore-next-line */
$this->assertWizardStepExists($step, $formName);
/** @var Schema $form */
$form = $this->instance()->{$formName};
/** @var Wizard $wizard */
$wizard = $form->getComponent(fn (Component $component): bool => $component instanceof Wizard);
$stepIndex = ($step <= 1) ? 0 : $step - 2;
$this->call('callSchemaComponentMethod', $wizard->getKey(), 'nextStep', [$stepIndex]);
return $this;
};
}
public function goToNextWizardStep(): Closure
{
return function (string $formName = 'form'): static {
/** @phpstan-ignore-next-line */
$this->assertFormExists($formName);
/** @var Schema $form */
$form = $this->instance()->{$formName};
/** @var Wizard $wizard */
$wizard = $form->getComponent(fn (Component $component): bool => $component instanceof Wizard);
$this->call('callSchemaComponentMethod', $wizard->getKey(), 'nextStep', [$wizard->getCurrentStepIndex()]);
return $this;
};
}
public function goToPreviousWizardStep(): Closure
{
return function (string $formName = 'form'): static {
/** @phpstan-ignore-next-line */
$this->assertFormExists($formName);
/** @var Schema $form */
$form = $this->instance()->{$formName};
/** @var Wizard $wizard */
$wizard = $form->getComponent(fn (Component $component): bool => $component instanceof Wizard);
$this->call('callSchemaComponentMethod', $wizard->getKey(), 'previousStep', [$wizard->getCurrentStepIndex()]);
return $this;
};
}
}
@@ -204,7 +204,7 @@ trait CanFormatState
);
}
$locale = $component->evaluate($locale) ?? Infolist::$defaultNumberLocale ?? config('app.locale');
$locale = $component->evaluate($locale) ?? Schema::$defaultNumberLocale ?? config('app.locale');
return Number::format($state, $decimalPlaces, $component->evaluate($maxDecimalPlaces), $locale);
});
@@ -31,7 +31,7 @@ trait HasExtraEntryWrapperAttributes
*/
public function getExtraEntryWrapperAttributes(): array
{
$temporaryAttributeBag = new ComponentAttributeBag();
$temporaryAttributeBag = new ComponentAttributeBag;
foreach ($this->extraEntryWrapperAttributes as $extraEntryWrapperAttributes) {
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraEntryWrapperAttributes));
@@ -22,6 +22,6 @@ class InfolistsServiceProvider extends PackageServiceProvider
public function packageBooted(): void
{
Testable::mixin(new TestsInfolistActions());
Testable::mixin(new TestsInfolistActions);
}
}
@@ -27,7 +27,7 @@ class Notifications extends Component
public function mount(): void
{
$this->notifications = new Collection();
$this->notifications = new Collection;
$this->pullNotificationsFromSession();
}
+2 -2
View File
@@ -236,7 +236,7 @@ class Notification extends ViewComponent implements Arrayable
public static function assertNotified(Notification | string | null $notification = null): void
{
$notificationsLivewireComponent = new Notifications();
$notificationsLivewireComponent = new Notifications;
$notificationsLivewireComponent->mount();
$notifications = $notificationsLivewireComponent->notifications;
@@ -272,7 +272,7 @@ class Notification extends ViewComponent implements Arrayable
public static function assertNotNotified(Notification | string | null $notification = null): void
{
$notificationsLivewireComponent = new Notifications();
$notificationsLivewireComponent = new Notifications;
$notificationsLivewireComponent->mount();
$notifications = $notificationsLivewireComponent->notifications;
@@ -52,6 +52,6 @@ class NotificationsServiceProvider extends PackageServiceProvider
$component->dispatch('notificationsSent');
});
Testable::mixin(new TestsNotifications());
Testable::mixin(new TestsNotifications);
}
}
@@ -56,15 +56,15 @@ class FilamentServiceProvider extends PackageServiceProvider
public function packageRegistered(): void
{
$this->app->scoped('filament', function (): FilamentManager {
return new FilamentManager();
return new FilamentManager;
});
$this->app->singleton(PanelRegistry::class, function (): PanelRegistry {
return new PanelRegistry();
return new PanelRegistry;
});
$this->app->scoped(NavigationManager::class, function (): NavigationManager {
return new NavigationManager();
return new NavigationManager;
});
$this->app->bind(EmailVerificationResponseContract::class, EmailVerificationResponse::class);
@@ -31,7 +31,7 @@ trait HasExtraSidebarAttributes
*/
public function getExtraSidebarAttributes(): array
{
$temporaryAttributeBag = new ComponentAttributeBag();
$temporaryAttributeBag = new ComponentAttributeBag;
foreach ($this->extraSidebarAttributes as $extraSidebarAttributes) {
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraSidebarAttributes));
@@ -31,7 +31,7 @@ trait HasExtraTopbarAttributes
*/
public function getExtraTopbarAttributes(): array
{
$temporaryAttributeBag = new ComponentAttributeBag();
$temporaryAttributeBag = new ComponentAttributeBag;
foreach ($this->extraTopbarAttributes as $extraTopbarAttributes) {
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraTopbarAttributes));
+1 -1
View File
@@ -126,7 +126,7 @@ abstract class BasePage extends Component implements HasActions, HasForms, HasIn
protected function halt(): void
{
throw new Halt();
throw new Halt;
}
protected function callHook(string $hook): void
@@ -188,7 +188,7 @@ trait HasRoutes
Filament::setTenant($tenant, isQuiet: true);
}
$this->navigationManager = new NavigationManager();
$this->navigationManager = new NavigationManager;
$navigation = $this->navigationManager->get();
@@ -193,7 +193,7 @@ trait HasTenancy
->resolveRouteBinding($key, $this->getTenantSlugAttribute());
if ($record === null) {
throw (new ModelNotFoundException())->setModel($tenantModel, [$key]);
throw (new ModelNotFoundException)->setModel($tenantModel, [$key]);
}
return $record;
@@ -79,7 +79,7 @@ trait InteractsWithParentRecord
);
if ($parentRecord === null) {
throw (new ModelNotFoundException())->setModel($parentResource::getModel(), [$parentRecordKey]);
throw (new ModelNotFoundException)->setModel($parentResource::getModel(), [$parentRecordKey]);
}
if ($previousParentRecord) {
@@ -33,7 +33,7 @@ trait InteractsWithRecord
$record = static::getResource()::resolveRecordRouteBinding($key, $modifyQuery);
if ($record === null) {
throw (new ModelNotFoundException())->setModel($this->getModel(), [$key]);
throw (new ModelNotFoundException)->setModel($this->getModel(), [$key]);
}
if ($parentRecord) {
+1 -1
View File
@@ -34,7 +34,7 @@ if (! function_exists('Filament\authorize')) {
);
if ($response === false) {
throw new AuthorizationException();
throw new AuthorizationException;
}
if (! $response instanceof Response) {
@@ -65,7 +65,7 @@ trait EntanglesStateWithSingularRelationship
if ($translatableContentDriver) {
$record = $translatableContentDriver->makeRecord($relatedModel, $data);
} else {
$record = new $relatedModel();
$record = new $relatedModel;
$record->fill($data);
}
@@ -108,7 +108,7 @@ trait EntanglesStateWithSingularRelationship
if ($translatableContentDriver) {
$record = $translatableContentDriver->makeRecord($relatedModel, $data);
} else {
$record = new $relatedModel();
$record = new $relatedModel;
$record->fill($data);
}
+27
View File
@@ -31,6 +31,8 @@ class Wizard extends Component
protected int | Closure $startStep = 1;
protected int $currentStepIndex = 0;
/**
* @var view-string
*/
@@ -61,6 +63,8 @@ class Wizard extends Component
$this->key('wizard');
$this->currentStepIndex($this->getStartStep() - 1);
$this->registerActions([
fn (Wizard $component): Action => $component->getNextAction(),
fn (Wizard $component): Action => $component->getPreviousAction(),
@@ -82,6 +86,7 @@ class Wizard extends Component
/** @var ?Step $nextStep */
$nextStep = $steps[$currentStepIndex + 1] ?? null;
$this->currentStepIndex($currentStepIndex + 1);
try {
$currentStep->callBeforeValidation();
@@ -98,6 +103,16 @@ class Wizard extends Component
$livewire->dispatch('next-wizard-step', key: $this->getKey());
}
#[Exposed]
public function previousStep(int $currentStepIndex): void
{
if ($currentStepIndex < 1) {
$currentStepIndex = 1;
}
$this->currentStepIndex($currentStepIndex - 1);
}
public function getNextAction(): Action
{
$action = Action::make($this->getNextActionName())
@@ -243,4 +258,16 @@ class Wizard extends Component
{
return filled($this->getStepQueryStringKey());
}
public function getCurrentStepIndex(): int
{
return $this->currentStepIndex;
}
protected function currentStepIndex(int $index): static
{
$this->currentStepIndex = $index;
return $this;
}
}
@@ -16,7 +16,7 @@ class SpatieTagsInput extends TagsInput
{
parent::setUp();
$this->type(new AllTagTypes());
$this->type(new AllTagTypes);
$this->loadStateFromRelationshipsUsing(static function (SpatieTagsInput $component, ?Model $record): void {
if (! method_exists($record, 'tagsWithType')) {
@@ -30,7 +30,7 @@ class SpatieLaravelTranslatableContentDriver implements TranslatableContentDrive
*/
public function makeRecord(string $model, array $data): Model
{
$record = new $model();
$record = new $model;
if (method_exists($record, 'setLocale')) {
$record->setLocale($this->activeLocale);
@@ -179,7 +179,7 @@
x-transition:leave-end="scale-95 opacity-0"
@endif
{{
($extraModalWindowAttributeBag ?? new \Illuminate\View\ComponentAttributeBag())->class([
($extraModalWindowAttributeBag ?? new \Illuminate\View\ComponentAttributeBag)->class([
'fi-modal-window pointer-events-auto relative row-start-2 flex w-full cursor-default flex-col bg-white shadow-xl ring-1 ring-gray-950/5 dark:bg-gray-900 dark:ring-white/10',
'fi-modal-slide-over-window ms-auto overflow-y-auto' => $slideOver,
// Using an arbitrary value instead of the h-dvh class that was added in Tailwind CSS v3.4.0
@@ -34,7 +34,7 @@ class ComponentManager implements ScopedComponentManager
app()->singletonIf(
ComponentManager::class,
fn () => new ComponentManager(),
fn () => new ComponentManager,
);
return app(ComponentManager::class);
@@ -111,7 +111,7 @@ abstract class ViewComponent extends Component implements Htmlable
return view(
$this->getView(),
[
'attributes' => new ComponentAttributeBag(),
'attributes' => new ComponentAttributeBag,
...$this->extractPublicMethods(),
...(isset($this->viewIdentifier) ? [$this->viewIdentifier => $this] : []),
...$this->viewData,
@@ -31,7 +31,7 @@ trait HasExtraAlpineAttributes
*/
public function getExtraAlpineAttributes(): array
{
$temporaryAttributeBag = new ComponentAttributeBag();
$temporaryAttributeBag = new ComponentAttributeBag;
foreach ($this->extraAlpineAttributes as $extraAlpineAttributes) {
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraAlpineAttributes));
@@ -31,7 +31,7 @@ trait HasExtraAttributes
*/
public function getExtraAttributes(): array
{
$temporaryAttributeBag = new ComponentAttributeBag();
$temporaryAttributeBag = new ComponentAttributeBag;
foreach ($this->extraAttributes as $extraAttributes) {
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraAttributes));
@@ -60,7 +60,7 @@ class SupportServiceProvider extends PackageServiceProvider
{
$this->app->scoped(
AssetManager::class,
fn () => new AssetManager(),
fn () => new AssetManager,
);
$this->app->scoped(
@@ -72,23 +72,23 @@ class SupportServiceProvider extends PackageServiceProvider
$this->app->scoped(
ColorManager::class,
fn () => new ColorManager(),
fn () => new ColorManager,
);
$this->app->scoped(
IconManager::class,
fn () => new IconManager(),
fn () => new IconManager,
);
$this->app->scoped(
ViewManager::class,
fn () => new ViewManager(),
fn () => new ViewManager,
);
$this->app->scoped(
HtmlSanitizerInterface::class,
fn (): HtmlSanitizer => new HtmlSanitizer(
(new HtmlSanitizerConfig())
(new HtmlSanitizerConfig)
->allowSafeElements()
->allowRelativeLinks()
->allowRelativeMedias()
@@ -122,7 +122,7 @@ class SupportServiceProvider extends PackageServiceProvider
public function packageBooted(): void
{
app('livewire')->componentHook(new SupportPartials());
app('livewire')->componentHook(new SupportPartials);
FilamentAsset::register([
Js::make('async-alpine', __DIR__ . '/../dist/async-alpine.js'),
+1 -1
View File
@@ -51,7 +51,7 @@ if (! function_exists('Filament\Support\get_model_label')) {
if (! function_exists('Filament\Support\locale_has_pluralization')) {
function locale_has_pluralization(): bool
{
return (new MessageSelector())->getPluralIndex(app()->getLocale(), 10) > 0;
return (new MessageSelector)->getPluralIndex(app()->getLocale(), 10) > 0;
}
}
@@ -31,7 +31,7 @@ trait HasExtraCellAttributes
*/
public function getExtraCellAttributes(): array
{
$temporaryAttributeBag = new ComponentAttributeBag();
$temporaryAttributeBag = new ComponentAttributeBag;
foreach ($this->extraCellAttributes as $extraCellAttributes) {
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraCellAttributes));
@@ -31,7 +31,7 @@ trait HasExtraHeaderAttributes
*/
public function getExtraHeaderAttributes(): array
{
$temporaryAttributeBag = new ComponentAttributeBag();
$temporaryAttributeBag = new ComponentAttributeBag;
foreach ($this->extraHeaderAttributes as $extraHeaderAttributes) {
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraHeaderAttributes));
+1 -1
View File
@@ -239,7 +239,7 @@ class ImageColumn extends Column
*/
public function getExtraImgAttributes(): array
{
$temporaryAttributeBag = new ComponentAttributeBag();
$temporaryAttributeBag = new ComponentAttributeBag;
foreach ($this->extraImgAttributes as $extraImgAttributes) {
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraImgAttributes));
@@ -43,11 +43,11 @@ class TablesServiceProvider extends PackageServiceProvider
}
}
Testable::mixin(new TestsActions());
Testable::mixin(new TestsBulkActions());
Testable::mixin(new TestsColumns());
Testable::mixin(new TestsFilters());
Testable::mixin(new TestsRecords());
Testable::mixin(new TestsSummaries());
Testable::mixin(new TestsActions);
Testable::mixin(new TestsBulkActions);
Testable::mixin(new TestsColumns);
Testable::mixin(new TestsFilters);
Testable::mixin(new TestsRecords);
Testable::mixin(new TestsSummaries);
}
}
@@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class() extends Migration
return new class extends Migration
{
public function up(): void
{
@@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class() extends Migration
return new class extends Migration
{
public function up(): void
{
@@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class() extends Migration
return new class extends Migration
{
public function up(): void
{
+3 -3
View File
@@ -23,7 +23,7 @@ it('has components', function () {
$components = [];
foreach (range(1, $count = rand(2, 10)) as $i) {
$components[] = new Component();
$components[] = new Component;
}
$componentsBoundToContainer = ($container = Schema::make(Livewire::make()))
@@ -43,7 +43,7 @@ it('has dynamic components', function () {
$components = [];
foreach (range(1, $count = rand(2, 10)) as $i) {
$components[] = new Component();
$components[] = new Component;
}
$componentsBoundToContainer = ($container = Schema::make(Livewire::make()))
@@ -61,7 +61,7 @@ it('has dynamic components', function () {
it('belongs to parent component', function () {
$container = Schema::make(Livewire::make())
->parentComponent($component = new Component());
->parentComponent($component = new Component);
expect($container)
->getParentComponent()->toBe($component);
+6 -6
View File
@@ -9,7 +9,7 @@ use Illuminate\Support\Str;
uses(TestCase::class);
it('belongs to container', function () {
$component = (new Component())
$component = (new Component)
->container($container = Schema::make(Livewire::make()));
expect($component)
@@ -17,7 +17,7 @@ it('belongs to container', function () {
});
it('can access container\'s Livewire component', function () {
$component = (new Component())
$component = (new Component)
->container(Schema::make($livewire = Livewire::make()));
expect($component)
@@ -28,10 +28,10 @@ it('has child components', function () {
$components = [];
foreach (range(1, $count = rand(2, 10)) as $i) {
$components[] = new Component();
$components[] = new Component;
}
$componentsBoundToContainer = ($parentComponent = new Component())
$componentsBoundToContainer = ($parentComponent = new Component)
->container(Schema::make(Livewire::make()))
->childComponents($components)
->getChildComponentContainer()
@@ -47,7 +47,7 @@ it('has child components', function () {
});
it('has a label', function () {
$component = (new Component())
$component = (new Component)
->container(Schema::make(Livewire::make()))
->label($label = Str::random());
@@ -56,7 +56,7 @@ it('has a label', function () {
});
it('can have meta', function () {
$component = (new Component())
$component = (new Component)
->meta('foo', 'bar')
->meta('bob', 'baz');
+1 -1
View File
@@ -15,7 +15,7 @@ class Livewire extends Component implements HasForms
public static function make(): static
{
return new static();
return new static;
}
public function mount(): void
+61
View File
@@ -2,6 +2,7 @@
use Filament\Forms\Components\TextInput;
use Filament\Schema\Components\Section;
use Filament\Schema\Components\Wizard;
use Filament\Schema\Schema;
use Filament\Tests\Forms\Fixtures\Livewire;
use Filament\Tests\TestCase;
@@ -108,6 +109,17 @@ it('does not have layout components', function () {
->assertFormComponentDoesNotExist('no-such-section');
});
it('can go to next wizard step on multiple forms', function () {
livewire(TestComponentWithMultipleWizardForms::class)
->assertHasNoFormErrors(formName: 'fooForm')
->assertHasNoFormErrors(formName: 'barForm')
->assertWizardStepExists(2, 'fooForm')
->goToWizardStep(2, formName: 'fooForm')
->assertHasFormErrors(['title'], 'fooForm')
->assertHasNoFormErrors(['title'], 'barForm');
});
class TestComponentWithForm extends Livewire
{
public function form(Schema $form): Schema
@@ -185,3 +197,52 @@ class TestComponentWithMultipleForms extends Livewire
];
}
}
class TestComponentWithMultipleWizardForms extends Livewire
{
public $fooData;
public $barData;
public function mount(): void
{
$this->fooForm->fill();
$this->barForm->fill();
}
protected function getForms(): array
{
return [
'fooForm',
'barForm',
];
}
public function fooForm(Schema $form): Schema
{
return $form
->schema($this->getSchemaForForms())
->statePath('fooData');
}
public function barForm(Schema $form): Schema
{
return $form
->schema($this->getSchemaForForms())
->statePath('barData');
}
protected function getSchemaForForms(): array
{
return [
Wizard::make([
Wizard\Step::make('step 1')->schema([
TextInput::make('title')->required(),
]),
Wizard\Step::make('step 2')->schema([
TextInput::make('content')->required(),
]),
]),
];
}
}
+4 -4
View File
@@ -40,7 +40,7 @@ test('can get number of container columns at one breakpoint', function () {
test('can get number of container columns from parent component', function () {
$container = Schema::make(Livewire::make())
->parentComponent((new Component())->columns([
->parentComponent((new Component)->columns([
'default' => $defaultColumns = rand(1, 12),
'sm' => $columnsAtSm = rand(1, 12),
'md' => $columnsAtMd = rand(1, 12),
@@ -68,7 +68,7 @@ test('can set number of container columns at `lg` breakpoint', function () {
});
test('can get component column span at all breakpoints', function () {
$component = (new Component())
$component = (new Component)
->container(Schema::make(Livewire::make()))
->columnSpan([
'default' => $defaultSpan = rand(1, 12),
@@ -90,7 +90,7 @@ test('can get component column span at all breakpoints', function () {
});
test('can get component column span at one breakpoint', function () {
$component = (new Component())
$component = (new Component)
->container(Schema::make(Livewire::make()))
->columnSpan([
'2xl' => $spanAt2xl = rand(1, 12),
@@ -101,7 +101,7 @@ test('can get component column span at one breakpoint', function () {
});
test('can set component column span at `default` breakpoint', function () {
$component = (new Component())
$component = (new Component)
->container(Schema::make(Livewire::make()))
->columnSpan($defaultSpan = rand(1, 12));
+8 -8
View File
@@ -10,7 +10,7 @@ use Illuminate\Support\Str;
uses(TestCase::class);
test('components can be hidden', function () {
$component = (new Component())
$component = (new Component)
->container(Schema::make(Livewire::make()))
->hidden();
@@ -23,7 +23,7 @@ test('components can be hidden based on condition', function () {
$container = Schema::make(Livewire::make())
->components([
(new Component())
(new Component)
->visible(fn (callable $get) => $get($statePath) === false),
])
->fill([
@@ -34,7 +34,7 @@ test('components can be hidden based on condition', function () {
->toHaveCount(0);
$container->components([
(new Component())
(new Component)
->whenTruthy($statePath),
]);
@@ -42,7 +42,7 @@ test('components can be hidden based on condition', function () {
->toHaveLength(1);
$container->components([
(new Component())
(new Component)
->whenFalsy($statePath),
]);
@@ -51,7 +51,7 @@ test('components can be hidden based on condition', function () {
$container
->components([
(new Component())
(new Component)
->whenFalsy([$statePath, 'bob']),
])
->fill([
@@ -63,7 +63,7 @@ test('components can be hidden based on condition', function () {
$container
->components([
(new Component())
(new Component)
->whenTruthy([$statePath, 'bob']),
])
->fill([
@@ -78,11 +78,11 @@ test('hidden components are not returned from container', function () {
$components = [];
foreach (range(1, $visibleCount = rand(2, 10)) as $i) {
$components[] = new Component();
$components[] = new Component;
}
foreach (range(1, rand(2, 10)) as $i) {
$components[] = (new Component())->hidden();
$components[] = (new Component)->hidden();
}
$componentsBoundToContainer = ($container = Schema::make(Livewire::make()))
+12 -12
View File
@@ -11,7 +11,7 @@ uses(TestCase::class);
test('containers can store a record', function () {
$container = Schema::make(Livewire::make())
->model($record = new Post());
->model($record = new Post);
expect($container)
->getRecord()->toBe($record);
@@ -24,7 +24,7 @@ test('containers can get their model class', function () {
expect($container)
->getModel()->toBe($model);
$container->model(new Post());
$container->model(new Post);
expect($container)
->getModel()->toBe($model);
@@ -32,7 +32,7 @@ test('containers can get their model class', function () {
test('containers can get an instance of their model', function () {
$container = Schema::make(Livewire::make())
->model($modelInstance = new Post());
->model($modelInstance = new Post);
expect($container)
->getModelInstance()->toBe($modelInstance);
@@ -44,16 +44,16 @@ test('containers can get an instance of their model', function () {
});
test('components can store a record', function () {
$component = (new Component())
$component = (new Component)
->container(Schema::make(Livewire::make()))
->model($record = new Post());
->model($record = new Post);
expect($component)
->getRecord()->toBe($record);
});
test('components can get their model class', function () {
$component = (new Component())
$component = (new Component)
->container(Schema::make(Livewire::make()))
->model($model = Post::class);
@@ -62,7 +62,7 @@ test('components can get their model class', function () {
});
test('components can get an instance of their model', function () {
$component = (new Component())
$component = (new Component)
->container(Schema::make(Livewire::make()))
->model($model = Post::class);
@@ -71,10 +71,10 @@ test('components can get an instance of their model', function () {
});
test('components can inherit their container record', function () {
$component = (new Component())
$component = (new Component)
->container(
Schema::make(Livewire::make())
->model($record = new Post()),
->model($record = new Post),
);
expect($component)
@@ -82,7 +82,7 @@ test('components can inherit their container record', function () {
});
test('components can inherit their container model class', function () {
$component = (new Component())
$component = (new Component)
->container(
Schema::make(Livewire::make())
->model($model = Post::class),
@@ -94,10 +94,10 @@ test('components can inherit their container model class', function () {
});
test('components do not inherit their container record if they have their own model defined', function () {
$component = (new Component())
$component = (new Component)
->container(
Schema::make(Livewire::make())
->model(new User()),
->model(new User),
)
->model($model = Post::class);
@@ -28,14 +28,14 @@ test('fields can have state binding modifiers', function () {
});
test('component state binding is deferred by default', function () {
$component = (new Component())->container(Schema::make(Livewire::make()));
$component = (new Component)->container(Schema::make(Livewire::make()));
expect($component)
->getStateBindingModifiers()->toBe([]);
});
test('component state binding can be live', function () {
$component = (new Component())
$component = (new Component)
->container(Schema::make(Livewire::make()))
->live();
@@ -44,7 +44,7 @@ test('component state binding can be live', function () {
});
test('component state binding can be triggered on blur', function () {
$component = (new Component())
$component = (new Component)
->container(Schema::make(Livewire::make()))
->live(onBlur: true);
@@ -53,7 +53,7 @@ test('component state binding can be triggered on blur', function () {
});
test('component state binding can be debounced', function () {
$component = (new Component())
$component = (new Component)
->container(Schema::make(Livewire::make()))
->live(debounce: '750ms');
@@ -62,11 +62,11 @@ test('component state binding can be debounced', function () {
});
test('components inherit their state binding modifiers', function () {
$component = (new Component())
$component = (new Component)
->container(
Schema::make(Livewire::make())
->parentComponent(
(new Component())->stateBindingModifiers($modifiers = [Str::random()]),
(new Component)->stateBindingModifiers($modifiers = [Str::random()]),
),
);
+56 -56
View File
@@ -25,7 +25,7 @@ test('container has state path', function () {
test('container has state path and inherits state path from parent component', function () {
$container = Schema::make(Livewire::make())
->parentComponent(
(new Component())
(new Component)
->container(Schema::make(Livewire::make()))
->statePath($parentComponentStatePath = Str::random()),
)
@@ -36,7 +36,7 @@ test('container has state path and inherits state path from parent component', f
});
test('component has state path', function () {
$component = (new Component())
$component = (new Component)
->container(Schema::make(Livewire::make()))
->statePath($componentStatePath = Str::random());
@@ -45,7 +45,7 @@ test('component has state path', function () {
});
test('component inherits state path from container', function () {
$component = (new Component())
$component = (new Component)
->container(
Schema::make(Livewire::make())
->statePath($containerStatePath = Str::random()),
@@ -56,7 +56,7 @@ test('component inherits state path from container', function () {
});
test('component has state path and inherits state path from container', function () {
$component = (new Component())
$component = (new Component)
->container(
Schema::make(Livewire::make())
->statePath($containerStatePath = Str::random()),
@@ -71,7 +71,7 @@ test('state can be hydrated from array', function () {
Schema::make($livewire = Livewire::make())
->statePath('data')
->components([
(new Component())
(new Component)
->statePath($statePath = Str::random()),
])
->fill([$statePath => ($state = Str::random())]);
@@ -91,7 +91,7 @@ test('hydrating array state can overwrite existing state', function () {
)
->statePath('data')
->components([
(new Component())
(new Component)
->statePath($statePath),
])
->fill([]);
@@ -104,7 +104,7 @@ test('state can be hydrated from defaults', function () {
Schema::make($livewire = Livewire::make())
->statePath('data')
->components([
(new Component())
(new Component)
->statePath($statePath = Str::random())
->default($state = Str::random()),
])
@@ -125,7 +125,7 @@ test('hydrating default state can overwrite existing state', function () {
)
->statePath('data')
->components([
(new Component())
(new Component)
->statePath($statePath),
])
->fill();
@@ -138,10 +138,10 @@ test('child component state is not lost by hydrating parent component', function
Schema::make($livewire = Livewire::make())
->statePath('data')
->components([
(new Component())
(new Component)
->statePath($parentStatePath = Str::random())
->schema([
(new Component())
(new Component)
->statePath($statePath = Str::random())
->default($state = Str::random()),
]),
@@ -156,10 +156,10 @@ test('child component state is not lost by hydrating parent component defaults',
Schema::make($livewire = Livewire::make())
->statePath('data')
->components([
(new Component())
(new Component)
->statePath($parentStatePath = Str::random())
->schema([
(new Component())
(new Component)
->statePath($statePath = Str::random())
->default($state = Str::random()),
])
@@ -175,10 +175,10 @@ test('child component state can be hydrated by parent component defaults', funct
Schema::make($livewire = Livewire::make())
->statePath('data')
->components([
(new Component())
(new Component)
->statePath($parentStatePath = Str::random())
->schema([
(new Component())
(new Component)
->statePath($statePath = Str::random()),
])
->default([$statePath => ($state = Str::random())]),
@@ -193,10 +193,10 @@ test('child component defaults are overwritten by parent component defaults', fu
Schema::make($livewire = Livewire::make())
->statePath('data')
->components([
(new Component())
(new Component)
->statePath($parentStatePath = Str::random())
->schema([
(new Component())
(new Component)
->statePath($statePath = Str::random())
->default(Str::random()),
])
@@ -212,10 +212,10 @@ test('missing child component state can be filled with null', function () {
Schema::make($livewire = Livewire::make())
->statePath('data')
->components([
(new Component())
(new Component)
->statePath($parentStatePath = Str::random())
->schema([
(new Component())->statePath($statePath = Str::random()),
(new Component)->statePath($statePath = Str::random()),
])
->afterStateHydrated(fn (Component $component) => $component->state([])),
])
@@ -229,10 +229,10 @@ test('missing hidden child component state can be filled with null', function ()
Schema::make($livewire = Livewire::make())
->statePath('data')
->components([
(new Component())
(new Component)
->hidden()
->schema([
(new Component())->statePath($statePath = Str::random()),
(new Component)->statePath($statePath = Str::random()),
]),
])
->fill();
@@ -245,7 +245,7 @@ test('custom logic can be executed after state is hydrated', function () {
Schema::make($livewire = Livewire::make())
->statePath('data')
->components([
(new Component())
(new Component)
->statePath($statePath = Str::random())
->afterStateHydrated(fn (Component $component, $state) => $component->state(strrev($state))),
])
@@ -259,7 +259,7 @@ test('custom logic can be executed after state is updated', function () {
Schema::make($livewire = Livewire::make())
->statePath('data')
->components([
(new Component())
(new Component)
->statePath($statePath = Str::random())
->afterStateUpdated(fn (Component $component, $state) => $component->state(strrev($state))),
])
@@ -274,7 +274,7 @@ test('custom logic can be executed after nested state is updated', function () {
Schema::make($livewire = Livewire::make())
->statePath('data')
->components([
(new Component())
(new Component)
->statePath($statePath = Str::random())
->afterStateUpdated(fn (Component $component, $state) => $component->state([strrev($state[0])])),
])
@@ -289,10 +289,10 @@ test('custom logic can be executed after child component state is updated', func
Schema::make($livewire = Livewire::make())
->statePath('data')
->components([
(new Component())
(new Component)
->statePath($statePath = Str::random())
->childComponents([
(new Component())
(new Component)
->statePath($childComponentStatePath = Str::random())
->afterStateUpdated(fn (Component $component, $state) => $component->state(strrev($state))),
]),
@@ -310,7 +310,7 @@ test('custom logic can be executed only once after nested state is updated', fun
Schema::make($livewire = Livewire::make())
->statePath('data')
->components([
(new Component())
(new Component)
->statePath($statePath = Str::random())
->afterStateUpdated(function () use (&$calls) {
$calls++;
@@ -326,7 +326,7 @@ test('custom logic can be executed more than once after nested state is updated
Schema::make($livewire = Livewire::make())
->statePath('data')
->components([
(new Component())
(new Component)
->statePath($statePath = Str::random())
->afterStateUpdated(fn (Component $component, $state) => $component->state([$state[0] + 1])),
])
@@ -342,10 +342,10 @@ test('custom logic on parent component can be executed after child component sta
Schema::make($livewire = Livewire::make())
->statePath('data')
->components([
(new Component())
(new Component)
->statePath($statePath = Str::random())
->childComponents([
(new Component())
(new Component)
->statePath($childComponentStatePath = Str::random()),
])
->afterStateUpdated(fn (Component $component, $state) => $component->state([
@@ -363,7 +363,7 @@ test('state can be dehydrated', function () {
$container = Schema::make(Livewire::make())
->statePath('data')
->components([
(new Component())
(new Component)
->statePath($statePath = Str::random())
->default($state = Str::random()),
])
@@ -379,7 +379,7 @@ test('state can be dehydrated using custom logic', function () {
$container = Schema::make(Livewire::make())
->statePath('data')
->components([
(new Component())
(new Component)
->statePath($statePath = Str::random())
->default($state = Str::random())
->dehydrateStateUsing(fn ($state) => strrev($state)),
@@ -396,7 +396,7 @@ test('custom logic can be executed before state is dehydrated', function () {
$container = Schema::make(Livewire::make())
->statePath('data')
->components([
(new Component())
(new Component)
->statePath($statePath = Str::random())
->default($state = Str::random())
->beforeStateDehydrated(fn (Component $component, $state) => $component->state(strrev($state))),
@@ -415,7 +415,7 @@ test('components can be excluded from state dehydration', function () {
$container = Schema::make(Livewire::make())
->statePath('data')
->components([
(new Component())
(new Component)
->statePath(Str::random())
->default(Str::random())
->dehydrated(false),
@@ -430,10 +430,10 @@ test('components can be excluded from state dehydration if their parent componen
$container = Schema::make(Livewire::make())
->statePath('data')
->components([
(new Component())
(new Component)
->dehydrated(false)
->schema([
(new Component())
(new Component)
->statePath(Str::random())
->default(Str::random()),
]),
@@ -448,7 +448,7 @@ test('hidden components are excluded from state dehydration', function () {
$container = Schema::make(Livewire::make())
->statePath('data')
->components([
(new Component())
(new Component)
->statePath(Str::random())
->default(Str::random())
->hidden(),
@@ -463,10 +463,10 @@ test('hidden components are excluded from state dehydration if their parent comp
$container = Schema::make(Livewire::make())
->statePath('data')
->components([
(new Component())
(new Component)
->hidden()
->schema([
(new Component())
(new Component)
->statePath(Str::random())
->default(Str::random()),
]),
@@ -481,7 +481,7 @@ test('hidden components are excluded from state dehydration except if they are m
$container = Schema::make(Livewire::make())
->statePath('data')
->components([
(new Component())
(new Component)
->statePath(Str::random())
->default(Str::random())
->hidden()
@@ -497,7 +497,7 @@ test('disabled components are excluded from state dehydration', function () {
$container = Schema::make(Livewire::make())
->statePath('data')
->components([
(new Component())
(new Component)
->statePath(Str::random())
->default(Str::random())
->disabled(),
@@ -512,10 +512,10 @@ test('disabled components are excluded from state dehydration if their parent co
$container = Schema::make(Livewire::make())
->statePath('data')
->components([
(new Component())
(new Component)
->disabled()
->schema([
(new Component())
(new Component)
->statePath(Str::random())
->default(Str::random()),
]),
@@ -530,7 +530,7 @@ test('disabled components are excluded from state dehydration except if they are
$container = Schema::make(Livewire::make())
->statePath('data')
->components([
(new Component())
(new Component)
->statePath(Str::random())
->default(Str::random())
->disabled()
@@ -546,10 +546,10 @@ test('disabled components are excluded from state dehydration if their parent co
$container = Schema::make(Livewire::make())
->statePath('data')
->components([
(new Component())
(new Component)
->disabled()
->schema([
(new Component())
(new Component)
->statePath(Str::random())
->default(Str::random())
->dehydrated(),
@@ -565,7 +565,7 @@ test('dehydrated state can be mutated', function () {
$container = Schema::make(Livewire::make())
->statePath('data')
->components([
(new Component())
(new Component)
->statePath($statePath = Str::random())
->default($state = Str::random())
->mutateDehydratedStateUsing(fn ($state) => strrev($state)),
@@ -584,7 +584,7 @@ test('sibling state can be retrieved relatively from another component', functio
Schema::make(Livewire::make())
->statePath('data')
->components([
(new Component())
(new Component)
->statePath($statePath = Str::random())
->default($state = Str::random()),
$placeholder = Placeholder::make(Str::random())
@@ -600,10 +600,10 @@ test('sibling nested state can be retrieved relatively from another component',
Schema::make(Livewire::make())
->statePath('data')
->components([
(new Component())
(new Component)
->statePath($parentStatePath = Str::random())
->schema([
(new Component())
(new Component)
->statePath($statePath = Str::random())
->default($state = Str::random()),
]),
@@ -620,10 +620,10 @@ test('parent sibling state can be retrieved relatively from another component',
Schema::make(Livewire::make())
->statePath('data')
->components([
(new Component())
(new Component)
->statePath($statePath = Str::random())
->default($state = Str::random()),
(new Component())
(new Component)
->statePath(Str::random())
->schema([
$placeholder = Placeholder::make(Str::random())
@@ -640,7 +640,7 @@ test('sibling state can be retrieved absolutely from another component', functio
Schema::make(Livewire::make())
->statePath('data')
->components([
(new Component())
(new Component)
->statePath($statePath = Str::random())
->default($state = Str::random()),
$placeholder = Placeholder::make(Str::random())
@@ -656,10 +656,10 @@ test('sibling nested state can be retrieved absolutely from another component',
Schema::make(Livewire::make())
->statePath('data')
->components([
(new Component())
(new Component)
->statePath($parentStatePath = Str::random())
->schema([
(new Component())
(new Component)
->statePath($statePath = Str::random())
->default($state = Str::random()),
]),
@@ -676,10 +676,10 @@ test('parent sibling state can be retrieved absolutely from another component',
Schema::make(Livewire::make())
->statePath('data')
->components([
(new Component())
(new Component)
->statePath($statePath = Str::random())
->default($state = Str::random()),
(new Component())
(new Component)
->statePath(Str::random())
->schema([
$placeholder = Placeholder::make(Str::random())
+1 -1
View File
@@ -174,7 +174,7 @@ it('can close notifications', function () {
function getLastNotificationAction()
{
$notificationsLivewireComponent = new Notifications();
$notificationsLivewireComponent = new Notifications;
$notificationsLivewireComponent->mount();
$notifications = $notificationsLivewireComponent->notifications;
+1 -1
View File
@@ -18,7 +18,7 @@ it('can log a user out', function () {
});
it('allows a user to override the logout response', function () {
$logoutResponseFake = new class() implements LogoutResponse
$logoutResponseFake = new class implements LogoutResponse
{
public function toResponse($request): RedirectResponse
{
@@ -0,0 +1,30 @@
<?php
namespace Filament\Tests\Panels\Fixtures\Resources\PostResource\Pages;
use Filament\Forms\Components\TextInput;
use Filament\Resources\Pages\Concerns\HasWizard;
use Filament\Resources\Pages\CreateRecord;
use Filament\Schema\Components\Wizard\Step;
use Filament\Tests\Panels\Fixtures\Resources\PostResource;
class CreatePostUsingWizard extends CreateRecord
{
use HasWizard;
protected static string $resource = PostResource::class;
public function getSteps(): array
{
return [
Step::make('Step 1')
->schema([
TextInput::make('title')->required(),
]),
Step::make('Step 2')
->schema([
TextInput::make('content')->required(),
]),
];
}
}
@@ -0,0 +1,42 @@
<?php
use Filament\Tests\Panels\Fixtures\Resources\PostResource\Pages\CreatePostUsingWizard;
use Filament\Tests\Panels\Resources\TestCase;
use function Filament\Tests\livewire;
uses(TestCase::class);
it('it validates the current wizard step when moving to the next wizard step', function () {
livewire(CreatePostUsingWizard::class)
->goToWizardStep(2)
->assertHasFormErrors(['title'])
->assertHasNoFormErrors(['content'])
->fillForm(['title' => 'Test title'])
->goToWizardStep(2)
->assertHasNoFormErrors();
});
it('it verifies what wizard step we are currently in', function () {
livewire(CreatePostUsingWizard::class)
->assertWizardCurrentStep(1)
->fillForm(['title' => 'Test title'])
->goToWizardStep(2)
->assertWizardCurrentStep(2);
});
it('it goes to the next wizard step', function () {
livewire(CreatePostUsingWizard::class)
->fillForm(['title' => 'Test title'])
->goToNextWizardStep()
->assertWizardCurrentStep(2);
});
it('it goes to the previous wizard step', function () {
livewire(CreatePostUsingWizard::class)
->fillForm(['title' => 'Test title'])
->goToNextWizardStep()
->assertWizardCurrentStep(2)
->goToPreviousWizardStep()
->assertWizardCurrentStep(1);
});