Skip to content

Commit 9fd1a36

Browse files
committed
Update test to take into account updated 8.x behavior
1 parent d165daf commit 9fd1a36

File tree

1 file changed

+100
-5
lines changed

1 file changed

+100
-5
lines changed

tests/TaskHandlerTest.php

Lines changed: 100 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,17 +284,13 @@ public function hasMaxRetryDuration() {
284284

285285
/**
286286
* @test
287-
* @testWith [{"retryCount": 1, "shouldHaveFailed": false}]
288-
* [{"retryCount": 2, "shouldHaveFailed": false}]
289-
* [{"retryCount": 2, "travelSeconds": 29, "shouldHaveFailed": false}]
290-
* [{"retryCount": 2, "travelSeconds": 31, "shouldHaveFailed": true}]
287+
* @dataProvider whenIsJobFailingProvider
291288
*/
292289
public function job_max_attempts_is_ignored_if_has_retry_until($example)
293290
{
294291
// Arrange
295292
$this->request->headers->add(['X-CloudTasks-TaskRetryCount' => $example['retryCount']]);
296293

297-
$now = Carbon::now()->getTimestamp();
298294
if (array_key_exists('travelSeconds', $example)) {
299295
Carbon::setTestNow(Carbon::now()->addSeconds($example['travelSeconds']));
300296
}
@@ -346,6 +342,105 @@ public function getFirstAttempt() {
346342
}
347343
}
348344

345+
public function whenIsJobFailingProvider()
346+
{
347+
$this->createApplication();
348+
349+
// 8.x behavior: if retryUntil, only check that.
350+
// 6.x behavior: if retryUntil, check that, otherwise check maxAttempts
351+
352+
// max retry count is 3
353+
// max retryUntil is 30 seconds
354+
355+
if (version_compare(app()->version(), '8.0.0', '>=')) {
356+
return [
357+
[
358+
[
359+
'retryCount' => 1,
360+
'shouldHaveFailed' => false,
361+
],
362+
],
363+
[
364+
[
365+
'retryCount' => 2,
366+
'shouldHaveFailed' => false,
367+
],
368+
],
369+
[
370+
[
371+
'retryCount' => 1,
372+
'travelSeconds' => 29,
373+
'shouldHaveFailed' => false,
374+
],
375+
],
376+
[
377+
[
378+
'retryCount' => 1,
379+
'travelSeconds' => 31,
380+
'shouldHaveFailed' => true,
381+
],
382+
],
383+
[
384+
[
385+
'retryCount' => 1,
386+
'travelSeconds' => 32,
387+
'shouldHaveFailed' => true,
388+
],
389+
],
390+
[
391+
[
392+
'retryCount' => 1,
393+
'travelSeconds' => 31,
394+
'shouldHaveFailed' => true,
395+
],
396+
],
397+
];
398+
}
399+
400+
return [
401+
[
402+
[
403+
'retryCount' => 1,
404+
'shouldHaveFailed' => false,
405+
],
406+
],
407+
[
408+
[
409+
'retryCount' => 2,
410+
'shouldHaveFailed' => true,
411+
],
412+
],
413+
[
414+
[
415+
'retryCount' => 1,
416+
'travelSeconds' => 29,
417+
'shouldHaveFailed' => false,
418+
],
419+
],
420+
[
421+
[
422+
'retryCount' => 1,
423+
'travelSeconds' => 31,
424+
'shouldHaveFailed' => true,
425+
],
426+
],
427+
[
428+
[
429+
'retryCount' => 1,
430+
'travelSeconds' => 32,
431+
'shouldHaveFailed' => true,
432+
],
433+
],
434+
[
435+
[
436+
'retryCount' => 1,
437+
'travelSeconds' => 32,
438+
'shouldHaveFailed' => true,
439+
],
440+
],
441+
];
442+
}
443+
349444
private function simpleJob()
350445
{
351446
return json_decode(file_get_contents(__DIR__ . '/Support/test-job-payload.json'), true);

0 commit comments

Comments
 (0)