-
Notifications
You must be signed in to change notification settings - Fork 11.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[10.x] Add serializeAndRestore()
to QueueFake
andBusFake
#48131
[10.x] Add serializeAndRestore()
to QueueFake
andBusFake
#48131
Conversation
Can you add to Bus as well and mark as ready for review? |
serializeAndRestore()
to QueueFake
andBusFake
@taylorotwell Done. I know that you moved the logic out of the trait I had originally created. My two cents is that it would be a lot cleaner to leave it as a trait rather than duplicating the code in Also, not sure if we want to add this for EventFake as well? |
Some context
Queues are awesome. Jobs are awesome. Faking within tests is awesome.
But testing that a job is pushed is not always enough. Nor is testing the job's properties match expected values.
The normal process for jobs is that they are pushed to the queue where they are serialized and deserialized when they are run by a worker process. If there is an issue trying to serialize an object for your queue, it will fail... but probably not within your test suite 😟
Take for instance this job:
If we write a unit test like:
We see no problem in our test suite so it gets approved and merged... but then we release it into production and all of these jobs fail to serialize.
Instead, now we can write our tests to leverage
QueueFake@serializeAndRestoreJobs()
. This simulates the queuing process insofar that we will callserialize()
andunserialize()
on the job.Will gladly add a PR(s) for this to be added to EventFake and BusFake.