mirror of
https://github.com/danog/amp.git
synced 2024-11-26 20:15:00 +01:00
fe88413a17
This commit removes Humbug, as it's no longer maintained and not compatible with PHPUnit 6.
32 lines
669 B
PHP
32 lines
669 B
PHP
<?php
|
|
|
|
namespace Amp\Test;
|
|
|
|
use Amp\Failure;
|
|
|
|
class FailureTest extends \PHPUnit\Framework\TestCase {
|
|
/**
|
|
* @expectedException \TypeError
|
|
*/
|
|
public function testConstructWithNonException() {
|
|
$failure = new Failure(1);
|
|
}
|
|
|
|
public function testWhen() {
|
|
$exception = new \Exception;
|
|
|
|
$invoked = 0;
|
|
$callback = function ($exception, $value) use (&$invoked, &$reason) {
|
|
++$invoked;
|
|
$reason = $exception;
|
|
};
|
|
|
|
$success = new Failure($exception);
|
|
|
|
$success->when($callback);
|
|
|
|
$this->assertSame(1, $invoked);
|
|
$this->assertSame($exception, $reason);
|
|
}
|
|
}
|