|
1 | 1 | <?php
|
2 | 2 |
|
3 |
| -namespace Illuminate\Tests\Bus; |
| 3 | +namespace Illuminate\Tests\Integration\Bus; |
| 4 | + |
4 | 5 |
|
5 | 6 | use Illuminate\Bus\Queueable;
|
6 | 7 | use Illuminate\Contracts\Queue\ShouldQueue;
|
@@ -65,6 +66,32 @@ public function testOverridingQueueAndConnectionDoesNotUseAttributeValues(): voi
|
65 | 66 | && $job->value === 'abc';
|
66 | 67 | });
|
67 | 68 | }
|
| 69 | + |
| 70 | + public function testAllowsEnumsInAttributes(): void |
| 71 | + { |
| 72 | + Queue::fake(); |
| 73 | + |
| 74 | + FakeJobWithAttributesUsingEnums::dispatch(1234); |
| 75 | + |
| 76 | + Queue::assertPushed( |
| 77 | + fn (FakeJobWithAttributesUsingEnums $job) => $job->queue === 'my-value' |
| 78 | + && $job->connection == 'other-value' |
| 79 | + && $job->value === 1234 |
| 80 | + ); |
| 81 | + } |
| 82 | + |
| 83 | + public function testWorksWithDispatchFunction(): void |
| 84 | + { |
| 85 | + Queue::fake(); |
| 86 | + |
| 87 | + dispatch(new FakeJobWithAttributesUsingEnums('laravel'))->onConnection('zzz'); |
| 88 | + |
| 89 | + Queue::assertPushed( |
| 90 | + fn (FakeJobWithAttributesUsingEnums $job) => $job->queue === 'my-value' |
| 91 | + && $job->connection == 'zzz' |
| 92 | + && $job->value === 'laravel' |
| 93 | + ); |
| 94 | + } |
68 | 95 | }
|
69 | 96 |
|
70 | 97 | #[OnQueue('queue-from-attribute')]
|
@@ -103,3 +130,22 @@ public function __construct(public $value)
|
103 | 130 | {
|
104 | 131 | }
|
105 | 132 | }
|
| 133 | + |
| 134 | +#[OnQueue(PendingDispatchWithAttributesEnum::MyValue)] |
| 135 | +#[OnConnection(PendingDispatchWithAttributesEnum::OtherValue)] |
| 136 | +class FakeJobWithAttributesUsingEnums implements ShouldQueue |
| 137 | +{ |
| 138 | + use Dispatchable; |
| 139 | + use Queueable; |
| 140 | + use InteractsWithQueue; |
| 141 | + |
| 142 | + public function __construct(public $value) |
| 143 | + { |
| 144 | + } |
| 145 | +} |
| 146 | + |
| 147 | +enum PendingDispatchWithAttributesEnum: string |
| 148 | +{ |
| 149 | + case MyValue = 'my-value'; |
| 150 | + case OtherValue = 'other-value'; |
| 151 | +} |
0 commit comments