Skip to content

Commit 31561e5

Browse files
committed
ConfigurableArea Test Tidying
1 parent 74f6a5f commit 31561e5

File tree

4 files changed

+158
-84
lines changed

4 files changed

+158
-84
lines changed

tests/Unit/Traits/Configuration/ComponentConfigurationTest.php

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -294,26 +294,6 @@ public function test_can_set_tr_url_target_advanced(): void
294294
$this->assertSame($this->basicTable->getTableRowUrlTarget(2), 'navigate');
295295
}
296296

297-
public function test_can_set_hide_configurable_areas_when_reordering_status(): void
298-
{
299-
$this->assertTrue($this->basicTable->getHideConfigurableAreasWhenReorderingStatus());
300-
301-
$this->basicTable->setHideConfigurableAreasWhenReorderingStatus(false);
302-
303-
$this->assertFalse($this->basicTable->getHideConfigurableAreasWhenReorderingStatus());
304-
305-
$this->basicTable->setHideConfigurableAreasWhenReorderingStatus(true);
306-
307-
$this->assertTrue($this->basicTable->getHideConfigurableAreasWhenReorderingStatus());
308-
309-
$this->basicTable->setHideConfigurableAreasWhenReorderingDisabled();
310-
311-
$this->assertFalse($this->basicTable->getHideConfigurableAreasWhenReorderingStatus());
312-
313-
$this->basicTable->setHideConfigurableAreasWhenReorderingEnabled();
314-
315-
$this->basicTable->setHideConfigurableAreasWhenReorderingStatus(true);
316-
}
317297

318298
public function test_no_extra_withs_by_default(): void
319299
{

tests/Unit/Traits/Configuration/ConfigurableAreaConfigurationTest.php

Lines changed: 86 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,99 @@
22

33
namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Traits\Configuration;
44

5+
use PHPUnit\Framework\Attributes\DataProvider;
56
use Rappasoft\LaravelLivewireTables\Tests\TestCase;
67

78
final class ConfigurableAreaConfigurationTest extends TestCase
89
{
9-
public function test_can_set_configurable_area(): void
10+
11+
public static function configurableAreaProvider(): array
12+
{
13+
return [
14+
['before-tools', 'path.to.my.before-tools.view'],
15+
['toolbar-left-start', 'path.to.my.toolbar-left-start.view'],
16+
['toolbar-left-end', 'path.to.my.toolbar-left-end.view'],
17+
['toolbar-right-start', 'path.to.my.toolbar-right-start.view'],
18+
['toolbar-right-end', 'path.to.my.toolbar-right-end.view'],
19+
['before-toolbar', 'path.to.my.before-toolbar.view'],
20+
['after-toolbar', 'path.to.my.after-toolbar.view'],
21+
['after-tools', 'path.to.my.after-tools.view'],
22+
['before-pagination', 'path.to.my.before-pagination.view'],
23+
['after-pagination', 'path.to.my.after-pagination.view'],
24+
];
25+
}
26+
27+
#[DataProvider('configurableAreaProvider')]
28+
public function test_can_set_configurable_area(string $configurableArea, string $configurableAreaViewPath): void
29+
{
30+
$defaults = [
31+
'before-tools' => null,
32+
'toolbar-left-start' => null,
33+
'toolbar-left-end' => null,
34+
'toolbar-right-start' => null,
35+
'toolbar-right-end' => null,
36+
'before-toolbar' => null,
37+
'after-toolbar' => null,
38+
'after-tools' => null,
39+
'before-pagination' => null,
40+
'after-pagination' => null,
41+
];
42+
$this->basicTable->setConfigurableAreas($defaults);
43+
44+
$this->assertNull($this->basicTable->getConfigurableAreaFor($configurableArea));
45+
46+
$this->basicTable->setConfigurableArea($configurableArea, $configurableAreaViewPath);
47+
48+
$this->assertSame($configurableAreaViewPath, $this->basicTable->getConfigurableAreaFor($configurableArea));
49+
}
50+
51+
public function test_can_set_multiple_configurable_areas(): void
1052
{
53+
$defaults = [
54+
'before-tools' => null,
55+
'toolbar-left-start' => null,
56+
'toolbar-left-end' => null,
57+
'toolbar-right-start' => null,
58+
'toolbar-right-end' => null,
59+
'before-toolbar' => null,
60+
'after-toolbar' => null,
61+
'after-tools' => null,
62+
'before-pagination' => null,
63+
'after-pagination' => null,
64+
];
65+
$this->basicTable->setConfigurableAreas($defaults);
66+
1167
$this->assertNull($this->basicTable->getConfigurableAreaFor('before-tools'));
68+
$this->assertNull($this->basicTable->getConfigurableAreaFor('after-toolbar'));
69+
70+
$this->basicTable->setConfigurableArea('before-tools', 'path.to.before-tools.view');
71+
$this->assertSame('path.to.before-tools.view', $this->basicTable->getConfigurableAreaFor('before-tools'));
1272

13-
$this->basicTable->setConfigurableArea('before-tools', 'path.to.my.view');
73+
$this->basicTable->setConfigurableArea('after-toolbar', 'path.to.after-toolbar.view');
74+
$this->assertSame('path.to.after-toolbar.view', $this->basicTable->getConfigurableAreaFor('after-toolbar'));
75+
$this->assertSame('path.to.before-tools.view', $this->basicTable->getConfigurableAreaFor('before-tools'));
1476

15-
$this->assertSame('path.to.my.view', $this->basicTable->getConfigurableAreaFor('before-tools'));
1677
}
78+
79+
public function test_can_set_hide_configurable_areas_when_reordering_status(): void
80+
{
81+
$this->assertTrue($this->basicTable->getHideConfigurableAreasWhenReorderingStatus());
82+
83+
$this->basicTable->setHideConfigurableAreasWhenReorderingStatus(false);
84+
85+
$this->assertFalse($this->basicTable->getHideConfigurableAreasWhenReorderingStatus());
86+
87+
$this->basicTable->setHideConfigurableAreasWhenReorderingStatus(true);
88+
89+
$this->assertTrue($this->basicTable->getHideConfigurableAreasWhenReorderingStatus());
90+
91+
$this->basicTable->setHideConfigurableAreasWhenReorderingDisabled();
92+
93+
$this->assertFalse($this->basicTable->getHideConfigurableAreasWhenReorderingStatus());
94+
95+
$this->basicTable->setHideConfigurableAreasWhenReorderingEnabled();
96+
97+
$this->basicTable->setHideConfigurableAreasWhenReorderingStatus(true);
98+
}
99+
17100
}

tests/Unit/Traits/Helpers/ComponentHelpersTest.php

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -181,67 +181,6 @@ public function test_can_add_additional_selects_nonarray(): void
181181
$this->assertEquals(['name', 'updated_at'], $this->basicTable->getAdditionalSelects());
182182
}
183183

