diff --git a/examples/thread/map.php b/examples/thread/map.php new file mode 100644 index 00000000000..fc38de69ffd --- /dev/null +++ b/examples/thread/map.php @@ -0,0 +1,18 @@ + random_int(1, 999999999999999999), + 'b' => random_bytes(128), + 'c' => uniqid(), + 'd' => time(), + ]; + + $map = new Thread\Map($array); + $thread = new Thread(__FILE__, $map); +} else { + $map = $args[0]; + var_dump($map->toArray()); +} diff --git a/tests/swoole_runtime/file_hook/fgets.phpt b/tests/swoole_runtime/file_hook/fgets.phpt new file mode 100644 index 00000000000..9631b564c1f --- /dev/null +++ b/tests/swoole_runtime/file_hook/fgets.phpt @@ -0,0 +1,28 @@ +--TEST-- +swoole_runtime/file_hook: fgets +--SKIPIF-- + +--FILE-- + +--EXPECT-- diff --git a/tests/swoole_runtime/file_hook/co_fread.phpt b/tests/swoole_runtime/file_hook/fread.phpt similarity index 93% rename from tests/swoole_runtime/file_hook/co_fread.phpt rename to tests/swoole_runtime/file_hook/fread.phpt index e15062caee6..a8d45b341c5 100644 --- a/tests/swoole_runtime/file_hook/co_fread.phpt +++ b/tests/swoole_runtime/file_hook/fread.phpt @@ -13,7 +13,7 @@ Swoole\Runtime::enableCoroutine(); go(function () { $fp = fopen(__FILE__, 'r'); echo "open\n"; - $data = Co::fread($fp, 1024); + $data = fread($fp, 1024); echo "read\n"; Swoole\Runtime::enableCoroutine(false); Assert::assert(!empty($data)); diff --git a/tests/swoole_thread/arraylist.phpt b/tests/swoole_thread/arraylist.phpt index 2e9cd5967d3..196cb862618 100644 --- a/tests/swoole_thread/arraylist.phpt +++ b/tests/swoole_thread/arraylist.phpt @@ -19,6 +19,7 @@ $array = [ ]; $l = new ArrayList($array); +Assert::eq(count($l), count($array)); Assert::eq($l->toArray(), $array); for ($i = 0; $i < count($array); $i++) { @@ -31,6 +32,7 @@ $array2 = [ ]; $l[] = $array2; +Assert::eq(count($l), 5); Assert::eq($l[4]->toArray(), $array2); try { diff --git a/tests/swoole_thread/map.phpt b/tests/swoole_thread/map.phpt index 101bf05f8ae..3f16cf03a07 100644 --- a/tests/swoole_thread/map.phpt +++ b/tests/swoole_thread/map.phpt @@ -20,6 +20,7 @@ $array = [ $m = new Map($array); Assert::eq($m->toArray(), $array); +Assert::eq(count($m), count($array)); foreach ($array as $k => $v) { Assert::eq($m[$k], $array[$k]); @@ -30,8 +31,9 @@ $array2 = [ 'hello' => 'world', ]; $m['map'] = $array2; - +Assert::eq(count($m), 5); Assert::eq($m['map']->toArray(), $array2); +Assert::eq(count($m['map']), count($array2)); Assert::eq($m['map']->values(), array_values($array2)); ?> --EXPECTF--