|
2 | 2 |
|
3 | 3 | namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Traits\Configuration; |
4 | 4 |
|
| 5 | +use PHPUnit\Framework\Attributes\DataProvider; |
5 | 6 | use Rappasoft\LaravelLivewireTables\Tests\TestCase; |
6 | 7 |
|
7 | 8 | final class ConfigurableAreaConfigurationTest extends TestCase |
8 | 9 | { |
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 |
10 | 52 | { |
| 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 | + |
11 | 67 | $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')); |
12 | 72 |
|
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')); |
14 | 76 |
|
15 | | - $this->assertSame('path.to.my.view', $this->basicTable->getConfigurableAreaFor('before-tools')); |
16 | 77 | } |
| 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 | + |
17 | 100 | } |
0 commit comments