1
0
mirror of https://github.com/danog/amp.git synced 2024-11-27 12:35:02 +01:00
amp/test/PauseTest.php

41 lines
980 B
PHP
Raw Normal View History

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