Skip to content

Commit 2d4d3f7

Browse files
committed
tests
1 parent b8f9b4a commit 2d4d3f7

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

tests/Bus/BusPendingDispatchWithAttributesTest.php renamed to tests/Integration/Bus/BusPendingDispatchWithAttributesTest.php

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

3-
namespace Illuminate\Tests\Bus;
3+
namespace Illuminate\Tests\Integration\Bus;
4+
45

56
use Illuminate\Bus\Queueable;
67
use Illuminate\Contracts\Queue\ShouldQueue;
@@ -65,6 +66,32 @@ public function testOverridingQueueAndConnectionDoesNotUseAttributeValues(): voi
6566
&& $job->value === 'abc';
6667
});
6768
}
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+
}
6895
}
6996

7097
#[OnQueue('queue-from-attribute')]
@@ -103,3 +130,22 @@ public function __construct(public $value)
103130
{
104131
}
105132
}
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

Comments
 (0)