|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Traits\Helpers; |
| 4 | + |
| 5 | +use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\PetsTable; |
| 6 | +use Rappasoft\LaravelLivewireTables\Tests\TestCase; |
| 7 | + |
| 8 | +final class QueryStringHelpersTest extends TestCase |
| 9 | +{ |
| 10 | + public function test_check_querystring_returns_empty_if_disabled(): void |
| 11 | + { |
| 12 | + |
| 13 | + $testTableQueryString = new class extends PetsTable |
| 14 | + { |
| 15 | + public function configure(): void |
| 16 | + { |
| 17 | + parent::configure(); |
| 18 | + $this->setQueryStringDisabled(); |
| 19 | + } |
| 20 | + |
| 21 | + public function getCurrentQueryStringBinding(): array |
| 22 | + { |
| 23 | + return $this->queryStringWithQueryString(); |
| 24 | + } |
| 25 | + }; |
| 26 | + |
| 27 | + $testTableQueryString->mountManagesFilters(); |
| 28 | + $testTableQueryString->configure(); |
| 29 | + $testTableQueryString->boot(); |
| 30 | + $testTableQueryString->bootedComponentUtilities(); |
| 31 | + $testTableQueryString->bootedManagesFilters(); |
| 32 | + $testTableQueryString->bootedWithColumns(); |
| 33 | + $testTableQueryString->bootedWithColumnSelect(); |
| 34 | + $testTableQueryString->bootedWithSecondaryHeader(); |
| 35 | + $testTableQueryString->booted(); |
| 36 | + |
| 37 | + $this->assertSame([], $testTableQueryString->getCurrentQueryStringBinding()); |
| 38 | + |
| 39 | + } |
| 40 | + |
| 41 | + public function test_check_querystring_returns_default_if_enabled(): void |
| 42 | + { |
| 43 | + |
| 44 | + $testTableQueryString = new class extends PetsTable |
| 45 | + { |
| 46 | + public function configure(): void |
| 47 | + { |
| 48 | + parent::configure(); |
| 49 | + $this->setQueryStringEnabled(); |
| 50 | + } |
| 51 | + |
| 52 | + public function getCurrentQueryStringBinding(): array |
| 53 | + { |
| 54 | + return $this->queryStringWithQueryString(); |
| 55 | + } |
| 56 | + }; |
| 57 | + |
| 58 | + $testTableQueryString->mountManagesFilters(); |
| 59 | + $testTableQueryString->configure(); |
| 60 | + $testTableQueryString->boot(); |
| 61 | + $testTableQueryString->bootedComponentUtilities(); |
| 62 | + $testTableQueryString->bootedManagesFilters(); |
| 63 | + $testTableQueryString->bootedWithColumns(); |
| 64 | + $testTableQueryString->bootedWithColumnSelect(); |
| 65 | + $testTableQueryString->bootedWithSecondaryHeader(); |
| 66 | + $testTableQueryString->booted(); |
| 67 | + |
| 68 | + $this->assertSame(['table' => ['except' => null, 'history' => false, 'keep' => false, 'as' => 'table']], $testTableQueryString->getCurrentQueryStringBinding()); |
| 69 | + |
| 70 | + } |
| 71 | +} |
0 commit comments