Skip to content

Commit 86896ef

Browse files
committed
Add test for factory throwing an exception
1 parent 226d704 commit 86896ef

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

tests/React/Promise/LazyPromiseTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,26 @@ public function shouldReturnPromiseIfFactoryReturnsNull()
6363
$p = new LazyPromise($factory);
6464
$this->assertInstanceOf('React\\Promise\\PromiseInterface', $p->then());
6565
}
66+
67+
/** @test */
68+
public function shouldReturnRejectedPromiseIfFactoryThrowsException()
69+
{
70+
$exception = new \Exception();
71+
72+
$factory = $this->createCallableMock();
73+
$factory
74+
->expects($this->once())
75+
->method('__invoke')
76+
->will($this->throwException($exception));
77+
78+
$errorHandler = $this->createCallableMock();
79+
$errorHandler
80+
->expects($this->once())
81+
->method('__invoke')
82+
->with($this->identicalTo($exception));
83+
84+
$p = new LazyPromise($factory);
85+
86+
$p->then($this->expectCallableNever(), $errorHandler);
87+
}
6688
}

0 commit comments

Comments
 (0)