Skip to content

Commit

Permalink
fix FilterSelect applying
Browse files Browse the repository at this point in the history
  • Loading branch information
nidjo17 authored and paveljanda committed Jun 6, 2022
1 parent e7b0ceb commit 359aedf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/DataSource/ArrayDataSource.php
Expand Up @@ -15,6 +15,7 @@
use Ublaboo\DataGrid\Filter\FilterDateRange;
use Ublaboo\DataGrid\Filter\FilterMultiSelect;
use Ublaboo\DataGrid\Filter\FilterRange;
use Ublaboo\DataGrid\Filter\FilterSelect;
use Ublaboo\DataGrid\Filter\FilterText;
use Ublaboo\DataGrid\Utils\DateTimeHelper;
use Ublaboo\DataGrid\Utils\Sorting;
Expand Down Expand Up @@ -196,6 +197,10 @@ protected function applyFilter($row, Filter $filter)
$value = (string) $value;
$rowVal = (string) $row[$column];

if ($filter instanceof FilterSelect) {
return $rowVal === $value;
}

if ($filter instanceof FilterText && $filter->isExactSearch()) {
return $rowVal === $value;
}
Expand Down
10 changes: 10 additions & 0 deletions tests/Cases/DataSources/BaseDataSourceTest.phpt
Expand Up @@ -188,6 +188,16 @@ abstract class BaseDataSourceTest extends TestCase
], $result);
}

public function testFilterSelect(): void
{
$filter = new Ublaboo\DataGrid\Filter\FilterSelect($this->grid, 'a', 'b', ['John Red' => 'John Red'], 'name');
$filter->setValue('John Red');

$this->ds->filter([$filter]);

Assert::equal([$this->data[5]], $this->getActualResultAsArray());
}


protected function getActualResultAsArray()
{
Expand Down

0 comments on commit 359aedf

Please sign in to comment.