1414use Orchestra \Testbench \Attributes \WithConfig ;
1515
1616#[WithConfig('horizon.silenced ' , ['App \\Jobs \\ConfigJob ' ])]
17+ #[WithConfig('horizon.silenced_tags ' , ['notifications ' ])]
1718class MarkJobAsCompleteTest extends IntegrationTest
1819{
1920 public function test_it_can_mark_a_job_as_complete (): void
@@ -26,6 +27,11 @@ public function test_it_can_handle_silenced_jobs_from_the_config(): void
2627 $ this ->runScenario ('App \\Jobs \\ConfigJob ' , true );
2728 }
2829
30+ public function test_it_can_handle_silenced_jobs_from_tags (): void
31+ {
32+ $ this ->runScenario ('App \\Jobs \\TestJob ' , true , ['notifications ' , 'low_priority ' ]);
33+ }
34+
2935 public function test_it_can_handle_silenced_jobs_from_an_interface (): void
3036 {
3137 $ this ->runScenario (SilencedJob::class, true );
@@ -36,11 +42,11 @@ public function test_it_can_handle_jobs_which_are_not_silenced(): void
3642 $ this ->runScenario (NonSilencedJob::class, false );
3743 }
3844
39- public function runScenario (string $ job , bool $ silenced ): void
45+ public function runScenario (string $ job , bool $ silenced, array $ jobTags = [] ): void
4046 {
4147 $ payload = m::mock (JobPayload::class);
4248 $ payload ->shouldReceive ('commandName ' )->andReturn ($ job );
43- $ payload ->shouldReceive ('tags ' )->andReturn ([] );
49+ $ payload ->shouldReceive ('tags ' )->andReturn ($ jobTags );
4450 $ payload ->shouldReceive ('isSilenced ' )->andReturn ($ silenced );
4551
4652 $ job = m::mock (RedisJob::class);
@@ -54,7 +60,7 @@ public function runScenario(string $job, bool $silenced): void
5460 $ jobs ->shouldReceive ('completed ' )->once ()->with ($ payload , false , $ silenced );
5561
5662 $ tags = m::mock (TagRepository::class);
57- $ tags ->shouldReceive ('monitored ' )->once ()->with ([] )->andReturn ([]);
63+ $ tags ->shouldReceive ('monitored ' )->once ()->with ($ jobTags )->andReturn ([]);
5864
5965 $ listener = new MarkJobAsComplete ($ jobs , $ tags );
6066
0 commit comments