2014-09-22 22:47:48 +02:00
|
|
|
<?php
|
|
|
|
|
2014-09-23 04:38:32 +02:00
|
|
|
namespace Amp\Test;
|
2014-09-22 22:47:48 +02:00
|
|
|
|
2014-09-23 04:38:32 +02:00
|
|
|
use Amp\Success;
|
2014-09-22 22:47:48 +02:00
|
|
|
|
|
|
|
class SuccessTest extends \PHPUnit_Framework_TestCase {
|
|
|
|
|
|
|
|
public function testWhenInvokedImmediately() {
|
|
|
|
$value = 42;
|
|
|
|
$success = new Success($value);
|
|
|
|
$success->when(function($error, $result) use ($value) {
|
|
|
|
$this->assertNull($error);
|
|
|
|
$this->assertSame($value, $result);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testWaitReturnsResolvedValue() {
|
|
|
|
$value = 42;
|
|
|
|
$success = new Success($value);
|
|
|
|
$this->assertSame($value, $success->wait());
|
|
|
|
}
|
|
|
|
}
|