@@ -78,33 +78,31 @@ public function after_max_attempts_it_will_log_to_failed_table()
78
78
}
79
79
80
80
#[Test]
81
- public function after_max_attempts_it_will_delete_the_task ()
81
+ public function after_max_attempts_it_will_no_longer_execute_the_task ()
82
82
{
83
83
// Arrange
84
+ Event::fake ([JobOutput::class]);
84
85
$ job = $ this ->dispatch (new FailingJob ());
85
86
86
87
// Act & Assert
87
88
$ releasedJob = $ job ->runAndGetReleasedJob ();
88
- CloudTasksApi::assertDeletedTaskCount (1 );
89
- CloudTasksApi::assertTaskDeleted ($ job ->task ->getName ());
89
+ Event::assertDispatched (JobOutput::class, 1 );
90
90
$ this ->assertDatabaseCount ('failed_jobs ' , 0 );
91
91
92
92
$ releasedJob = $ releasedJob ->runAndGetReleasedJob ();
93
- CloudTasksApi::assertDeletedTaskCount (2 );
94
- CloudTasksApi::assertTaskDeleted ($ job ->task ->getName ());
93
+ Event::assertDispatched (JobOutput::class, 2 );
95
94
$ this ->assertDatabaseCount ('failed_jobs ' , 0 );
96
95
97
96
$ releasedJob ->run ();
98
- CloudTasksApi::assertDeletedTaskCount (3 );
99
- CloudTasksApi::assertTaskDeleted ($ job ->task ->getName ());
97
+ Event::assertDispatched (JobOutput::class, 4 );
100
98
$ this ->assertDatabaseCount ('failed_jobs ' , 1 );
101
99
}
102
100
103
101
#[Test]
104
102
#[TestWith([['now ' => '2020-01-01 00:00:00 ' , 'try_at ' => '2020-01-01 00:00:00 ' , 'should_fail ' => false ]])]
105
103
#[TestWith([['now ' => '2020-01-01 00:00:00 ' , 'try_at ' => '2020-01-01 00:04:59 ' , 'should_fail ' => false ]])]
106
104
#[TestWith([['now ' => '2020-01-01 00:00:00 ' , 'try_at ' => '2020-01-01 00:05:00 ' , 'should_fail ' => true ]])]
107
- public function after_max_retry_until_it_will_log_to_failed_table_and_delete_the_task (array $ args )
105
+ public function after_max_retry_until_it_will_log_to_failed_table (array $ args )
108
106
{
109
107
// Arrange
110
108
$ this ->travelTo ($ args ['now ' ]);
@@ -115,8 +113,6 @@ public function after_max_retry_until_it_will_log_to_failed_table_and_delete_the
115
113
$ releasedJob = $ job ->runAndGetReleasedJob ();
116
114
117
115
// Assert
118
- CloudTasksApi::assertDeletedTaskCount (1 );
119
- CloudTasksApi::assertTaskDeleted ($ job ->task ->getName ());
120
116
$ this ->assertDatabaseCount ('failed_jobs ' , 0 );
121
117
122
118
// Act
@@ -130,6 +126,9 @@ public function after_max_retry_until_it_will_log_to_failed_table_and_delete_the
130
126
#[Test]
131
127
public function test_unlimited_max_attempts ()
132
128
{
129
+ // Assert
130
+ Event::fake (JobOutput::class);
131
+
133
132
// Act
134
133
$ job = $ this ->dispatch (new FailingJobWithUnlimitedTries ());
135
134
@@ -138,8 +137,7 @@ public function test_unlimited_max_attempts()
138
137
$ job = $ job ->runAndGetReleasedJob ();
139
138
}
140
139
141
- // -1 because the last job is not run.
142
- CloudTasksApi::assertDeletedTaskCount (51 );
140
+ Event::assertDispatched (JobOutput::class, 51 );
143
141
}
144
142
145
143
#[Test]
@@ -204,9 +202,7 @@ public function failing_jobs_are_released()
204
202
205
203
$ job ->run ();
206
204
207
- CloudTasksApi::assertDeletedTaskCount (1 );
208
205
CloudTasksApi::assertCreatedTaskCount (2 );
209
- CloudTasksApi::assertTaskDeleted ($ job ->task ->getName ());
210
206
Event::assertDispatched (JobReleasedAfterException::class, function ($ event ) {
211
207
return $ event ->job ->attempts () === 1 ;
212
208
});
0 commit comments