Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/Traits/Core/Component/HandlesComputedProperties.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@
{
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

Check warning on line 16 in src/Traits/Core/Component/HandlesComputedProperties.php

View check run for this annotation

Codecov / codecov/patch

src/Traits/Core/Component/HandlesComputedProperties.php#L16

Added line #L16 was not covered by tests
{
$this->useComputedProperties = false;
return $this->setComputedPropertiesStatus(true);

Check warning on line 18 in src/Traits/Core/Component/HandlesComputedProperties.php

View check run for this annotation

Codecov / codecov/patch

src/Traits/Core/Component/HandlesComputedProperties.php#L18

Added line #L18 was not covered by tests
}

return $this;
public function useComputedPropertiesDisabled(): self
{
return $this->setComputedPropertiesStatus(false);
}

public function getComputedPropertiesStatus(): bool
Expand Down
43 changes: 43 additions & 0 deletions tests/Unit/Traits/WithColumnsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Traits;

use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\PetsTable;
use Rappasoft\LaravelLivewireTables\Tests\TestCase;

final class WithColumnsTest extends TestCase
{
public function test_rendering_with_columns_returns_columns(): void
{

$testTableDefault = new class extends PetsTable
{
public function configure(): void
{
parent::configure();
$this->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());
}
}
Loading