1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
<?php
namespace React\Tests\EventLoop;
use React\EventLoop\SignalsHandler;
final class SignalsHandlerTest extends TestCase
{
public function testEmittedEventsAndCallHandling()
{
$callCount = 0;
$func = function () use (&$callCount) {
$callCount++;
};
$signals = new SignalsHandler();
$this->assertSame(0, $callCount);
$signals->add(SIGUSR1, $func);
$this->assertSame(0, $callCount);
$signals->add(SIGUSR1, $func);
$this->assertSame(0, $callCount);
$signals->add(SIGUSR1, $func);
$this->assertSame(0, $callCount);
$signals->call(SIGUSR1);
$this->assertSame(1, $callCount);
$signals->add(SIGUSR2, $func);
$this->assertSame(1, $callCount);
$signals->add(SIGUSR2, $func);
$this->assertSame(1, $callCount);
$signals->call(SIGUSR2);
$this->assertSame(2, $callCount);
$signals->remove(SIGUSR2, $func);
$this->assertSame(2, $callCount);
$signals->remove(SIGUSR2, $func);
$this->assertSame(2, $callCount);
$signals->call(SIGUSR2);
$this->assertSame(2, $callCount);
$signals->remove(SIGUSR1, $func);
$this->assertSame(2, $callCount);
$signals->call(SIGUSR1);
$this->assertSame(2, $callCount);
}
}
|