Skip to content
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

Mock queue #28

Open
fklee opened this issue Nov 27, 2020 · 2 comments
Open

Mock queue #28

fklee opened this issue Nov 27, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@fklee
Copy link

fklee commented Nov 27, 2020

Hi,

I started to use your package which is extra to mock, and test mails ! Top. But now I would like to mock Laravel Queues and after doing this :
$queue = $browser->fake(Queue::class); [...] $queue->assertNotPushed(SynchrUser::class);
And I get this error :
Browser\UserActions ✘ Register │ │ Exception: Unable to retrieve mock for [Illuminate\Support\Facades\Queue]. │ │ /var/www/emploi2/vendor/noeldemartin/laravel-dusk-mocking/src/MockingProxy.php:50 │ /var/www/emploi2/tests/Browser/UserActionsTest.php:102 │ /var/www/emploi2/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:68 │ /var/www/emploi2/tests/Browser/UserActionsTest.php:114 │
I wondering if I was doing something wrong as Queue have all already a mock as mail ?
Sorry for this post, but now you could mention that queue fork would not be possible. I just found the error :
Serialization of 'Closure' is not allowed at .../noeldemartin/laravel-dusk-mocking/src/Driver.php:151)

Have you already have this issue. Is it possible to find a turnaround ?

@NoelDeMartin
Copy link
Owner

Hi there, thanks for opening an issue!

This is a known limitation, but I realize I only mentioned it in some comments and it wasn't documented. I've added a new section to the readme explaining those limitations. Make sure to check that out for some workarounds.

As per this issue in particular, it's very similar to #9 and #13. Those were also caused because some Laravel services use closures internally. I'll leave it open and add the "enhancement" label, but I don't expect to work on this anytime soon. Going down this path I'd end up reimplementing all Laravel fakes, and that's a rabbit hole I don't want to get myself into. If anyone wants to give it a shot and open a PR, go ahead!

@NoelDeMartin NoelDeMartin added the enhancement New feature or request label Nov 27, 2020
@fklee
Copy link
Author

fklee commented Nov 30, 2020

Hi,

Thanks for your complete answer. Do't know If I will have time to test other possibilities you mention, but thanks anyway for your hard work on this subject. For queues test, I can test them in the Database, not very usefull but I'am sure that I would find the data there :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants