Skip to content

Commit

Permalink
TASK: Fix boolean behaviour for SearchTermMatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Aug 15, 2024
1 parent 5a8ab49 commit 5bce349
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Neos\ContentRepository\Core\Projection\ContentGraph\Filter\SearchTerm;

use Neos\ContentRepository\Core\Feature\NodeModification\Dto\SerializedPropertyValue;
use Neos\ContentRepository\Core\Feature\NodeModification\Dto\SerializedPropertyValues;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;

Expand Down Expand Up @@ -43,11 +42,11 @@ private static function matchesValue(mixed $value, SearchTerm $searchTerm): bool

return match (true) {
is_string($value) => mb_stripos($value, $searchTerm->term) !== false,
// the following behaviour might seem odd, but is implemented after how the database filtering should behave
// the following behaviour might seem odd, but is implemented after how the doctrine adapter filtering is currently implemented
is_int($value),
is_float($value) => str_contains((string)$value, $searchTerm->term),
$value === true => $searchTerm->term === 'true',
$value === false => $searchTerm->term === 'false',
$value === true => str_contains('true', $searchTerm->term),
$value === false => str_contains('false', $searchTerm->term),
default => throw new \InvalidArgumentException(sprintf('Handling for type %s is not implemented.', get_debug_type($value))),
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ public static function matchingBooleanLikeComparisonExamples(): iterable
'false',
self::value(false),
];

yield 'string part matches boolean' => [
'ru',
self::value(true),
];
}

public static function matchingArrayComparisonExamples(): iterable
Expand Down

0 comments on commit 5bce349

Please sign in to comment.