Comments (8)
@driesvints noted, thanks for the info. I'll settle for just mocking the call to driver()
that Horizon ends up calling, as so far that doesn't seem to have any negative repercussions.
from horizon.
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.
from horizon.
@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
from horizon.
@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 HorizonServiceProvider
?
from horizon.
@driesvints it doesn't, though that at least gives me some info on where to look. Commenting out that section and preventing registerCommands()
from running during boot()
does solve the issue, but obviously that can't be done unilaterally without breaking Horizon.
Your suggestion of using runningInConsole()
lead me to the runningUnitTests()
function of $this->app
, but regrettably that returns false
during the initialization of Horizon (despite returning true
while actually running the example test).
It does seem possible to work around the issue by adding an expectation that driver()
be called on the cache facade, but it's unclear if that could result in other issues if there's a scenario where Horizon doesn't end up calling that function.
from horizon.
Looking at this a little closer, within HorizonServiceProvider::registerCommands()
, changing
if ($this->app->runningInConsole()) {
to
if ($this->app->runningInConsole() && !$this->app->runningUnitTests()) {
Does resolve the issue. I was mistaken previously that runningUnitTests() returned false, that was for the standard ExampleTest Laravel ships with, but for my test feature test it does return true.
What I don't know is whether this could realistically be modified without breaking something else.
from horizon.
@rpungello let's try it: #1410
from horizon.
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.
from horizon.
Related Issues (20)
- BatchesController missing check for existence of batch HOT 2
- laravel horizon failed after change database password
- The horizon and queue methods must be consistent, so I suggest reading the same value HOT 1
- The horizon dashboard does not have stylesheet loaded HOT 6
- Subresource Integrity failures when using ASSET_URL HOT 3
- Uncaught SyntaxError: Unexpected token 'export' at app.js HOT 13
- Dashboard problems with a wrong absolute path HOT 2
- Graceful termination fails for workers marked for termination during job processing HOT 1
- Filter by Queue on recent jobs. HOT 3
- Failed to find a valid digest in the 'integrity' attribute for resource. After upgrading to Laravel 11 HOT 2
- Error: Subresource Integrity: The resource styles.css has an integrity attribute... HOT 2
- Dashboard opens blank page HOT 3
- open_basedir restricting horizon dashboard load page HOT 4
- If using sanctum how to authorization? HOT 1
- Undefined variable $assetsAreCurrent HOT 5
- is_file(): open_basedir restriction in effect. File(/vendor/horizon/nonExistentFile) is not within the allowed path(s): (/var/www:/var/lib/php/session:/tmp:/usr/bin) HOT 5
- laravel horizon on remove says HorizonApplicationServiceProvider not found HOT 1
- Ability to remove failed jobs from ui HOT 1
- How to throw the job into horizon HOT 1
- Feature Request: Warn the user if no supervisor configuration is present in the selected environment HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from horizon.