From 0ca8ad0a47d876865ddc7a716db53bc4dd2395e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Debrauwer?= Date: Thu, 1 Aug 2024 16:51:25 +0200 Subject: [PATCH] [11.x] Inverse Fake Queue Interactions: `assertNotDeleted`, `assertNotFailed`, and `assertNotReleased` (#52320) * assertNotDeleted, assertNotFailed, and assertNotReleased * Update InteractsWithQueue.php --------- Co-authored-by: Taylor Otwell --- src/Illuminate/Queue/InteractsWithQueue.php | 51 +++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/Illuminate/Queue/InteractsWithQueue.php b/src/Illuminate/Queue/InteractsWithQueue.php index 790a2bf659d..a539f70c396 100644 --- a/src/Illuminate/Queue/InteractsWithQueue.php +++ b/src/Illuminate/Queue/InteractsWithQueue.php @@ -111,6 +111,23 @@ public function assertDeleted() return $this; } + /** + * Assert that the job was not deleted from the queue. + * + * @return $this + */ + public function assertNotDeleted() + { + $this->ensureQueueInteractionsHaveBeenFaked(); + + PHPUnit::assertTrue( + ! $this->job->isDeleted(), + 'Job was unexpectedly deleted.' + ); + + return $this; + } + /** * Assert that the job was manually failed. * @@ -128,6 +145,23 @@ public function assertFailed() return $this; } + /** + * Assert that the job was not manually failed. + * + * @return $this + */ + public function assertNotFailed() + { + $this->ensureQueueInteractionsHaveBeenFaked(); + + PHPUnit::assertTrue( + ! $this->job->hasFailed(), + 'Job was unexpectedly failed manually.' + ); + + return $this; + } + /** * Assert that the job was released back onto the queue. * @@ -158,6 +192,23 @@ public function assertReleased($delay = null) return $this; } + /** + * Assert that the job was not released back onto the queue. + * + * @return $this + */ + public function assertNotReleased() + { + $this->ensureQueueInteractionsHaveBeenFaked(); + + PHPUnit::assertTrue( + ! $this->job->isReleased(), + 'Job was unexpectedly released.' + ); + + return $this; + } + /** * Ensure that queue interactions have been faked. *