sakanjo/filament-easy-testings

Filament plugin to make testing easier

v1.0.0 2025-01-21 06:25 UTC

This package is auto-updated.

Last update: 2025-01-21 06:28:12 UTC


README

Preview

Workflow status Laravel v11.x PHP 8.2

A Filament plugin to make testing easier.

✨ Help support the maintenance of this package by sponsoring me.

Table of Contents

đŸ“Ļ Install

Install the package via composer:

composer require sakanjo/filament-easy-testings

đŸĻ„ Usage

<?php

// ...
use SaKanjo\FilamentEasyTestings\EasyTestingPlugin;
use App\Filament\EasyTestings\Presets\MyPreset;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugin(
            EasyTestingPlugin::make()
                ->preset(MyPreset::make())
        );
}

Presets

Presets are the core of the plugin, allows you to create different tests with no limit.

Default presets

The package comes with a default preset that you can use out of the box.

  • DefaultPreset
  • EnvPreset
  • WebsocketPreset

Creating custom preset

You can create your own custom preset by extending the SaKanjo\FilamentEasyTestings\Presets\Preset class.

<?php

namespace App\Filament\EasyTestings;

use Filament\Forms;
use Filament\Notifications\Notification;
use SaKanjo\FilamentEasyTestings\Pages\TestingsPage;
use SaKanjo\FilamentEasyTestings\Presets\Preset;

class HelloPreset extends Preset
{
    public static function schema(): array
    {
        return [
            Forms\Components\Section::make('Say hi')
                ->persistCollapsed()
                ->icon('heroicon-m-bolt')
                ->schema([
                    Forms\Components\TextInput::make('name')
                        ->label('Name')
                        ->required(),

                    Forms\Components\Actions::make([
                        Forms\Components\Actions\Action::make('submit')
                            ->action(function (Forms\Get $get, TestingsPage $livewire): void {
                                $livewire->validateFields(['name']);
                                $name = $get('name');

                                Notification::make()
                                    ->title("Hello $name")
                                    ->send();
                            }),
                    ]),
                ]),
        ];
    }
}

💖 Support the development

Do you like this project? Support it by donating

Click the "💖 Sponsor" at the top of this repo.

Šī¸ Credits

📄 License

MIT License Š 2023-PRESENT Salah Kanjo