From 4426a898dcb1915e96376fc1b9d72db96480367f Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Mon, 9 Sep 2024 23:31:51 +0800 Subject: [PATCH 1/6] Concurrency Improvements 1. Add a working tests for Concurrency 2. Update composer.json to include replace `illuminate/concurrency` 3. Update PHP versions Signed-off-by: Mior Muhammad Zaki --- composer.json | 1 + src/Illuminate/Concurrency/ForkDriver.php | 1 + src/Illuminate/Concurrency/composer.json | 2 +- .../Concurrency/ConcurrencyTest.php | 28 +++++++++++++++---- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 75485f2e75e0..d4ced3fe1993 100644 --- a/composer.json +++ b/composer.json @@ -64,6 +64,7 @@ "illuminate/bus": "self.version", "illuminate/cache": "self.version", "illuminate/collections": "self.version", + "illuminate/concurrency": "self.version", "illuminate/conditionable": "self.version", "illuminate/config": "self.version", "illuminate/console": "self.version", diff --git a/src/Illuminate/Concurrency/ForkDriver.php b/src/Illuminate/Concurrency/ForkDriver.php index ad1e62f156a5..beca07d7e44b 100644 --- a/src/Illuminate/Concurrency/ForkDriver.php +++ b/src/Illuminate/Concurrency/ForkDriver.php @@ -14,6 +14,7 @@ class ForkDriver */ public function run(Closure|array $tasks): array { + /** @phpstan-ignore class.notFound */ return Fork::new()->run(...Arr::wrap($tasks)); } diff --git a/src/Illuminate/Concurrency/composer.json b/src/Illuminate/Concurrency/composer.json index d0ac214062e0..6476f73aafde 100644 --- a/src/Illuminate/Concurrency/composer.json +++ b/src/Illuminate/Concurrency/composer.json @@ -14,7 +14,7 @@ } ], "require": { - "php": "^8.0.2", + "php": "^8.2", "illuminate/process": "^11.0", "laravel/serializable-closure": "^1.2.2" }, diff --git a/tests/Integration/Concurrency/ConcurrencyTest.php b/tests/Integration/Concurrency/ConcurrencyTest.php index c2f2495d48be..daad1fe2b34b 100644 --- a/tests/Integration/Concurrency/ConcurrencyTest.php +++ b/tests/Integration/Concurrency/ConcurrencyTest.php @@ -4,17 +4,35 @@ use Illuminate\Support\Facades\Concurrency; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\RequiresOperatingSystem; +#[RequiresOperatingSystem('Linux|DAR')] class ConcurrencyTest extends TestCase { + protected function setUp(): void + { + $this->defineStashRoutes(<< 1 + 1, + fn () => 2 + 2, + ]); +}); +PHP); + + parent::setUp(); + } + public function testWorkCanBeDistributed() { - $this->markTestSkipped('Todo...'); + $response = $this->get('concurrency') + ->assertOk(); - [$first, $second] = Concurrency::run([ - fn () => 1 + 1, - fn () => 2 + 2, - ]); + [$first, $second] = $response->original; $this->assertEquals(2, $first); $this->assertEquals(4, $second); From eac0a6326f38b81d0fe680b5275f60e90ee456a8 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Mon, 9 Sep 2024 15:33:51 +0000 Subject: [PATCH 2/6] Apply fixes from StyleCI --- tests/Integration/Concurrency/ConcurrencyTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/Integration/Concurrency/ConcurrencyTest.php b/tests/Integration/Concurrency/ConcurrencyTest.php index daad1fe2b34b..270109735dbb 100644 --- a/tests/Integration/Concurrency/ConcurrencyTest.php +++ b/tests/Integration/Concurrency/ConcurrencyTest.php @@ -2,7 +2,6 @@ namespace Illuminate\Tests\Integration\Console; -use Illuminate\Support\Facades\Concurrency; use Orchestra\Testbench\TestCase; use PHPUnit\Framework\Attributes\RequiresOperatingSystem; From 72337d5bc8476c0df78b3dfb0b8f58fa5fc60c1d Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Mon, 9 Sep 2024 23:40:38 +0800 Subject: [PATCH 3/6] wip Signed-off-by: Mior Muhammad Zaki --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d4ced3fe1993..8a78ce9b10cf 100644 --- a/composer.json +++ b/composer.json @@ -107,7 +107,7 @@ "league/flysystem-sftp-v3": "^3.0", "mockery/mockery": "^1.6", "nyholm/psr7": "^1.2", - "orchestra/testbench-core": "^9.3.0", + "orchestra/testbench-core": "^9.4.0", "pda/pheanstalk": "^5.0", "phpstan/phpstan": "^1.11.5", "phpunit/phpunit": "^10.5|^11.0", From bb7c9f8b9894f612f969c5b9e0021fd18cdf2e4a Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Mon, 9 Sep 2024 23:49:56 +0800 Subject: [PATCH 4/6] wip Signed-off-by: Mior Muhammad Zaki --- tests/Integration/Concurrency/ConcurrencyTest.php | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/tests/Integration/Concurrency/ConcurrencyTest.php b/tests/Integration/Concurrency/ConcurrencyTest.php index 270109735dbb..6f7d10b4042a 100644 --- a/tests/Integration/Concurrency/ConcurrencyTest.php +++ b/tests/Integration/Concurrency/ConcurrencyTest.php @@ -2,18 +2,11 @@ namespace Illuminate\Tests\Integration\Console; -use Orchestra\Testbench\TestCase; -use PHPUnit\Framework\Attributes\RequiresOperatingSystem; - -#[RequiresOperatingSystem('Linux|DAR')] -class ConcurrencyTest extends TestCase -{ - protected function setUp(): void - { - $this->defineStashRoutes(<< Date: Mon, 9 Sep 2024 23:50:17 +0800 Subject: [PATCH 5/6] wip Signed-off-by: Mior Muhammad Zaki --- tests/Integration/Concurrency/ConcurrencyTest.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/Integration/Concurrency/ConcurrencyTest.php b/tests/Integration/Concurrency/ConcurrencyTest.php index 6f7d10b4042a..19c95af6c988 100644 --- a/tests/Integration/Concurrency/ConcurrencyTest.php +++ b/tests/Integration/Concurrency/ConcurrencyTest.php @@ -2,12 +2,21 @@ namespace Illuminate\Tests\Integration\Console; -use Illuminate\Support\Facades\Concurrency; -use Illuminate\Support\Facades\Route; use Orchestra\Testbench\Attributes\UsesVendor; use Orchestra\Testbench\TestCase; use PHPUnit\Framework\Attributes\RequiresOperatingSystem; +#[UsesVendor] +#[RequiresOperatingSystem('Linux|DAR')] +class ConcurrencyTest extends TestCase +{ + protected function setUp(): void + { + $this->defineStashRoutes(<< 1 + 1, From 7a79031cc2d7fff6aad5133878987f643f597ba2 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Mon, 9 Sep 2024 23:51:53 +0800 Subject: [PATCH 6/6] wip Signed-off-by: Mior Muhammad Zaki --- tests/Integration/Concurrency/ConcurrencyTest.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/Integration/Concurrency/ConcurrencyTest.php b/tests/Integration/Concurrency/ConcurrencyTest.php index 19c95af6c988..76012712c375 100644 --- a/tests/Integration/Concurrency/ConcurrencyTest.php +++ b/tests/Integration/Concurrency/ConcurrencyTest.php @@ -2,17 +2,15 @@ namespace Illuminate\Tests\Integration\Console; -use Orchestra\Testbench\Attributes\UsesVendor; use Orchestra\Testbench\TestCase; use PHPUnit\Framework\Attributes\RequiresOperatingSystem; -#[UsesVendor] #[RequiresOperatingSystem('Linux|DAR')] class ConcurrencyTest extends TestCase { protected function setUp(): void { - $this->defineStashRoutes(<<defineCacheRoutes(<<