From 9ac8c8059687a0b6160c2cf6dcec24e22f05db16 Mon Sep 17 00:00:00 2001 From: Ben Kuhl Date: Sun, 25 Feb 2018 12:52:20 -0500 Subject: [PATCH 1/4] bulk() now properly pushes expected jobs --- src/Illuminate/Support/Testing/Fakes/QueueFake.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Support/Testing/Fakes/QueueFake.php b/src/Illuminate/Support/Testing/Fakes/QueueFake.php index 7428b871ad6f..1843a63750b9 100644 --- a/src/Illuminate/Support/Testing/Fakes/QueueFake.php +++ b/src/Illuminate/Support/Testing/Fakes/QueueFake.php @@ -239,7 +239,7 @@ public function pop($queue = null) */ public function bulk($jobs, $data = '', $queue = null) { - foreach ($this->jobs as $job) { + foreach ($jobs as $job) { $this->push($job); } } From b54874b2060a903e3c9ecd5a94aa182279af49ae Mon Sep 17 00:00:00 2001 From: Ben Kuhl Date: Sun, 25 Feb 2018 12:55:29 -0500 Subject: [PATCH 2/4] Now also passes queue onto the fake --- src/Illuminate/Support/Testing/Fakes/QueueFake.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Support/Testing/Fakes/QueueFake.php b/src/Illuminate/Support/Testing/Fakes/QueueFake.php index 1843a63750b9..66d191e90c95 100644 --- a/src/Illuminate/Support/Testing/Fakes/QueueFake.php +++ b/src/Illuminate/Support/Testing/Fakes/QueueFake.php @@ -240,7 +240,7 @@ public function pop($queue = null) public function bulk($jobs, $data = '', $queue = null) { foreach ($jobs as $job) { - $this->push($job); + $this->push($job, $data, $queue); } } From ddfa02f82184bed5faa519b3600de18a9d0c01f7 Mon Sep 17 00:00:00 2001 From: Ben Kuhl Date: Mon, 26 Feb 2018 08:01:23 -0500 Subject: [PATCH 3/4] Added tests to assert bulk() actually pushes jobs to the queue --- tests/Support/SupportTestingQueueFakeTest.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/Support/SupportTestingQueueFakeTest.php b/tests/Support/SupportTestingQueueFakeTest.php index 1e14ff3af2f2..59263638e004 100644 --- a/tests/Support/SupportTestingQueueFakeTest.php +++ b/tests/Support/SupportTestingQueueFakeTest.php @@ -87,6 +87,20 @@ public function testAssertNothingPushed() $this->assertThat($e, new ExceptionMessage('Jobs were pushed unexpectedly.')); } } + + public function testAssertPushedUsingBulk() + { + $this->fake->assertNothingPushed(); + + $queue = 'my-test-queue'; + $this->fake->bulk([ + $this->job, + new JobStub() + ], null, $queue); + + $this->fake->assertPushedOn($queue, JobStub::class); + $this->fake->assertPushed(JobStub::class, 2); + } } class JobStub From 60babda8786281e8819db2eb192e1ef87a539325 Mon Sep 17 00:00:00 2001 From: Ben Kuhl Date: Mon, 26 Feb 2018 08:02:15 -0500 Subject: [PATCH 4/4] StyleCI adjustment --- tests/Support/SupportTestingQueueFakeTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Support/SupportTestingQueueFakeTest.php b/tests/Support/SupportTestingQueueFakeTest.php index 59263638e004..495bb0684d3e 100644 --- a/tests/Support/SupportTestingQueueFakeTest.php +++ b/tests/Support/SupportTestingQueueFakeTest.php @@ -95,7 +95,7 @@ public function testAssertPushedUsingBulk() $queue = 'my-test-queue'; $this->fake->bulk([ $this->job, - new JobStub() + new JobStub(), ], null, $queue); $this->fake->assertPushedOn($queue, JobStub::class);