Skip to content
Merged
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
71 changes: 71 additions & 0 deletions tests/Unit/Traits/Helpers/QueryStringHelpersTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Traits\Helpers;

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

final class QueryStringHelpersTest extends TestCase
{
public function test_check_querystring_returns_empty_if_disabled(): void
{

$testTableQueryString = new class extends PetsTable
{
public function configure(): void
{
parent::configure();
$this->setQueryStringDisabled();
}

public function getCurrentQueryStringBinding(): array
{
return $this->queryStringWithQueryString();
}
};

$testTableQueryString->mountManagesFilters();
$testTableQueryString->configure();
$testTableQueryString->boot();
$testTableQueryString->bootedComponentUtilities();
$testTableQueryString->bootedManagesFilters();
$testTableQueryString->bootedWithColumns();
$testTableQueryString->bootedWithColumnSelect();
$testTableQueryString->bootedWithSecondaryHeader();
$testTableQueryString->booted();

$this->assertSame([], $testTableQueryString->getCurrentQueryStringBinding());

}

public function test_check_querystring_returns_default_if_enabled(): void
{

$testTableQueryString = new class extends PetsTable
{
public function configure(): void
{
parent::configure();
$this->setQueryStringEnabled();
}

public function getCurrentQueryStringBinding(): array
{
return $this->queryStringWithQueryString();
}
};

$testTableQueryString->mountManagesFilters();
$testTableQueryString->configure();
$testTableQueryString->boot();
$testTableQueryString->bootedComponentUtilities();
$testTableQueryString->bootedManagesFilters();
$testTableQueryString->bootedWithColumns();
$testTableQueryString->bootedWithColumnSelect();
$testTableQueryString->bootedWithSecondaryHeader();
$testTableQueryString->booted();

$this->assertSame(['table' => ['except' => null, 'history' => false, 'keep' => false, 'as' => 'table']], $testTableQueryString->getCurrentQueryStringBinding());

}
}
Loading