@@ -78,33 +78,31 @@ public function after_max_attempts_it_will_log_to_failed_table()
7878 }
7979
8080 #[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 ()
8282 {
8383 // Arrange
84+ Event::fake ([JobOutput::class]);
8485 $ job = $ this ->dispatch (new FailingJob ());
8586
8687 // Act & Assert
8788 $ releasedJob = $ job ->runAndGetReleasedJob ();
88- CloudTasksApi::assertDeletedTaskCount (1 );
89- CloudTasksApi::assertTaskDeleted ($ job ->task ->getName ());
89+ Event::assertDispatched (JobOutput::class, 1 );
9090 $ this ->assertDatabaseCount ('failed_jobs ' , 0 );
9191
9292 $ releasedJob = $ releasedJob ->runAndGetReleasedJob ();
93- CloudTasksApi::assertDeletedTaskCount (2 );
94- CloudTasksApi::assertTaskDeleted ($ job ->task ->getName ());
93+ Event::assertDispatched (JobOutput::class, 2 );
9594 $ this ->assertDatabaseCount ('failed_jobs ' , 0 );
9695
9796 $ releasedJob ->run ();
98- CloudTasksApi::assertDeletedTaskCount (3 );
99- CloudTasksApi::assertTaskDeleted ($ job ->task ->getName ());
97+ Event::assertDispatched (JobOutput::class, 4 );
10098 $ this ->assertDatabaseCount ('failed_jobs ' , 1 );
10199 }
102100
103101 #[Test]
104102 #[TestWith([['now ' => '2020-01-01 00:00:00 ' , 'try_at ' => '2020-01-01 00:00:00 ' , 'should_fail ' => false ]])]
105103 #[TestWith([['now ' => '2020-01-01 00:00:00 ' , 'try_at ' => '2020-01-01 00:04:59 ' , 'should_fail ' => false ]])]
106104 #[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 )
108106 {
109107 // Arrange
110108 $ this ->travelTo ($ args ['now ' ]);
@@ -115,8 +113,6 @@ public function after_max_retry_until_it_will_log_to_failed_table_and_delete_the
115113 $ releasedJob = $ job ->runAndGetReleasedJob ();
116114
117115 // Assert
118- CloudTasksApi::assertDeletedTaskCount (1 );
119- CloudTasksApi::assertTaskDeleted ($ job ->task ->getName ());
120116 $ this ->assertDatabaseCount ('failed_jobs ' , 0 );
121117
122118 // Act
@@ -130,6 +126,9 @@ public function after_max_retry_until_it_will_log_to_failed_table_and_delete_the
130126 #[Test]
131127 public function test_unlimited_max_attempts ()
132128 {
129+ // Assert
130+ Event::fake (JobOutput::class);
131+
133132 // Act
134133 $ job = $ this ->dispatch (new FailingJobWithUnlimitedTries ());
135134
@@ -138,8 +137,7 @@ public function test_unlimited_max_attempts()
138137 $ job = $ job ->runAndGetReleasedJob ();
139138 }
140139
141- // -1 because the last job is not run.
142- CloudTasksApi::assertDeletedTaskCount (51 );
140+ Event::assertDispatched (JobOutput::class, 51 );
143141 }
144142
145143 #[Test]
@@ -204,9 +202,7 @@ public function failing_jobs_are_released()
204202
205203 $ job ->run ();
206204
207- CloudTasksApi::assertDeletedTaskCount (1 );
208205 CloudTasksApi::assertCreatedTaskCount (2 );
209- CloudTasksApi::assertTaskDeleted ($ job ->task ->getName ());
210206 Event::assertDispatched (JobReleasedAfterException::class, function ($ event ) {
211207 return $ event ->job ->attempts () === 1 ;
212208 });
0 commit comments