Skip to content

Commit

Permalink
PaginationVisuals - Utilise Class Inheritance for Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lrljoe committed Oct 1, 2024
1 parent 4bce413 commit ebf2e09
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 45 deletions.
46 changes: 46 additions & 0 deletions tests/Traits/Visuals/Themed/BasePaginationVisuals.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace Rappasoft\LaravelLivewireTables\Tests\Traits\Visuals\Themed;

use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;

abstract class BasePaginationVisuals extends ThemedTestCase
{
abstract protected function setupBasicTableForBrowsing();

abstract protected function setupBasicTableSingleRecord();

public function pagination_shows_by_default()
{
return $this->setupBasicTableForLivewire();
}

public function setupSingleRecordBasicTable()
{
return $this->setupBasicTableForLivewire()
->call('setPerPageAccepted', [1])
->call('setPerPage', 1);
}

public function tableWithStandardDetailedPagination()
{
return $this->setupBasicTableSingleRecord()
->call('enableDetailedPagination', 'standard');
}

public function tableWithSimpleDetailedPagination()
{
return $this->setupBasicTableSingleRecord()
->call('enableDetailedPagination', 'simple');
}

public function test_per_page_dropdown_only_renders_with_accepted_values(): void
{
$this->expectException(DataTableConfigurationException::class);

$this->setupBasicTableForBrowsing()
->call('setPerPage', 15);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@

namespace Rappasoft\LaravelLivewireTables\Tests\Traits\Visuals\Themed\Bootstrap4;

use Livewire\Livewire;
use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\{PetsTable};
use Rappasoft\LaravelLivewireTables\Tests\Traits\Visuals\Themed\ThemedTestCase;
use Rappasoft\LaravelLivewireTables\Tests\Traits\Visuals\Themed\BasePaginationVisuals;

final class BS4PaginationVisualsTest extends ThemedTestCase
final class BS4PaginationVisualsTest extends BasePaginationVisuals
{
protected function setupBasicTableForBrowsing()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@

namespace Rappasoft\LaravelLivewireTables\Tests\Traits\Visuals\Themed\Bootstrap5;

use Livewire\Livewire;
use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\{PetsTable};
use Rappasoft\LaravelLivewireTables\Tests\Traits\Visuals\Themed\ThemedTestCase;
use Rappasoft\LaravelLivewireTables\Tests\Traits\Visuals\Themed\BasePaginationVisuals;

final class BS5PaginationVisualsTest extends ThemedTestCase
final class BS5PaginationVisualsTest extends BasePaginationVisuals
{
protected function setupBasicTableForBrowsing()
{
Expand Down
15 changes: 2 additions & 13 deletions tests/Traits/Visuals/Themed/Tailwind/TWPaginationVisualsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@

namespace Rappasoft\LaravelLivewireTables\Tests\Traits\Visuals\Themed\Tailwind;

use Livewire\Livewire;
use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\{PetsTable};
use Rappasoft\LaravelLivewireTables\Tests\Traits\Visuals\Themed\ThemedTestCase;
use Rappasoft\LaravelLivewireTables\Tests\Traits\Visuals\Themed\BasePaginationVisuals;

final class TWPaginationVisualsTest extends ThemedTestCase
final class TWPaginationVisualsTest extends BasePaginationVisuals
{
protected function setupBasicTableForBrowsing()
{
Expand Down Expand Up @@ -130,14 +127,6 @@ public function test_total_results_label_doesnt_show_with_pagination_hidden(): v
]);
}*/

public function test_per_page_dropdown_only_renders_with_accepted_values(): void
{
$this->expectException(DataTableConfigurationException::class);

$this->setupBasicTableForBrowsing()
->call('setPerPage', 15);
}

public function test_can_get_currently_displayed_ids(): void
{
$this->setupBasicTableForBrowsing()
Expand Down
23 changes: 1 addition & 22 deletions tests/Traits/Visuals/Themed/ThemedTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@
use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\{PetsTable};
use Rappasoft\LaravelLivewireTables\Tests\TestCase;

abstract class ThemedTestCase extends TestCase
class ThemedTestCase extends TestCase
{
abstract protected function setupBasicTableForBrowsing();

abstract protected function setupBasicTableSingleRecord();

protected function setupBasicTableForLivewire()
{
Expand All @@ -23,22 +20,4 @@ public function pagination_shows_by_default()
return $this->setupBasicTableForLivewire();
}

public function setupSingleRecordBasicTable()
{
return $this->setupBasicTableForLivewire()
->call('setPerPageAccepted', [1])
->call('setPerPage', 1);
}

public function tableWithStandardDetailedPagination()
{
return $this->setupBasicTableSingleRecord()
->call('enableDetailedPagination', 'standard');
}

public function tableWithSimpleDetailedPagination()
{
return $this->setupBasicTableSingleRecord()
->call('enableDetailedPagination', 'simple');
}
}

0 comments on commit ebf2e09

Please sign in to comment.