[Fail Case] Add test for aggregator transforms #162
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@nunomaduro this is the failing test for #158
You'll note that we've setup an extended "Thread" model where the toSearchableArray method specifies to only use the date transform.
The
testTransformsAreRespectedOnSingleModel
passes, I've only added it to ensure this is tested in the future.The
testModelTransformsAreRespectedOnAggregators
test then fails, as while the following check passes on the single model, it fails on the aggregate as the'100'
has been cast to100
.The test can be made to pass by adding the following function to our
ThreadAggregatorUsingOnlyDateTransform
class as this causes the check at https://github.com/algolia/scout-extended/blob/master/src/Jobs/UpdateJob.php#L113 to pass and as such we don't call the default transformers again, however I feel a better fix would be an update in thehasToSearchableArray method on
UpdateJobs`.P.S. sorry about the non-matching code style. I just quickly wrote this up to make the point clear.