From 962562c97e26064a743f563ea6e4994615e7296a Mon Sep 17 00:00:00 2001 From: jaulz <5358638+jaulz@users.noreply.github.com> Date: Fri, 8 Nov 2024 07:50:59 +0000 Subject: [PATCH] test: add test --- tests/JobPipelineTest.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/JobPipelineTest.php b/tests/JobPipelineTest.php index bf8d1a5..29d6ca8 100644 --- a/tests/JobPipelineTest.php +++ b/tests/JobPipelineTest.php @@ -2,6 +2,7 @@ namespace Stancl\JobPipeline\Tests; +use Exception; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Queue; @@ -193,6 +194,22 @@ class JobPipelineTest extends TestCase $this->assertTrue($passes); } + + /** @test */ + public function failures_in_closures_will_throw_correctly() + { + $this->expectExceptionMessage('foobar'); + + Event::listen(TestEvent::class, JobPipeline::make([ + function () { + throw new Exception('foobar'); + } + ])->send(function (TestEvent $event) { + return $this->valuestore; + })->shouldBeQueued(false)->toListener()); + + event(new TestEvent(new TestModel())); + } } class FooJob