|
3 | 3 | namespace Rappasoft\LaravelLivewireTables\Tests;
|
4 | 4 |
|
5 | 5 | use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
| 6 | +use Illuminate\Encryption\Encrypter; |
6 | 7 | use Illuminate\Support\Collection;
|
| 8 | +use Illuminate\Support\Facades\Hash; |
| 9 | +use Illuminate\View\View; |
| 10 | +use Livewire\Livewire; |
7 | 11 | use Rappasoft\LaravelLivewireTables\DataTableComponent;
|
8 | 12 | use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\PetsAltQueryTable;
|
9 | 13 | use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\PetsTable;
|
@@ -115,6 +119,42 @@ public function search_filter_alt_query_relation()
|
115 | 119 | $this->assertEquals(2, $this->tableAltQuery->rows->total());
|
116 | 120 | }
|
117 | 121 |
|
| 122 | + /** @test */ |
| 123 | + public function custom_filter() |
| 124 | + { |
| 125 | + $this->table->filters['species.name'] = 1; |
| 126 | + |
| 127 | + $this->assertTrue($this->table->getRowsProperty()->where('name', 'Cartman')->isNotEmpty()); |
| 128 | + $this->assertTrue($this->table->getRowsProperty()->where('name', 'Tux')->isNotEmpty()); |
| 129 | + $this->assertFalse($this->table->getRowsProperty()->where('May', 'Tux')->isNotEmpty()); |
| 130 | + $this->assertFalse($this->table->getRowsProperty()->where('Ben', 'Tux')->isNotEmpty()); |
| 131 | + $this->assertFalse($this->table->getRowsProperty()->where('Chico', 'Tux')->isNotEmpty()); |
| 132 | + } |
| 133 | + |
| 134 | + /** @test */ |
| 135 | + public function custom_filters_pills_label_use_column_name_when_possible() |
| 136 | + { |
| 137 | + config()->set('app.key', Encrypter::generateKey(config('app.cipher'))); |
| 138 | + |
| 139 | + Livewire::test(PetsTable::class) |
| 140 | + ->set('filters', [ |
| 141 | + 'species.name' => 1, |
| 142 | + ]) |
| 143 | + ->assertSeeTextInOrder(['Applied Filters:', 'Species:', 'Cat', 'Filters']); |
| 144 | + } |
| 145 | + |
| 146 | + /** @test */ |
| 147 | + public function custom_filters_pills_label_use_filter_name_when_is_not_bound_to_a_column() |
| 148 | + { |
| 149 | + config()->set('app.key', Encrypter::generateKey(config('app.cipher'))); |
| 150 | + |
| 151 | + Livewire::test(PetsTable::class) |
| 152 | + ->set('filters', [ |
| 153 | + 'breed_id' => 1 |
| 154 | + ]) |
| 155 | + ->assertSeeTextInOrder(['Applied Filters:', 'Filter Breed:', 'American Shorthair', 'Filters']); |
| 156 | + } |
| 157 | + |
118 | 158 | /** @test */
|
119 | 159 | public function bulk_actions_defined_through_function()
|
120 | 160 | {
|
|
0 commit comments