1
0
mirror of https://github.com/danog/amp.git synced 2024-12-04 18:38:17 +01:00
amp/test/Loop/NativeDriverTest.php

46 lines
999 B
PHP
Raw Normal View History

2016-05-27 22:05:25 +02:00
<?php
namespace Amp\Test\Loop;
use Amp\Loop\Driver;
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
{
return function () {
return new NativeDriver;
};
2016-05-27 22:05:25 +02:00
}
2018-06-18 20:00:01 +02:00
public function testHandle()
{
$this->assertNull($this->loop->getHandle());
}
/**
* @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
}