Skip to content

Commit 682797d

Browse files
committed
[12.x] setUpRedis in QueueTestCase
1 parent c0af0ea commit 682797d

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

tests/Integration/Queue/QueueTestCase.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
namespace Illuminate\Tests\Integration\Queue;
44

5+
use Illuminate\Foundation\Testing\Concerns\InteractsWithRedis;
56
use Illuminate\Foundation\Testing\DatabaseMigrations;
67
use Orchestra\Testbench\TestCase;
78

89
abstract class QueueTestCase extends TestCase
910
{
10-
use DatabaseMigrations;
11+
use DatabaseMigrations, InteractsWithRedis;
1112

1213
/**
1314
* The current database driver.
@@ -27,6 +28,24 @@ protected function defineEnvironment($app)
2728
$this->driver = $app['config']->get('queue.default', 'sync');
2829
}
2930

31+
#[\Override]
32+
protected function setUp(): void
33+
{
34+
$this->afterApplicationCreated(function () {
35+
if ($this->getQueueDriver() === 'redis') {
36+
$this->setUpRedis();
37+
}
38+
});
39+
40+
$this->beforeApplicationDestroyed(function () {
41+
if ($this->getQueueDriver() === 'redis') {
42+
$this->tearDownRedis();
43+
}
44+
});
45+
46+
parent::setUp();
47+
}
48+
3049
/**
3150
* Run queue worker command.
3251
*

0 commit comments

Comments
 (0)