Initial commit
This commit is contained in:
40
tests/Signal/SignalTest.php
Normal file
40
tests/Signal/SignalTest.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace NoccyLabs\Ipc\Signal;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class SignalTest extends \PhpUnit\Framework\TestCase
|
||||
{
|
||||
|
||||
public function testSimpleSignalHandler()
|
||||
{
|
||||
$callback = function () use (&$handler1) { $handler1 = true; };
|
||||
|
||||
$handler = new Signal(SIGUSR1);
|
||||
$handler->setHandler($callback);
|
||||
|
||||
posix_kill(posix_getpid(), SIGUSR1);
|
||||
|
||||
usleep(1000);
|
||||
|
||||
$this->assertEquals(true, $handler1);
|
||||
}
|
||||
|
||||
public function testSimpleSignalDispatcher()
|
||||
{
|
||||
$callback = function () use (&$handler1) { $handler1 = true; };
|
||||
|
||||
$handler = new Signal(SIGUSR1);
|
||||
$handler->setHandler($callback);
|
||||
|
||||
$handler->dispatch(posix_getpid());
|
||||
|
||||
usleep(1000);
|
||||
|
||||
$this->assertEquals(true, $handler1);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user