From db385ffc057208b323779453554d1f924a71eb56 Mon Sep 17 00:00:00 2001 From: Alex Vanderbist Date: Fri, 25 Aug 2023 18:05:14 +0200 Subject: [PATCH] Add test for tasks serialized to files --- tests/PoolTest.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/PoolTest.php b/tests/PoolTest.php index e906499..8689e99 100644 --- a/tests/PoolTest.php +++ b/tests/PoolTest.php @@ -388,4 +388,24 @@ public function it_can_be_stopped_early() $this->assertGreaterThanOrEqual($stoppingPoint, $completedProcessesCount); $this->assertLessThanOrEqual($concurrency * 2, $completedProcessesCount); } + + /** @test */ + public function it_writes_large_serialized_tasks_to_file() + { + $pool = Pool::create()->maxTaskPayload(10); + + $counter = 0; + + foreach (range(1, 5) as $i) { + $pool->add(function () { + return 2; + })->then(function (int $output) use (&$counter) { + $counter += $output; + }); + } + + $pool->wait(); + + $this->assertEquals(10, $counter, (string) $pool->status()); + } }