aboutsummaryrefslogtreecommitdiffhomepage
path: root/assets/php/vendor/react/event-loop/tests/SignalsHandlerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'assets/php/vendor/react/event-loop/tests/SignalsHandlerTest.php')
-rw-r--r--assets/php/vendor/react/event-loop/tests/SignalsHandlerTest.php55
1 files changed, 55 insertions, 0 deletions
diff --git a/assets/php/vendor/react/event-loop/tests/SignalsHandlerTest.php b/assets/php/vendor/react/event-loop/tests/SignalsHandlerTest.php
new file mode 100644
index 0000000..f8b7df3
--- /dev/null
+++ b/assets/php/vendor/react/event-loop/tests/SignalsHandlerTest.php
@@ -0,0 +1,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);
+ }
+}