Skip to content

Commit

Permalink
Fix setting 'false' as filter
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasz-falda committed Jul 20, 2020
1 parent 1b70ca0 commit d9c3ab3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/LuigisBoxBundle/ValueObject/SearchUrlBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function addFilter(string $key, $value): self
if (\is_string($this->filters[$key])) {
$this->filters[$key] = [$this->filters[$key]];
}
$this->filters[$key][] = (string) $value;
$this->filters[$key][] = (string) (false === $value ? '0' : $value);

$this->filters[$key] = array_unique($this->filters[$key]);

Expand Down Expand Up @@ -167,7 +167,7 @@ public function addMustFilter(string $key, $value): self
if (\is_string($this->mustFilters[$key])) {
$this->mustFilters[$key] = [$this->mustFilters[$key]];
}
$this->mustFilters[$key][] = (string) $value;
$this->mustFilters[$key][] = (string) (false === $value ? '0' : $value);

$this->mustFilters[$key] = array_unique($this->mustFilters[$key]);

Expand Down
8 changes: 8 additions & 0 deletions tests/Unit/ValueObject/SearchUrlBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ public function buildValidUrlTest(): void
];
$this->assertOk($query, $searchBuilder);

$searchBuilder->addFilter('available', false);
$query['f[]'] = [
'category:Top & Top',
'category:Jeans',
'available:0',
];
$this->assertOk($query, $searchBuilder);

$searchBuilder->resetFilters();
$searchBuilder->setFilters(
[
Expand Down

0 comments on commit d9c3ab3

Please sign in to comment.