184-
public function test_can_get_configurable_areas(): void
185-
{
186-
$this->assertEquals([
187-
'before-tools' => null,
188-
'toolbar-left-start' => null,
189-
'toolbar-left-end' => null,
190-
'toolbar-right-start' => null,
191-
'toolbar-right-end' => null,
192-
'before-toolbar' => null,
193-
'after-toolbar' => null,
194-
'after-tools' => null,
195-
'before-pagination' => null,
196-
'after-pagination' => null,
197-
], $this->basicTable->getConfigurableAreas());
198-
199-
$this->basicTable->setConfigurableAreas([
200-
'toolbar-left-start' => 'includes.areas.toolbar-left-start',
201-
]);
202-
203-
$this->assertEquals('includes.areas.toolbar-left-start', $this->basicTable->getConfigurableAreaFor('toolbar-left-start'));
204-
205-
$this->basicTable->setConfigurableAreas([
206-
'toolbar-left-start' => ['includes.areas.toolbar-left-start', ['param1' => 'hello']],
207-
]);
208-
209-
$this->assertEquals('includes.areas.toolbar-left-start', $this->basicTable->getConfigurableAreaFor('toolbar-left-start'));
210-
}
211-
212-
public function test_can_get_configurable_area_parameters(): void
213-
{
214-
$this->basicTable->setConfigurableAreas([
215-
'toolbar-left-start' => 'includes.areas.toolbar-left-start',
216-
]);
217-
218-
$this->assertEquals([], $this->basicTable->getParametersForConfigurableArea('toolbar-left-start'));
219-
220-
$this->basicTable->setConfigurableAreas([
221-
'toolbar-left-start' => ['includes.areas.toolbar-left-start', ['param1' => 'hello']],
222-
]);
223-
224-
$this->assertEquals(['param1' => 'hello'], $this->basicTable->getParametersForConfigurableArea('toolbar-left-start'));
225-
}
226-
227-
public function test_can_get_hide_configurable_areas_when_reordering_status(): void
228-
{
229-
$this->assertTrue($this->basicTable->getHideConfigurableAreasWhenReorderingStatus());
230-
231-
$this->assertTrue($this->basicTable->hideConfigurableAreasWhenReorderingIsEnabled());
232-
233-
$this->basicTable->setHideConfigurableAreasWhenReorderingDisabled();
234-
235-
$this->assertTrue($this->basicTable->hideConfigurableAreasWhenReorderingIsDisabled());
236-
237-
$this->assertFalse($this->basicTable->hideConfigurableAreasWhenReorderingIsEnabled());
238-
239-
$this->basicTable->setHideConfigurableAreasWhenReorderingEnabled();
240-
241-
$this->assertTrue($this->basicTable->hideConfigurableAreasWhenReorderingIsEnabled());
242-
243-
$this->assertFalse($this->basicTable->hideConfigurableAreasWhenReorderingIsDisabled());
244-
}
245184

