Skip to content

Commit 8ad97c3

Browse files
committed
test async signals
1 parent f481d88 commit 8ad97c3

1 file changed

Lines changed: 29 additions & 1 deletion

File tree

tests/CurrentProcessTest.php

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
use Innmind\Server\Status\Server\Memory\Bytes;
1414
use Innmind\TimeContinuum\Period;
1515
use Innmind\TimeWarp\Halt;
16-
use Innmind\Signals\Handler;
16+
use Innmind\Signals\{
17+
Handler,
18+
Signal,
19+
Async\Interceptor,
20+
};
1721
use Innmind\Immutable\SideEffect;
1822
use Psr\Log\NullLogger;
1923
use Innmind\BlackBox\{
@@ -70,6 +74,30 @@ public function testSignals()
7074
$this->assertSame($process->signals(), $process->signals());
7175
}
7276

77+
public function testAsyncSignals(): BlackBox\Proof
78+
{
79+
return $this
80+
->forAll(Set::of(...Signal::cases()))
81+
->prove(function($signal) {
82+
$config = Config::new();
83+
$interceptor = Interceptor::new();
84+
$config = $config->handleSignalsVia(
85+
$config->signalsHandler()->async($interceptor),
86+
);
87+
$async = OperatingSystem::new($config);
88+
$called = 0;
89+
$async
90+
->process()
91+
->signals()
92+
->listen($signal, static function() use (&$called) {
93+
++$called;
94+
});
95+
$interceptor->dispatch($signal);
96+
97+
$this->assertSame(1, $called);
98+
});
99+
}
100+
73101
public function testMemory()
74102
{
75103
$process = CurrentProcess::of(

0 commit comments

Comments
 (0)