From ef4ded6e4e069ec84c37b93a6b563b13424723cc Mon Sep 17 00:00:00 2001 From: Jonathan Martins Date: Thu, 2 Mar 2023 14:19:06 -0300 Subject: [PATCH] leave only shouldBeQueued method --- src/JobPipeline.php | 56 +++------------------------------- tests/JobPipelineTest.php | 4 +-- tests/tmp/jobpipelinetest.json | 1 + 3 files changed, 8 insertions(+), 53 deletions(-) diff --git a/src/JobPipeline.php b/src/JobPipeline.php index 69d7c69..952f2c7 100644 --- a/src/JobPipeline.php +++ b/src/JobPipeline.php @@ -64,60 +64,14 @@ class JobPipeline implements ShouldQueue return $this; } - public function shouldBeQueued(bool|string $shouldBeQueued = true) + public function shouldBeQueued(bool $shouldBeQueued = true, string $queue = '') { - if (is_string($shouldBeQueued)) + $this->shouldBeQueued = $shouldBeQueued; + + if ($queue) { - $this->shouldBeQueuedOn($shouldBeQueued); + $this->queue = $queue; } - else - { - $this->shouldBeQueued = $shouldBeQueued; - } - - return $this; - } - - public function shouldBeQueuedOn(string $queue) - { - $this->shouldBeQueued = true; - - $this->onQueue($queue); - - return $this; - } - - public function onConnection(null|string $connection) - { - $this->connection = $connection; - - return $this; - } - - public function onQueue(null|string $queue) - { - $this->queue = $queue; - - return $this; - } - - public function timeout(int $timeoutInSeconds) - { - $this->timeout = $timeoutInSeconds; - - return $this; - } - - public function delay($delay) - { - $this->delay = $delay; - - return $this; - } - - public function tries(int $tries) - { - $this->tries = $tries; return $this; } diff --git a/tests/JobPipelineTest.php b/tests/JobPipelineTest.php index 27cf520..c1d75c4 100644 --- a/tests/JobPipelineTest.php +++ b/tests/JobPipelineTest.php @@ -87,7 +87,7 @@ class JobPipelineTest extends TestCase FooJob::class, ])->send(function () { return $this->valuestore; - })->shouldBeQueuedOn('another') + })->shouldBeQueued(true, 'another') ->toListener()); $this->assertFalse($this->valuestore->has('foo')); @@ -106,7 +106,7 @@ class JobPipelineTest extends TestCase FooJob::class, ])->send(function () { return $this->valuestore; - })->shouldBeQueuedOn('another') + })->shouldBeQueued(true, 'another') ->toListener()); $this->assertFalse($this->valuestore->has('foo')); diff --git a/tests/tmp/jobpipelinetest.json b/tests/tmp/jobpipelinetest.json index e69de29..9f5dd4e 100644 --- a/tests/tmp/jobpipelinetest.json +++ b/tests/tmp/jobpipelinetest.json @@ -0,0 +1 @@ +{"foo":"bar"} \ No newline at end of file