mirror of
https://github.com/danog/amp.git
synced 2024-11-27 04:24:42 +01:00
28 lines
699 B
PHP
28 lines
699 B
PHP
<?php
|
|
|
|
namespace Amp\Test;
|
|
|
|
use Amp\Failure;
|
|
|
|
class FailureTest extends \PHPUnit_Framework_TestCase {
|
|
|
|
public function testWhenInvokedImmediately() {
|
|
$exception = new \Exception('test');
|
|
$failure = new Failure($exception);
|
|
$failure->when(function($error, $result) use ($exception) {
|
|
$this->assertNull($result);
|
|
$this->assertSame($exception, $error);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* @expectedException \RuntimeException
|
|
* @expectedExceptionMessage test
|
|
*/
|
|
public function testWaitThrowsImmediately() {
|
|
$exception = new \RuntimeException('test');
|
|
$failure = new Failure($exception);
|
|
$failure->wait();
|
|
}
|
|
}
|