-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[10.x] Remember the job on the exception (#48830)
* Remember the job on the exception * Update tests/Queue/QueueExceptionTest.php Co-authored-by: Julius Kiekbusch <[email protected]> * Update tests/Queue/QueueExceptionTest.php Co-authored-by: Julius Kiekbusch <[email protected]> * Update src/Illuminate/Queue/MaxAttemptsExceededException.php Co-authored-by: Dries Vints <[email protected]> * Update MaxAttemptsExceededException.php --------- Co-authored-by: Dries Vints <[email protected]> Co-authored-by: Julius Kiekbusch <[email protected]> Co-authored-by: Taylor Otwell <[email protected]>
- Loading branch information
1 parent
84a1580
commit 9d7868b
Showing
4 changed files
with
74 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace Illuminate\Tests\Queue; | ||
|
||
use Illuminate\Queue\Jobs\RedisJob; | ||
use Illuminate\Queue\Jobs\SyncJob; | ||
use Illuminate\Queue\MaxAttemptsExceededException; | ||
use Illuminate\Queue\TimeoutExceededException; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class QueueExceptionTest extends TestCase | ||
{ | ||
public function test_it_can_create_timeout_exception_for_job() | ||
{ | ||
$e = TimeoutExceededException::forJob($job = new MyFakeRedisJob()); | ||
|
||
$this->assertSame('App\\Jobs\\UnderlyingJob has timed out.', $e->getMessage()); | ||
$this->assertSame($job, $e->job); | ||
} | ||
|
||
public function test_it_can_create_max_attempts_exception_for_job() | ||
{ | ||
$e = MaxAttemptsExceededException::forJob($job = new MyFakeRedisJob()); | ||
|
||
$this->assertSame('App\\Jobs\\UnderlyingJob has been attempted too many times.', $e->getMessage()); | ||
$this->assertSame($job, $e->job); | ||
} | ||
} | ||
|
||
class MyFakeRedisJob extends RedisJob | ||
{ | ||
public function __construct() | ||
{ | ||
// | ||
} | ||
|
||
public function resolveName() | ||
{ | ||
return 'App\\Jobs\\UnderlyingJob'; | ||
} | ||
} |