Skip to content

Commit

Permalink
Merge pull request #25 from answear/dev
Browse files Browse the repository at this point in the history
Fix setting 'false' as filter
  • Loading branch information
lukasz-falda authored Jul 21, 2020
2 parents 1b70ca0 + d9c3ab3 commit 1beb6fe
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 1beb6fe

Please sign in to comment.