From 7d2b781eeddc2bb5e81cd55b60817ad691a36e44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Pr=C3=A9vot?= Date: Wed, 2 Dec 2026 09:54:30 +0100 Subject: [PATCH] Compatibility with stable cartesian-product releases Use `of` static method if available, instead of now private constructor, as well as `toArray` instead of `compute`. --- composer.json | 2 +- src/HttpBaseTest.php | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 8ee8166..4e8865c 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "phpunit/phpunit": "^9.6.17 || ^10.0 || ^11.0 || ^12.0", "php-http/message": "^1.0 || ^2.0", "guzzlehttp/psr7": "^1.9 || ^2.0 || ^3.0", - "th3n3rd/cartesian-product": "^0.3" + "th3n3rd/cartesian-product": "^0.3 || ^1.0" }, "suggest": { "php-http/httplug": "To test async client" diff --git a/src/HttpBaseTest.php b/src/HttpBaseTest.php index 1852721..569b40a 100644 --- a/src/HttpBaseTest.php +++ b/src/HttpBaseTest.php @@ -58,9 +58,15 @@ public static function requestProvider(): array 'body' => self::getBodies(), ]; - $cartesianProduct = new CartesianProduct($sets); + if (method_exists(CartesianProduct::class, 'of')) { + $cartesianProduct = CartesianProduct::of($sets); - $cases = $cartesianProduct->compute(); + $cases = $cartesianProduct->toArray(); + } else { + $cartesianProduct = new CartesianProduct($sets); + + $cases = $cartesianProduct->compute(); + } // Filter all TRACE requests with a body, as they're not HTTP spec compliant return array_filter($cases, function ($case) { @@ -81,9 +87,15 @@ public static function requestWithOutcomeProvider(): array 'body' => self::getBodies(), ]; - $cartesianProduct = new CartesianProduct($sets); + if (method_exists(CartesianProduct::class, 'of')) { + $cartesianProduct = CartesianProduct::of($sets); - return $cartesianProduct->compute(); + return $cartesianProduct->toArray(); + } else { + $cartesianProduct = new CartesianProduct($sets); + + return $cartesianProduct->compute(); + } } private static function getMethods(): array