© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•12mo ago
CodingBoi

[Test] itemLabel function from Repeater

I want to test that a custom itemLabel generator closure is working as expected, thus I'm creating a test for it.

class LineItemPieceIdGeneratorTest extends TestCase
{
    public function testLineItemPieceIdGenerator()
    {
        
        // Create a new ComponentContainer instance.
        $container = ComponentContainer::make();

        // Assign a schema of components to the container.
        $container->schema([
            Repeater::make('line_items')
                ->schema([
                    Repeater::make('pieces')
                        ->itemLabel(fn (ComponentContainer $container, $state) => LineItemPieceIdGenerator::make()->handle($container, $state))
                        ->schema([
                            TextInput::make('line_items.piece_id')
                        ])

                ])
        ]);
class LineItemPieceIdGeneratorTest extends TestCase
{
    public function testLineItemPieceIdGenerator()
    {
        
        // Create a new ComponentContainer instance.
        $container = ComponentContainer::make();

        // Assign a schema of components to the container.
        $container->schema([
            Repeater::make('line_items')
                ->schema([
                    Repeater::make('pieces')
                        ->itemLabel(fn (ComponentContainer $container, $state) => LineItemPieceIdGenerator::make()->handle($container, $state))
                        ->schema([
                            TextInput::make('line_items.piece_id')
                        ])

                ])
        ]);


in this case, the Container itself is rendered as "empty", and the "make" function wants a Livewire instance.
This is the first time I am trying to test something in Filament.
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Incremental itemLabel for repeater
FilamentFFilament / ❓┊help
2y ago
Custom itemLabel in Repeater
FilamentFFilament / ❓┊help
3y ago
ItemLabel Repeater Index In Input
FilamentFFilament / ❓┊help
3y ago
How to "$set" Repeater itemLabel()
FilamentFFilament / ❓┊help
3y ago