@@ -75,7 +75,35 @@ public function testUniqueEventsCanBeBroadcast()
7575 Bus::assertNotDispatched (UniqueBroadcastEvent::class);
7676 Queue::assertPushed (UniqueBroadcastEvent::class);
7777
78- $ lockKey = 'laravel_unique_job: ' .UniqueBroadcastEvent::class.': ' .TestEventUnique::class;
78+ $ lockKey = 'laravel_unique_job: ' .TestEventUnique::class.': ' ;
79+ $ this ->assertFalse ($ this ->app ->get (Cache::class)->lock ($ lockKey , 10 )->get ());
80+ }
81+
82+ public function testUniqueEventsCanBeBroadcastWithUniqueIdFromProperty ()
83+ {
84+ Bus::fake ();
85+ Queue::fake ();
86+
87+ Broadcast::queue (new TestEventUniqueWithIdProperty );
88+
89+ Bus::assertNotDispatched (UniqueBroadcastEvent::class);
90+ Queue::assertPushed (UniqueBroadcastEvent::class);
91+
92+ $ lockKey = 'laravel_unique_job: ' .TestEventUniqueWithIdProperty::class.':unique-id-property ' ;
93+ $ this ->assertFalse ($ this ->app ->get (Cache::class)->lock ($ lockKey , 10 )->get ());
94+ }
95+
96+ public function testUniqueEventsCanBeBroadcastWithUniqueIdFromMethod ()
97+ {
98+ Bus::fake ();
99+ Queue::fake ();
100+
101+ Broadcast::queue (new TestEventUniqueWithIdMethod );
102+
103+ Bus::assertNotDispatched (UniqueBroadcastEvent::class);
104+ Queue::assertPushed (UniqueBroadcastEvent::class);
105+
106+ $ lockKey = 'laravel_unique_job: ' .TestEventUniqueWithIdMethod::class.':unique-id-method ' ;
79107 $ this ->assertFalse ($ this ->app ->get (Cache::class)->lock ($ lockKey , 10 )->get ());
80108 }
81109
@@ -178,6 +206,16 @@ public function broadcastOn()
178206 }
179207}
180208
209+ class TestEventUniqueWithIdProperty extends TestEventUnique
210+ {
211+ public string $ uniqueId = 'unique-id-property ' ;
212+ }
213+
214+ class TestEventUniqueWithIdMethod extends TestEventUnique
215+ {
216+ public string $ uniqueId = 'unique-id-method ' ;
217+ }
218+
181219class TestEventRescue implements ShouldBroadcast, ShouldRescue
182220{
183221 /**
0 commit comments