added button component

This commit is contained in:
Pedro Cabral
2026-04-21 14:33:46 +02:00
parent 1b5d3f5bdf
commit 1bc3e5f885
5 changed files with 155 additions and 18 deletions

View File

@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
namespace Tests\Feature\Component;
use Tests\Feature\Component\DataProvider\ButtonTestDataProvider;
use Tests\TestCase;
class ButtonTest extends TestCase
{
public function testGeneratesButtonElement(): void
{
$view = $this->blade('<x-button>Click!</x-button>');
$view->assertSeeHtml('<button ');
$view->assertDontSeeHtml('<a ');
}
public function testButtonCanHaveAttributes(): void
{
$view = $this->blade('<x-button data-attr="123">Click!</x-button>');
$view->assertSeeHtml('data-attr="123"');
}
public function testDefaultVariantIsPrimary(): void
{
$view = $this->blade('<x-button>Click!</x-button>');
$view->assertSeeHtml('bg-primary text-text-inverted');
}
#[\PHPUnit\Framework\Attributes\DataProviderExternal(ButtonTestDataProvider::class, 'getDataForButtonTestWithButtons')]
public function testVariants(string $variant, string $expectedHtml): void
{
$button = sprintf('<x-button variant="%s">Click!</x-button>', $variant);
$view = $this->blade($button);
$view->assertSeeHtml($expectedHtml);
}
}