246185
// Exists in DataTableComponentTest
247186
// public function test_can_get_dataTable_fingerprint(): void
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
3+
namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Traits\Helpers;
4+
5+
use Rappasoft\LaravelLivewireTables\Tests\Models\Pet;
6+
use Rappasoft\LaravelLivewireTables\Tests\TestCase;
7+
8+
final class ConfigurableAreaHelpersTest extends TestCase
9+
{
10+
public function test_can_get_configurable_areas(): void
11+
{
12+
$this->assertEquals([
13+
'before-tools' => null,
14+
'toolbar-left-start' => null,
15+
'toolbar-left-end' => null,
16+
'toolbar-right-start' => null,
17+
'toolbar-right-end' => null,
18+
'before-toolbar' => null,
19+
'after-toolbar' => null,
20+
'after-tools' => null,
21+
'before-pagination' => null,
22+
'after-pagination' => null,
23+
], $this->basicTable->getConfigurableAreas());
24+
25+
$this->basicTable->setConfigurableAreas([
26+
'toolbar-left-start' => 'includes.areas.toolbar-left-start',
27+
]);
28+
29+
$this->assertEquals('includes.areas.toolbar-left-start', $this->basicTable->getConfigurableAreaFor('toolbar-left-start'));
30+
31+
$this->basicTable->setConfigurableAreas([
32+
'toolbar-left-start' => ['includes.areas.toolbar-left-start', ['param1' => 'hello']],
33+
]);
34+
35+
$this->assertEquals('includes.areas.toolbar-left-start', $this->basicTable->getConfigurableAreaFor('toolbar-left-start'));
36+
}
37+
38+
public function test_can_get_configurable_area_parameters(): void
39+
{
40+
$this->basicTable->setConfigurableAreas([
41+
'toolbar-left-start' => 'includes.areas.toolbar-left-start',
42+
]);
43+
44+
$this->assertEquals([], $this->basicTable->getParametersForConfigurableArea('toolbar-left-start'));
45+
46+
$this->basicTable->setConfigurableAreas([
47+
'toolbar-left-start' => ['includes.areas.toolbar-left-start', ['param1' => 'hello']],
48+
]);
49+
50+
$this->assertEquals(['param1' => 'hello'], $this->basicTable->getParametersForConfigurableArea('toolbar-left-start'));
51+
}
52+
53+
public function test_can_get_hide_configurable_areas_when_reordering_status(): void
54+
{
55+
$this->assertTrue($this->basicTable->getHideConfigurableAreasWhenReorderingStatus());
56+
57+
$this->assertTrue($this->basicTable->hideConfigurableAreasWhenReorderingIsEnabled());
58+
59+
$this->basicTable->setHideConfigurableAreasWhenReorderingDisabled();
60+
61+
$this->assertTrue($this->basicTable->hideConfigurableAreasWhenReorderingIsDisabled());
62+
63+
$this->assertFalse($this->basicTable->hideConfigurableAreasWhenReorderingIsEnabled());
64+
65+
$this->basicTable->setHideConfigurableAreasWhenReorderingEnabled();
66+
67+
$this->assertTrue($this->basicTable->hideConfigurableAreasWhenReorderingIsEnabled());
68+
69+
$this->assertFalse($this->basicTable->hideConfigurableAreasWhenReorderingIsDisabled());
70+
}
71+
72+
}

0 commit comments

Comments
 (0)