xref: /php-uv/tests/320-fs-poll.phpt (revision 4332fe7a)
1--TEST--
2Check for fs poll
3--FILE--
4<?php
5define("FIXTURE_PATH", dirname(__FILE__) . "/fixtures/poll");
6
7$poll = uv_fs_poll_init(uv_default_loop());
8
9fclose(fopen(FIXTURE_PATH, "w+"));
10
11$i = 0;
12uv_fs_poll_start($poll,function($rsc,$stat,$p,$c) use (&$i) {
13    echo "OK";
14
15    if ($i > 3) {
16        uv_fs_poll_stop($rsc);
17        uv_unref($rsc);
18    }
19    $i++;
20}, FIXTURE_PATH, 1);
21
22$timer = uv_timer_init();
23uv_timer_start($timer, 100, 100, function($timer) use (&$i) {
24    $fp = fopen(FIXTURE_PATH, "w+");
25    fwrite($fp,"hoge");
26    fclose($fp);
27
28    if ($i > 4) {
29        uv_timer_stop($timer);
30        uv_unref($timer);
31    }
32});
33
34uv_run();
35--EXPECT--
36OKOKOKOKOK
37