mirror of
https://github.com/danog/amp.git
synced 2024-12-02 17:37:50 +01:00
37 lines
961 B
PHP
37 lines
961 B
PHP
<?php
|
|
|
|
namespace Amp\Test;
|
|
|
|
use Amp\Pause;
|
|
use Amp\NativeReactor;
|
|
|
|
class PauseTest extends \PHPUnit_Framework_TestCase {
|
|
/**
|
|
* @dataProvider provideBadMillisecondArgs
|
|
* @expectedException \DomainException
|
|
* @expectedExceptionMessage Pause timeout must be greater than or equal to 1 millisecond
|
|
*/
|
|
public function testCtorThrowsOnBadMillisecondParam($arg) {
|
|
(new NativeReactor)->run(function ($reactor) use ($arg) {
|
|
new Pause($arg, $reactor);
|
|
});
|
|
}
|
|
|
|
public function provideBadMillisecondArgs() {
|
|
return [
|
|
[0],
|
|
[-1],
|
|
];
|
|
}
|
|
|
|
public function testPauseYield() {
|
|
$endReached = false;
|
|
(new NativeReactor)->run(function ($reactor) use (&$endReached) {
|
|
$result = (yield new Pause(1, $reactor));
|
|
$this->assertNull($result);
|
|
$endReached = true;
|
|
});
|
|
$this->assertTrue($endReached);
|
|
}
|
|
}
|