diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b49d6e1..c04e8cb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,12 +19,15 @@ jobs: - "8.3" - "8.4" - "8.5" + - "8.6" dependencies: - "lowest" - "highest" exclude: - php-version: "8.5" dependencies: "lowest" + - php-version: "8.6" + dependencies: "lowest" steps: - name: "Checkout" diff --git a/lib/promise-adapter/src/Adapter/WebonyxGraphQLSyncPromiseAdapter.php b/lib/promise-adapter/src/Adapter/WebonyxGraphQLSyncPromiseAdapter.php index 7fb5eaa..5be169f 100644 --- a/lib/promise-adapter/src/Adapter/WebonyxGraphQLSyncPromiseAdapter.php +++ b/lib/promise-adapter/src/Adapter/WebonyxGraphQLSyncPromiseAdapter.php @@ -22,7 +22,7 @@ */ class WebonyxGraphQLSyncPromiseAdapter implements PromiseAdapterInterface { - /** @var callable[] */ + /** @var array */ private $cancellers = []; /** @@ -61,7 +61,7 @@ public function create(&$resolve = null, &$reject = null, ?callable $canceller = $resolve = $res; $reject = $rej; }); - $this->cancellers[spl_object_hash($promise)] = $canceller; + $this->cancellers[spl_object_id($promise)] = $canceller; return $promise; } @@ -137,8 +137,8 @@ public function await($promise = null, $unwrap = false) throw $exception; } - $hash = spl_object_hash($promise); - unset($this->cancellers[$hash]); + $id = spl_object_id($promise); + unset($this->cancellers[$id]); return $resolvedValue; } @@ -147,12 +147,12 @@ public function await($promise = null, $unwrap = false) */ public function cancel($promise) { - $hash = spl_object_hash($promise); - if (!$this->isPromise($promise) || !isset($this->cancellers[$hash])) { + $id = spl_object_id($promise); + if (!$this->isPromise($promise) || !isset($this->cancellers[$id])) { throw new \InvalidArgumentException(sprintf('The "%s" method must be called with a compatible Promise.', __METHOD__)); } - $canceller = $this->cancellers[$hash]; - unset($this->cancellers[$hash]); + $canceller = $this->cancellers[$id]; + unset($this->cancellers[$id]); $adoptedPromise = $promise; if ($promise instanceof Promise) { $adoptedPromise = $promise->adoptedPromise; diff --git a/src/CacheMap.php b/src/CacheMap.php index eb98873..b7cfd64 100644 --- a/src/CacheMap.php +++ b/src/CacheMap.php @@ -51,7 +51,7 @@ public function clearAll() private static function serializedKey($key) { if (is_object($key)) { - return spl_object_hash($key); + return sprintf('%032x', spl_object_id($key)); } elseif (is_array($key)) { return json_encode($key); } diff --git a/tests/Functional/Webonyx/GraphQL/TestCase.php b/tests/Functional/Webonyx/GraphQL/TestCase.php index 2ad5840..278739e 100644 --- a/tests/Functional/Webonyx/GraphQL/TestCase.php +++ b/tests/Functional/Webonyx/GraphQL/TestCase.php @@ -22,6 +22,9 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase { + /** Fixture file names mapped to testExecute() parameter names. */ + private const FIXTURE_ARGUMENTS = ['metrics' => 'expectedMetrics', 'response' => 'expectedResponse']; + private static $fixtures = null; public static function getFixtures() @@ -32,7 +35,7 @@ public static function getFixtures() foreach ($fixturesFiles as $file) { $pathInfo = pathinfo($file); $group = basename($pathInfo['dirname']); - $key = $pathInfo['filename']; + $key = self::FIXTURE_ARGUMENTS[$pathInfo['filename']] ?? $pathInfo['filename']; $content = file_get_contents($file); diff --git a/tests/TestCase.php b/tests/TestCase.php index 3b58663..1cda450 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -29,13 +29,13 @@ public function setUp(): void protected function tearDown(): void { $instances = new \ReflectionProperty(DataLoader::class, 'instances'); - $instances->setValue(null); + $instances->setValue(null, null); $activeInstances = new \ReflectionProperty(DataLoader::class, 'activeInstances'); - $activeInstances->setValue([]); + $activeInstances->setValue(null, []); $promiseAdapters = new \ReflectionProperty(DataLoader::class, 'promiseAdapters'); - $promiseAdapters->setValue(null); + $promiseAdapters->setValue(null, null); parent::tearDown(); }