|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Traits\Styling; |
| 4 | + |
| 5 | +use PHPUnit\Framework\Attributes\Group; |
| 6 | +use Rappasoft\LaravelLivewireTables\Tests\TestCase; |
| 7 | +use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\PetsTable; |
| 8 | + |
| 9 | +#[Group('Filters')] |
| 10 | +final class FilterButtonStylingTest extends TestCase |
| 11 | +{ |
| 12 | + public function test_can_get_default_filter_button_attributes(): void |
| 13 | + { |
| 14 | + $this->assertSame(['default-styling' => true, 'default-colors' => true, 'class' => ''], $this->basicTable->getFilterButtonAttributes()); |
| 15 | + } |
| 16 | + |
| 17 | + public function test_can_get_default_filter_button_badge_attributes(): void |
| 18 | + { |
| 19 | + $this->assertSame(['default-styling' => true, 'default-colors' => true, 'class' => ''], $this->basicTable->getFilterButtonBadgeAttributes()); |
| 20 | + } |
| 21 | + |
| 22 | + public function test_can_change_default_filter_button_attributes(): void |
| 23 | + { |
| 24 | + $testTableDefault = new class extends PetsTable |
| 25 | + { |
| 26 | + public function configure(): void |
| 27 | + { |
| 28 | + parent::configure(); |
| 29 | + $this->useComputedPropertiesDisabled(); |
| 30 | + |
| 31 | + } |
| 32 | + |
| 33 | + public function publiclySetFilterButtonAttributes(array $attributes = []) |
| 34 | + { |
| 35 | + $this->setFilterButtonAttributes($attributes); |
| 36 | + } |
| 37 | + }; |
| 38 | + $this->assertSame(['default-styling' => true, 'default-colors' => true, 'class' => ''], $testTableDefault->getFilterButtonAttributes()); |
| 39 | + $testTableDefault->publiclySetFilterButtonAttributes(['class' => 'bg-blue-500']); |
| 40 | + $this->assertSame(['default-styling' => true, 'default-colors' => true, 'class' => 'bg-blue-500'], $testTableDefault->getFilterButtonAttributes()); |
| 41 | + $testTableDefault->publiclySetFilterButtonAttributes(['class' => 'bg-blue-500', 'default-colors' => false]); |
| 42 | + $this->assertSame(['default-styling' => true, 'default-colors' => false, 'class' => 'bg-blue-500'], $testTableDefault->getFilterButtonAttributes()); |
| 43 | + } |
| 44 | + |
| 45 | + public function test_can_change_default_filter_button_badge_attributes(): void |
| 46 | + { |
| 47 | + $testTableDefault = new class extends PetsTable |
| 48 | + { |
| 49 | + public function configure(): void |
| 50 | + { |
| 51 | + parent::configure(); |
| 52 | + $this->useComputedPropertiesDisabled(); |
| 53 | + |
| 54 | + } |
| 55 | + |
| 56 | + public function publiclySetFilterButtonBadgeAttributes(array $attributes = []) |
| 57 | + { |
| 58 | + $this->setFilterButtonBadgeAttributes($attributes); |
| 59 | + } |
| 60 | + }; |
| 61 | + $this->assertSame(['default-styling' => true, 'default-colors' => true, 'class' => ''], $testTableDefault->getFilterButtonBadgeAttributes()); |
| 62 | + $testTableDefault->publiclySetFilterButtonBadgeAttributes(['class' => 'bg-blue-500']); |
| 63 | + $this->assertSame(['default-styling' => true, 'default-colors' => true, 'class' => 'bg-blue-500'], $testTableDefault->getFilterButtonBadgeAttributes()); |
| 64 | + $testTableDefault->publiclySetFilterButtonBadgeAttributes(['class' => 'bg-blue-500', 'default-colors' => false]); |
| 65 | + $this->assertSame(['default-styling' => true, 'default-colors' => false, 'class' => 'bg-blue-500'], $testTableDefault->getFilterButtonBadgeAttributes()); |
| 66 | + } |
| 67 | +} |
0 commit comments