2016-05-27 22:05:25 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Amp\Test\Loop;
|
|
|
|
|
2019-02-26 01:05:47 +01:00
|
|
|
use Amp\Loop\Driver;
|
2017-03-12 11:21:44 +01:00
|
|
|
use Amp\Loop\NativeDriver;
|
2016-05-27 22:05:25 +02:00
|
|
|
|
2018-06-18 20:00:01 +02:00
|
|
|
class NativeDriverTest extends DriverTest
|
|
|
|
{
|
|
|
|
public function getFactory(): callable
|
|
|
|
{
|
2017-03-10 21:31:57 +01:00
|
|
|
return function () {
|
2017-03-12 11:21:44 +01:00
|
|
|
return new NativeDriver;
|
2017-03-10 21:31:57 +01:00
|
|
|
};
|
2016-05-27 22:05:25 +02:00
|
|
|
}
|
2017-03-13 13:56:46 +01:00
|
|
|
|
2018-06-18 20:00:01 +02:00
|
|
|
public function testHandle()
|
|
|
|
{
|
2017-03-13 13:56:46 +01:00
|
|
|
$this->assertNull($this->loop->getHandle());
|
|
|
|
}
|
2019-02-26 01:05:47 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @requires PHP 7.1
|
|
|
|
*/
|
|
|
|
public function testAsyncSignals()
|
|
|
|
{
|
|
|
|
\pcntl_async_signals(true);
|
|
|
|
|
|
|
|
try {
|
|
|
|
$this->start(function (Driver $loop) use (&$invoked) {
|
|
|
|
$watcher = $loop->onSignal(SIGUSR1, function () use (&$invoked) {
|
|
|
|
$invoked = true;
|
|
|
|
});
|
|
|
|
$loop->unreference($watcher);
|
|
|
|
$loop->defer(function () {
|
|
|
|
\posix_kill(\getmypid(), \SIGUSR1);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} finally {
|
|
|
|
\pcntl_async_signals(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->assertTrue($invoked);
|
|
|
|
}
|
2016-05-27 22:05:25 +02:00
|
|
|
}
|