1
0
mirror of https://github.com/danog/amp.git synced 2025-01-22 05:11:42 +01:00
amp/test/PauseTest.php
2015-07-29 16:59:53 -04:00

41 lines
980 B
PHP

<?php
namespace Amp\Test;
use Amp\Pause;
use Amp\NativeReactor;
class PauseTest extends \PHPUnit_Framework_TestCase {
protected function setUp() {
\Amp\reactor($assign = new NativeReactor);
}
/**
* @dataProvider provideBadMillisecondArgs
* @expectedException \DomainException
* @expectedExceptionMessage Pause timeout must be greater than or equal to 1 millisecond
*/
public function testCtorThrowsOnBadMillisecondParam($arg) {
\Amp\run(function () use ($arg) {
new Pause($arg);
});
}
public function provideBadMillisecondArgs() {
return [
[0],
[-1],
];
}
public function testPauseYield() {
$endReached = false;
\Amp\run(function () use (&$endReached) {
$result = (yield new Pause(1));
$this->assertNull($result);
$endReached = true;
});
$this->assertTrue($endReached);
}
}