-
Notifications
You must be signed in to change notification settings - Fork 660
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
Having Horizon installed is breaking some tests #1406
Comments
You're doing cache faking here: https://github.com/rpungello/laravel-test/blob/master/tests/Feature/ExampleTest.php#L16-L19 This doesn't work when installing Horizon because it needs to resolve the cache driver upon initialisation through its service provider. Since you only added one expectation to the cache faking, this fails. |
@driesvints is this documented somewhere? I followed the official Laravel docs for mocking facades, which explicitly show the method for mocking the Cache facade I used: https://laravel.com/docs/11.x/mocking#mocking-facades |
@rpungello I want to check something real quickly with you. Does it work if you replace: $this->app->bind(Console\WorkCommand::class, function ($app) {
return new Console\WorkCommand($app['queue.worker'], $app['cache.store']);
}); With if ($this->app->runningInConsole()) {
$this->app->bind(Console\WorkCommand::class, function ($app) {
return new Console\WorkCommand($app['queue.worker'], $app['cache.store']);
});
} In the |
@driesvints it doesn't, though that at least gives me some info on where to look. Commenting out that section and preventing Your suggestion of using It does seem possible to work around the issue by adding an expectation that |
Looking at this a little closer, within What I don't know is whether this could realistically be modified without breaking something else. |
@rpungello let's try it: #1410 |
Unfortunately it doesn't seems possible since we need some of these commands themselves in our own test suite. I'm sorry @rpungello but it seems these two just aren't compatible right now. |
@driesvints noted, thanks for the info. I'll settle for just mocking the call to |
Horizon Version
5.23.2
Laravel Version
11.1.1
PHP Version
8.3.4
Redis Driver
PhpRedis
Redis Version
6.0.2
Database Driver & Version
No response
Description
I have an application I've added Laravel Horizon to. After doing so, one of our tests started mysteriously failing.
I was able to reproduce the issue in a dummy repository (linked in steps to reproduce).
Steps To Reproduce
See: https://github.com/rpungello/laravel-test
On the master branch, running the tests via
sail test
produces the following error: "Received Mockery_0_Illuminate_Cache_CacheManager::driver(), but no expectations were specified"Switching to HEAD~1 (without Horizon) and re-running
composer install
, and the error goes away (sail test
runs successfully). The only difference between these two commits is the addition of Horizon to composer.json. Thehorizon:install
command wasn't even run.The text was updated successfully, but these errors were encountered: