3
namespace React\Promise;
5
use React\Promise\PromiseAdapter\CallbackPromiseAdapter;
7
class FulfilledPromiseTest extends TestCase
9
use PromiseTest\PromiseSettledTestTrait,
10
PromiseTest\PromiseFulfilledTestTrait;
12
public function getPromiseTestAdapter(callable $canceller = null)
16
return new CallbackPromiseAdapter([
17
'promise' => function () use (&$promise) {
19
throw new \LogicException('FulfilledPromise must be resolved before obtaining the promise');
24
'resolve' => function ($value = null) use (&$promise) {
26
$promise = new FulfilledPromise($value);
29
'reject' => function () {
30
throw new \LogicException('You cannot call reject() for React\Promise\FulfilledPromise');
32
'notify' => function () {
35
'settle' => function ($value = null) use (&$promise) {
37
$promise = new FulfilledPromise($value);
44
public function shouldThrowExceptionIfConstructedWithAPromise()
46
$this->setExpectedException('\InvalidArgumentException');
48
return new FulfilledPromise(new FulfilledPromise());
52
public function shouldNotLeaveGarbageCyclesWhenRemovingLastReferenceToFulfilledPromiseWithAlwaysFollowers()
55
$promise = new FulfilledPromise(1);
56
$promise->always(function () {
57
throw new \RuntimeException();
61
$this->assertSame(0, gc_collect_cycles());
65
public function shouldNotLeaveGarbageCyclesWhenRemovingLastReferenceToFulfilledPromiseWithThenFollowers()
68
$promise = new FulfilledPromise(1);
69
$promise = $promise->then(function () {
70
throw new \RuntimeException();
74
$this->assertSame(0, gc_collect_cycles());