14
14
use Orchestra \Testbench \Attributes \WithConfig ;
15
15
16
16
#[WithConfig('horizon.silenced ' , ['App \\Jobs \\ConfigJob ' ])]
17
+ #[WithConfig('horizon.silenced_tags ' , ['notifications ' ])]
17
18
class MarkJobAsCompleteTest extends IntegrationTest
18
19
{
19
20
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
26
27
$ this ->runScenario ('App \\Jobs \\ConfigJob ' , true );
27
28
}
28
29
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
+
29
35
public function test_it_can_handle_silenced_jobs_from_an_interface (): void
30
36
{
31
37
$ this ->runScenario (SilencedJob::class, true );
@@ -36,11 +42,11 @@ public function test_it_can_handle_jobs_which_are_not_silenced(): void
36
42
$ this ->runScenario (NonSilencedJob::class, false );
37
43
}
38
44
39
- public function runScenario (string $ job , bool $ silenced ): void
45
+ public function runScenario (string $ job , bool $ silenced, array $ jobTags = [] ): void
40
46
{
41
47
$ payload = m::mock (JobPayload::class);
42
48
$ payload ->shouldReceive ('commandName ' )->andReturn ($ job );
43
- $ payload ->shouldReceive ('tags ' )->andReturn ([] );
49
+ $ payload ->shouldReceive ('tags ' )->andReturn ($ jobTags );
44
50
$ payload ->shouldReceive ('isSilenced ' )->andReturn ($ silenced );
45
51
46
52
$ job = m::mock (RedisJob::class);
@@ -54,7 +60,7 @@ public function runScenario(string $job, bool $silenced): void
54
60
$ jobs ->shouldReceive ('completed ' )->once ()->with ($ payload , false , $ silenced );
55
61
56
62
$ tags = m::mock (TagRepository::class);
57
- $ tags ->shouldReceive ('monitored ' )->once ()->with ([] )->andReturn ([]);
63
+ $ tags ->shouldReceive ('monitored ' )->once ()->with ($ jobTags )->andReturn ([]);
58
64
59
65
$ listener = new MarkJobAsComplete ($ jobs , $ tags );
60
66
0 commit comments