Skip to content

Commit e3eeabc

Browse files
authored
Add test queryStringWithQueryString
1 parent 3d279b9 commit e3eeabc

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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+
42+
public function test_check_querystring_returns_default_if_enabled(): void
43+
{
44+
45+
$testTableQueryString = new class extends PetsTable
46+
{
47+
public function configure(): void
48+
{
49+
parent::configure();
50+
$this->setQueryStringEnabled();
51+
}
52+
53+
public function getCurrentQueryStringBinding(): array
54+
{
55+
return $this->queryStringWithQueryString();
56+
}
57+
};
58+
59+
$testTableQueryString->mountManagesFilters();
60+
$testTableQueryString->configure();
61+
$testTableQueryString->boot();
62+
$testTableQueryString->bootedComponentUtilities();
63+
$testTableQueryString->bootedManagesFilters();
64+
$testTableQueryString->bootedWithColumns();
65+
$testTableQueryString->bootedWithColumnSelect();
66+
$testTableQueryString->bootedWithSecondaryHeader();
67+
$testTableQueryString->booted();
68+
69+
$this->assertSame(['table' => ['except' => null, 'history' => false, 'keep' => false, 'as' => 'table']], $testTableQueryString->getCurrentQueryStringBinding());
70+
71+
72+
}
73+
74+
75+
}

0 commit comments

Comments
 (0)