Skip to content

Commit

Permalink
Merge pull request #241 from peter-gribanov/expr_to_string
Browse files Browse the repository at this point in the history
MemberOfX::getFilter() and LogicX::getFilter() should return a string
  • Loading branch information
peter-gribanov authored Sep 4, 2020
2 parents d807520 + 3ba9c68 commit f08b3fd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/Filter/MemberOfX.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function getFilter(QueryBuilder $qb, $dqlAlias)
$field = ArgumentToOperandConverter::toField($this->field);
$value = ArgumentToOperandConverter::toValue($this->value);

return $qb->expr()->isMemberOf(
return (string) $qb->expr()->isMemberOf(
$value->transform($qb, $dqlAlias),
$field->transform($qb, $dqlAlias)
);
Expand Down
2 changes: 1 addition & 1 deletion src/Logic/LogicX.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function getFilter(QueryBuilder $qb, $dqlAlias)
);
}

return call_user_func_array($expression, $children);
return (string) call_user_func_array($expression, $children);
}

/**
Expand Down
13 changes: 4 additions & 9 deletions tests/Filter/MemberOfXSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,16 @@ public function it_is_an_expression()
$this->shouldBeAnInstanceOf(Filter::class);
}

public function it_returns_expression_func_object(
QueryBuilder $qb,
ArrayCollection $parameters,
Expr $exp,
Comparison $exp_comparison
) {
public function it_returns_expression_func_object(QueryBuilder $qb, ArrayCollection $parameters, Expr $exp)
{
$exp_comparison = new Comparison(':comparison_10', 'MEMBER OF', 'a.age');
$qb->expr()->willReturn($exp);
$qb->getParameters()->willReturn($parameters);
$parameters->count()->willReturn(10);

$qb->setParameter('comparison_10', 18, null)->shouldBeCalled();
$exp->isMemberOf(':comparison_10', 'a.age')->willReturn($exp_comparison);

$comparison = $this->getFilter($qb, null);

$comparison->shouldReturn($exp_comparison);
$this->getFilter($qb, null)->shouldReturn(':comparison_10 MEMBER OF a.age');
}
}

0 comments on commit f08b3fd

Please sign in to comment.