Skip to content

Commit

Permalink
Merge pull request BitBagCommerce#36 from Codeweld/fix/bool-filters
Browse files Browse the repository at this point in the history
Allow to apply filters with bool values in Behat tests
  • Loading branch information
Codeweld authored Jan 7, 2022
2 parents 015cff5 + 2337d63 commit 1acf85c
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/Behat/Model/OperationRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,30 @@ private function formatFilters(): string
* @var mixed $filterValue
*/
foreach ($filters as $filterName => $filterValue) {
$filtersData .= sprintf(
"%s: %s,\n",
$filterName,
(string) $filterValue
);
$filtersData .= $this->formatFilter($filterName, $filterValue);
}

return sprintf('(
%s
)', $filtersData);
}

/** @param mixed $filterValue */
private function formatFilter(string $filterName, $filterValue): string
{
$processedValue = (string) $filterValue;

if (true === is_bool($filterValue)) {
$processedValue = $filterValue ? 'true' : 'false';
}

return sprintf(
"%s: %s,\n",
$filterName,
$processedValue
);
}

private function addFiltersToQuery(): void
{
$filters = $this->formatFilters();
Expand Down

0 comments on commit 1acf85c

Please sign in to comment.