Skip to content

Commit a57de60

Browse files
authored
Add missing Columns Non Computed Test (rappasoft#2162)
* Add missing Columns Non Computed Test * Fix styling --------- Co-authored-by: lrljoe <[email protected]>
1 parent 2368708 commit a57de60

File tree

2 files changed

+51
-5
lines changed

2 files changed

+51
-5
lines changed

src/Traits/Core/Component/HandlesComputedProperties.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,21 @@ trait HandlesComputedProperties
66
{
77
protected bool $useComputedProperties = true;
88

9-
public function useComputedPropertiesEnabled(): self
9+
protected function setComputedPropertiesStatus(bool $useComputedProperties): self
1010
{
11-
$this->useComputedProperties = true;
11+
$this->useComputedProperties = $useComputedProperties;
1212

1313
return $this;
1414
}
1515

16-
public function useComputedPropertiesDisabled(): self
16+
public function useComputedPropertiesEnabled(): self
1717
{
18-
$this->useComputedProperties = false;
18+
return $this->setComputedPropertiesStatus(true);
19+
}
1920

20-
return $this;
21+
public function useComputedPropertiesDisabled(): self
22+
{
23+
return $this->setComputedPropertiesStatus(false);
2124
}
2225

2326
public function getComputedPropertiesStatus(): bool
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Traits;
4+
5+
use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\PetsTable;
6+
use Rappasoft\LaravelLivewireTables\Tests\TestCase;
7+
8+
final class WithColumnsTest extends TestCase
9+
{
10+
public function test_rendering_with_columns_returns_columns(): void
11+
{
12+
13+
$testTableDefault = new class extends PetsTable
14+
{
15+
public function configure(): void
16+
{
17+
parent::configure();
18+
$this->useComputedPropertiesDisabled();
19+
20+
}
21+
};
22+
23+
$view = view('livewire-tables::datatable');
24+
25+
$testTableDefault->boot();
26+
$testTableDefault->mountManagesFilters();
27+
$testTableDefault->bootedComponentUtilities();
28+
$testTableDefault->bootedManagesFilters();
29+
$testTableDefault->bootedWithColumns();
30+
$testTableDefault->bootedWithColumnSelect();
31+
$testTableDefault->bootedWithSecondaryHeader();
32+
$testTableDefault->booted();
33+
$testTableDefault->renderingWithColumns($view, $view->getData());
34+
$testTableDefault->renderingWithColumnSelect($view, $view->getData());
35+
$testTableDefault->renderingWithCustomisations($view, $view->getData());
36+
$testTableDefault->renderingWithData($view, $view->getData());
37+
$testTableDefault->renderingWithFooter($view, $view->getData());
38+
$testTableDefault->renderingWithReordering($view, $view->getData());
39+
$testTableDefault->renderingWithPagination($view, $view->getData());
40+
$testTableDefault->render();
41+
$this->assertSame(9, $view->getData()['columns']->count());
42+
}
43+
}

0 commit comments

Comments
 (0)