You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The parameters for the add function can be \Illuminate\Support\Enumerable|object|array. My guess is that I can add new Jobs directly in there because they are objects and are wrapped with the Collection::wrap helper. Now I want to test my code with the withFakeBatch method on the batchable job class. In the documentation it is called that the second member of the tuple is the batch and with $batch->added I get a list of all the jobs added. So I wrote my test like this:
Laravel Version
10.14.0
PHP Version
8.2.4
Database Driver & Version
MySQL 8.0.32
Description
Hello,
I tried to test out batches for my application to add jobs dynamic. This is an abstraction for my handle code in a batchable job:
The parameters for the add function can be
\Illuminate\Support\Enumerable|object|array
. My guess is that I can add new Jobs directly in there because they are objects and are wrapped with theCollection::wrap
helper. Now I want to test my code with thewithFakeBatch
method on the batchable job class. In the documentation it is called that the second member of the tuple is the batch and with$batch->added
I get a list of all the jobs added. So I wrote my test like this:The tests throws an error that the
count($batch->added)
is not 2.After searching for the issue I found the overwritten add method in the BatchFake Class:
In my opinion the method is missing the line
With this line of code the object is safe to use again and it is more like the "real" add method in the Batch class.
If something is not clear enough I would love to provide more information.
Thanks for the great tool and have a nice day!
Steps To Reproduce
In this repository there is a Test failing with the scenario described above.
https://github.com/schonhoff/bug-with-fake-batch
The text was updated successfully, but these errors were encountered: