|
7 | 7 | use Illuminate\Contracts\Queue\ShouldBeUnique;
|
8 | 8 | use Illuminate\Contracts\Queue\ShouldQueue;
|
9 | 9 | use Illuminate\Foundation\Bus\Dispatchable;
|
| 10 | +use Illuminate\Queue\Events\JobQueued; |
| 11 | +use Illuminate\Queue\Events\JobQueueing; |
10 | 12 | use Illuminate\Queue\InteractsWithQueue;
|
| 13 | +use Illuminate\Support\Facades\Config; |
11 | 14 | use Orchestra\Testbench\Attributes\WithMigration;
|
12 | 15 |
|
13 | 16 | #[WithMigration]
|
@@ -135,6 +138,33 @@ public function testUniqueJobLockIsReleasedForJobDispatchedAfterResponse()
|
135 | 138 | $this->assertFalse(UniqueJob::$ran);
|
136 | 139 | }
|
137 | 140 |
|
| 141 | + public function testQueueMayBeNullForJobQueueingAndJobQueuedEvent() |
| 142 | + { |
| 143 | + Config::set('queue.default', 'database'); |
| 144 | + $events = []; |
| 145 | + $this->app['events']->listen(function (JobQueueing $e) use (&$events) { |
| 146 | + $events[] = $e; |
| 147 | + }); |
| 148 | + $this->app['events']->listen(function (JobQueued $e) use (&$events) { |
| 149 | + $events[] = $e; |
| 150 | + }); |
| 151 | + |
| 152 | + MyTestDispatchableJob::dispatch(); |
| 153 | + dispatch(function () { |
| 154 | + // |
| 155 | + }); |
| 156 | + |
| 157 | + $this->assertCount(4, $events); |
| 158 | + $this->assertInstanceOf(JobQueueing::class, $events[0]); |
| 159 | + $this->assertNull($events[0]->queue); |
| 160 | + $this->assertInstanceOf(JobQueued::class, $events[1]); |
| 161 | + $this->assertNull($events[1]->queue); |
| 162 | + $this->assertInstanceOf(JobQueueing::class, $events[2]); |
| 163 | + $this->assertNull($events[2]->queue); |
| 164 | + $this->assertInstanceOf(JobQueued::class, $events[3]); |
| 165 | + $this->assertNull($events[3]->queue); |
| 166 | + } |
| 167 | + |
138 | 168 | /**
|
139 | 169 | * Helpers.
|
140 | 170 | */
|
@@ -178,3 +208,8 @@ public function uniqueId()
|
178 | 208 | return self::$value;
|
179 | 209 | }
|
180 | 210 | }
|
| 211 | + |
| 212 | +class MyTestDispatchableJob implements ShouldQueue |
| 213 | +{ |
| 214 | + use Dispatchable; |
| 215 | +} |
0 commit comments