diff --git a/src/Traits/Core/Component/HandlesComputedProperties.php b/src/Traits/Core/Component/HandlesComputedProperties.php index d278ecae8..6e335c70b 100644 --- a/src/Traits/Core/Component/HandlesComputedProperties.php +++ b/src/Traits/Core/Component/HandlesComputedProperties.php @@ -6,18 +6,21 @@ trait HandlesComputedProperties { protected bool $useComputedProperties = true; - public function useComputedPropertiesEnabled(): self + protected function setComputedPropertiesStatus(bool $useComputedProperties): self { - $this->useComputedProperties = true; + $this->useComputedProperties = $useComputedProperties; return $this; } - public function useComputedPropertiesDisabled(): self + public function useComputedPropertiesEnabled(): self { - $this->useComputedProperties = false; + return $this->setComputedPropertiesStatus(true); + } - return $this; + public function useComputedPropertiesDisabled(): self + { + return $this->setComputedPropertiesStatus(false); } public function getComputedPropertiesStatus(): bool diff --git a/tests/Unit/Traits/WithColumnsTest.php b/tests/Unit/Traits/WithColumnsTest.php new file mode 100644 index 000000000..c258f92cf --- /dev/null +++ b/tests/Unit/Traits/WithColumnsTest.php @@ -0,0 +1,43 @@ +useComputedPropertiesDisabled(); + + } + }; + + $view = view('livewire-tables::datatable'); + + $testTableDefault->boot(); + $testTableDefault->mountManagesFilters(); + $testTableDefault->bootedComponentUtilities(); + $testTableDefault->bootedManagesFilters(); + $testTableDefault->bootedWithColumns(); + $testTableDefault->bootedWithColumnSelect(); + $testTableDefault->bootedWithSecondaryHeader(); + $testTableDefault->booted(); + $testTableDefault->renderingWithColumns($view, $view->getData()); + $testTableDefault->renderingWithColumnSelect($view, $view->getData()); + $testTableDefault->renderingWithCustomisations($view, $view->getData()); + $testTableDefault->renderingWithData($view, $view->getData()); + $testTableDefault->renderingWithFooter($view, $view->getData()); + $testTableDefault->renderingWithReordering($view, $view->getData()); + $testTableDefault->renderingWithPagination($view, $view->getData()); + $testTableDefault->render(); + $this->assertSame(9, $view->getData()['columns']->count()); + } +}