33namespace Interop \Async \Loop ;
44
55if (!defined ("SIGUSR1 " )) {
6- define ("SIGUSR1 " , 10 );
6+ define ("SIGUSR1 " , 30 );
7+ }
8+ if (!defined ("SIGUSR2 " )) {
9+ define ("SIGUSR2 " , 31 );
710}
811
912abstract class Test extends \PHPUnit_Framework_TestCase {
@@ -464,7 +467,7 @@ function testNoMemoryLeak($type, $args)
464467
465468 function testExecutionOrderGuarantees ()
466469 {
467- $ this ->expectOutputString ("01 02 03 04 " .str_repeat ("05 " , 8 )."10 11 12 " .str_repeat ("13 " , 4 )."20 21 22 23 24 25 30 31 " );
470+ $ this ->expectOutputString ("01 02 03 04 " .str_repeat ("05 " , 8 )."10 11 12 " .str_repeat ("13 " , 4 )."20 21 21 21 21 22 30 31 " );
468471 $ this ->start (function (Driver $ loop ) use (&$ ticks ) {
469472 $ f = function () use ($ loop ) {
470473 $ args = func_get_args ();
@@ -517,13 +520,13 @@ function testExecutionOrderGuarantees()
517520 $ loop ->onWritable (STDIN , $ f (1 , 3 ));
518521 });
519522
520- $ loop ->delay ($ msDelay = 15 , $ f (3 , 1 ));
521- $ loop ->delay ($ msDelay = 6 , $ f (2 , 5 ));
523+ $ loop ->delay ($ msDelay = 25 , $ f (3 , 1 ));
524+ $ loop ->delay ($ msDelay = 6 , $ f (2 , 2 ));
522525 $ loop ->delay ($ msDelay = 5 , $ f (2 , 1 ));
523- $ loop ->repeat ($ msDelay = 5 , $ f (2 , 2 ));
524- $ rep1 = $ loop ->repeat ($ msDelay = 5 , $ f (2 , 4 ));
526+ $ loop ->repeat ($ msDelay = 5 , $ f (2 , 1 ));
527+ $ rep1 = $ loop ->repeat ($ msDelay = 5 , $ f (2 , 1 ));
525528 $ loop ->disable ($ rep1 );
526- $ loop ->delay ($ msDelay = 5 , $ f (2 , 3 ));
529+ $ loop ->delay ($ msDelay = 5 , $ f (2 , 1 ));
527530 $ loop ->enable ($ rep1 );
528531
529532 $ loop ->defer ($ f (0 , 1 ));
@@ -934,7 +937,7 @@ function testInitiallyDisabledOnSignalWatcher()
934937 $ loop ->delay ($ msDelay = 1 , function () use ($ loop , $ watcherId ) {
935938 $ loop ->enable ($ watcherId );
936939 $ loop ->delay ($ msDelay = 1 , function () {
937- \posix_kill (\getmypid (), \ SIGUSR1 );
940+ \posix_kill (\getmypid (), SIGUSR1 );
938941 });
939942 });
940943 });
@@ -947,7 +950,7 @@ function testNestedLoopSignalDispatch()
947950 $ this ->markTestSkipped ("ext/posix required to test signal handlers " );
948951 }
949952
950- $ this ->expectOutputString ("inner SIGUSR1 \nouter SIGUSR1 \n" );
953+ $ this ->expectOutputString ("inner SIGUSR2 \nouter SIGUSR1 \n" );
951954 $ this ->start (function (Driver $ loop ) {
952955 $ loop ->delay ($ msDelay = 30 , function () use ($ loop ) {
953956 $ loop ->stop ();
@@ -963,13 +966,13 @@ function testNestedLoopSignalDispatch()
963966 echo "ERROR: manual stop " ;
964967 $ loop ->stop ();
965968 });
966- $ loop ->onSignal (SIGUSR1 , function ($ watcherId ) use ($ loop , $ stop ) {
967- echo "inner SIGUSR1 \n" ;
969+ $ loop ->onSignal (SIGUSR2 , function ($ watcherId ) use ($ loop , $ stop ) {
970+ echo "inner SIGUSR2 \n" ;
968971 $ loop ->cancel ($ stop );
969972 $ loop ->cancel ($ watcherId );
970973 });
971974 $ loop ->delay ($ msDelay = 1 , function () {
972- \posix_kill (\getmypid (), \ SIGUSR1 );
975+ \posix_kill (\getmypid (), SIGUSR2 );
973976 });
974977 $ loop ->run ();
975978 });
@@ -1115,25 +1118,25 @@ function testOptionalCallbackDataPassedOnInvocation()
11151118 $ this ->assertTrue ($ callbackData ->onWritable );
11161119 }
11171120
1118- // implementations SHOULD use Interop\Async\Loop\Registry trait , but are not forced to, hence test it here again
1121+ // getState and setState are final , but test it here again to be sure
11191122 function testRegistry () {
1120- $ this ->assertNull ($ this ->loop ->fetchState ("foo " ));
1121- $ this ->loop ->storeState ("foo " , NAN );
1122- $ this ->assertTrue (is_nan ($ this ->loop ->fetchState ("foo " )));
1123- $ this ->loop ->storeState ("foo " , "1 " );
1124- $ this ->assertNull ($ this ->loop ->fetchState ("bar " ));
1125- $ this ->loop ->storeState ("baz " , -INF );
1123+ $ this ->assertNull ($ this ->loop ->getState ("foo " ));
1124+ $ this ->loop ->setState ("foo " , NAN );
1125+ $ this ->assertTrue (is_nan ($ this ->loop ->getState ("foo " )));
1126+ $ this ->loop ->setState ("foo " , "1 " );
1127+ $ this ->assertNull ($ this ->loop ->getState ("bar " ));
1128+ $ this ->loop ->setState ("baz " , -INF );
11261129 // running must not affect state
11271130 $ this ->loop ->defer ([$ this ->loop , "stop " ]);
11281131 $ this ->loop ->run ();
1129- $ this ->assertSame (-INF , $ this ->loop ->fetchState ("baz " ));
1130- $ this ->assertSame ("1 " , $ this ->loop ->fetchState ("foo " ));
1132+ $ this ->assertSame (-INF , $ this ->loop ->getState ("baz " ));
1133+ $ this ->assertSame ("1 " , $ this ->loop ->getState ("foo " ));
11311134 }
11321135
11331136 /** @dataProvider provideRegistryValues */
11341137 function testRegistryValues ($ val ) {
1135- $ this ->loop ->storeState ("foo " , $ val );
1136- $ this ->assertSame ($ val , $ this ->loop ->fetchState ("foo " ));
1138+ $ this ->loop ->setState ("foo " , $ val );
1139+ $ this ->assertSame ($ val , $ this ->loop ->getState ("foo " ));
11371140 }
11381141
11391142 function provideRegistryValues () {
0 commit comments