mirror of
https://github.com/danog/amp.git
synced 2024-11-30 04:29:08 +01:00
29 lines
685 B
PHP
29 lines
685 B
PHP
<?php declare(strict_types = 1);
|
|
|
|
namespace Amp\Test;
|
|
|
|
use Amp;
|
|
use Amp\Pause;
|
|
use Interop\Async\Loop;
|
|
|
|
class PauseTest extends \PHPUnit_Framework_TestCase {
|
|
public function testPause() {
|
|
$time = 100;
|
|
$value = "test";
|
|
$start = microtime(true);
|
|
|
|
Loop::execute(function () use (&$result, $time, $value) {
|
|
$promise = new Pause($time, $value);
|
|
|
|
$callback = function ($exception, $value) use (&$result) {
|
|
$result = $value;
|
|
};
|
|
|
|
$promise->when($callback);
|
|
});
|
|
|
|
$this->assertLessThanOrEqual($time, microtime(true) - $start);
|
|
$this->assertSame($value, $result);
|
|
}
|
|
}
|