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
4 changes: 0 additions & 4 deletions src/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,13 @@ public function __construct(
* Perform actual filtering. You need to pass an identifying name.
* You'll get an array with name of fields as keys and the filtered values
* as values (except for "_sort" key, which holds info for sorting).
* You need to call saveFilter() before calling this method.
*
* @return array<string, mixed>
*/
public function filter(string $name): array
{
$filter = [];
$fname = $name.$this->getSession()->getId();
if (!isset($this->forms[$fname])) {
throw new \UnexpectedValueException(\sprintf('No filter found for "%s". Did you call saveFilter()?', $name));
}
/** @var array<string, mixed>|null $values */
$values = $this->getSession()->get('filter.'.$name);
if (null !== $values) {
Expand Down
7 changes: 0 additions & 7 deletions tests/FilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ protected function setUp(): void
$this->filter = new Filter($this->factory, $stack);
}

public function testFilterWithoutSaveFilterShouldThrowException(): void
{
$this->expectException(\UnexpectedValueException::class);
$this->filter->filter('foo');
}

public function testFilter(): void
{
$this->filter->saveFilter(StubFormType::class, 'foo');
Expand Down Expand Up @@ -79,7 +73,6 @@ public function testFormViewWithoutPreviousForm(): void
public function testSort(): void
{
$this->filter->sort('foo', 'bar');
$this->filter->saveFilter(StubFormType::class, 'foo');
$filter = $this->filter->filter('foo');
self::assertArrayHasKey('_sort', $filter);
}
Expand Down