1
0
mirror of https://github.com/danog/amp.git synced 2024-11-30 04:29:08 +01:00
amp/test/FailureTest.php

32 lines
669 B
PHP
Raw Normal View History

<?php
2016-07-12 18:20:06 +02:00
namespace Amp\Test;
use Amp\Failure;
class FailureTest extends \PHPUnit_Framework_TestCase {
/**
2016-08-11 21:35:58 +02:00
* @expectedException \TypeError
2016-07-12 18:20:06 +02:00
*/
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);
}
}