From c7a95d4258bb10d23d220fd046852bfe1651e7b2 Mon Sep 17 00:00:00 2001 From: NathanFreeman <1056159381@qq.com> Date: Wed, 25 Dec 2024 19:57:51 +0800 Subject: [PATCH] add pgsql test --- .../long_running_pgsql_test.phpt | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 tests/swoole_pdo_pgsql/long_running_pgsql_test.phpt diff --git a/tests/swoole_pdo_pgsql/long_running_pgsql_test.phpt b/tests/swoole_pdo_pgsql/long_running_pgsql_test.phpt new file mode 100644 index 00000000000..67c0ddfa55b --- /dev/null +++ b/tests/swoole_pdo_pgsql/long_running_pgsql_test.phpt @@ -0,0 +1,46 @@ +--TEST-- +swoole_pdo_pgsql: long running pgsql test +--SKIPIF-- + +--FILE-- + SWOOLE_HOOK_PDO_PGSQL]); +run(function() { + $waitGroup = new WaitGroup(); + $channel = new Channel(1); + Coroutine::create(function() use ($waitGroup, $channel) { + $waitGroup->add(); + $pdo = pdo_pgsql_test_inc::create(); + $pdo->query("SELECT pg_sleep(5);"); + $waitGroup->done(); + echo 'DONE' . PHP_EOL; + }); + + Coroutine::create(function() use ($waitGroup, $channel) { + $waitGroup->add(); + $result = $channel->pop(2); + if (!$result) { + echo 'channel pop timeout' . PHP_EOL; + } + $waitGroup->done(); + }); + + var_dump(1); + Coroutine::sleep(1); + var_dump(2); + $waitGroup->wait(); +}); +?> +--EXPECTF-- +int(1) +int(2) +channel pop timeout +DONE