1
0
mirror of https://github.com/danog/amp.git synced 2025-01-22 13:21:16 +01:00
amp/test/PauseTest.php

29 lines
657 B
PHP
Raw Normal View History

<?php
2015-07-20 22:24:51 -04:00
namespace Amp\Test;
2016-07-19 00:05:40 -05:00
use Amp;
2015-07-20 22:24:51 -04:00
use Amp\Pause;
use AsyncInterop\Loop;
2015-07-20 22:24:51 -04:00
class PauseTest extends \PHPUnit_Framework_TestCase {
2016-07-19 00:05:40 -05:00
public function testPause() {
$time = 100;
$value = "test";
$start = microtime(true);
Loop::execute(function () use (&$result, $time, $value) {
2016-11-14 13:59:21 -06:00
$promise = new Pause($time, $value);
2016-07-19 00:05:40 -05:00
$callback = function ($exception, $value) use (&$result) {
$result = $value;
};
2016-11-14 13:59:21 -06:00
$promise->when($callback);
2015-07-20 22:28:51 -04:00
});
2016-07-19 00:05:40 -05:00
$this->assertLessThanOrEqual($time, microtime(true) - $start);
$this->assertSame($value, $result);
2015-07-20 22:28:51 -04:00
}
2015-07-20 22:24:51 -04:00
}