Definition at line 5 of file PromiseTest.php.
◆ testAll()
Sabre\Event\PromiseTest::testAll |
( |
| ) |
|
Definition at line 196 of file PromiseTest.php.
References Sabre\Event\Promise\all(), and Sabre\Event\Loop\run().
198 $promise1 =
new Promise();
199 $promise2 =
new Promise();
202 Promise::all([$promise1, $promise2])->then(
function($value) use (&$finalValue) {
204 $finalValue = $value;
208 $promise1->fulfill(1);
210 $this->assertEquals(0, $finalValue);
212 $promise2->fulfill(2);
214 $this->assertEquals([1, 2], $finalValue);
static all(array $promises)
Deprecated.
◆ testAllReject()
Sabre\Event\PromiseTest::testAllReject |
( |
| ) |
|
Definition at line 218 of file PromiseTest.php.
References Sabre\Event\Promise\all(), and Sabre\Event\Loop\run().
220 $promise1 =
new Promise();
221 $promise2 =
new Promise();
225 function($value) use (&$finalValue) {
229 function($value) use (&$finalValue) {
230 $finalValue = $value;
234 $promise1->reject(1);
236 $this->assertEquals(1, $finalValue);
237 $promise2->reject(2);
239 $this->assertEquals(1, $finalValue);
static all(array $promises)
Deprecated.
◆ testAllRejectThenResolve()
Sabre\Event\PromiseTest::testAllRejectThenResolve |
( |
| ) |
|
Definition at line 243 of file PromiseTest.php.
References Sabre\Event\Promise\all(), and Sabre\Event\Loop\run().
245 $promise1 =
new Promise();
246 $promise2 =
new Promise();
250 function($value) use (&$finalValue) {
254 function($value) use (&$finalValue) {
255 $finalValue = $value;
259 $promise1->reject(1);
261 $this->assertEquals(1, $finalValue);
262 $promise2->fulfill(2);
264 $this->assertEquals(1, $finalValue);
static all(array $promises)
Deprecated.
◆ testChain()
Sabre\Event\PromiseTest::testChain |
( |
| ) |
|
Definition at line 37 of file PromiseTest.php.
References $promise, and Sabre\Event\Loop\run().
43 $promise->then(
function($value) use (&$finalValue) {
44 $finalValue = $value + 2;
46 })->then(
function($value) use (&$finalValue) {
47 $finalValue = $value + 4;
52 $this->assertEquals(7, $finalValue);
$promise
This example shows demonstrates the Promise api.
◆ testChainPromise()
Sabre\Event\PromiseTest::testChainPromise |
( |
| ) |
|
Definition at line 55 of file PromiseTest.php.
References $promise, and Sabre\Event\Loop\run().
61 $subPromise =
new Promise();
63 $promise->then(
function($value) use ($subPromise) {
65 })->then(
function($value) use (&$finalValue) {
66 $finalValue = $value + 4;
70 $subPromise->fulfill(2);
73 $this->assertEquals(6, $finalValue);
$promise
This example shows demonstrates the Promise api.
◆ testExecutorFail()
Sabre\Event\PromiseTest::testExecutorFail |
( |
| ) |
|
Definition at line 126 of file PromiseTest.php.
References $promise, $result, $success, and Sabre\Event\Loop\run().
132 }))->then(
function(
$result) use (&$realResult) {
134 $realResult =
'incorrect';
136 },
function($reason) use (&$realResult) {
138 $realResult = $reason;
143 $this->assertEquals(
'hi', $realResult);
$promise
This example shows demonstrates the Promise api.
◆ testExecutorSuccess()
Sabre\Event\PromiseTest::testExecutorSuccess |
( |
| ) |
|
◆ testFail()
Sabre\Event\PromiseTest::testFail |
( |
| ) |
|
Definition at line 22 of file PromiseTest.php.
References $promise, and Sabre\Event\Loop\run().
28 $promise->then(null,
function($value) use (&$finalValue) {
29 $finalValue = $value + 2;
33 $this->assertEquals(3, $finalValue);
$promise
This example shows demonstrates the Promise api.
◆ testFromFailureHandler()
Sabre\Event\PromiseTest::testFromFailureHandler |
( |
| ) |
|
Definition at line 169 of file PromiseTest.php.
References $ok, $promise, and Sabre\Event\Loop\run().
173 $promise->otherwise(
function($reason) {
175 $this->assertEquals(
'foo', $reason);
176 throw new \Exception(
'hi');
178 })->then(
function() use (&
$ok) {
182 },
function() use (&
$ok) {
188 $this->assertEquals(0,
$ok);
192 $this->assertEquals(1,
$ok);
$promise
This example shows demonstrates the Promise api.
◆ testFulfillTwice()
Sabre\Event\PromiseTest::testFulfillTwice |
( |
| ) |
|
◆ testPendingFail()
Sabre\Event\PromiseTest::testPendingFail |
( |
| ) |
|
Definition at line 93 of file PromiseTest.php.
References $promise, and Sabre\Event\Loop\run().
98 $promise->then(null,
function($value) use (&$finalValue) {
99 $finalValue = $value + 2;
105 $this->assertEquals(6, $finalValue);
$promise
This example shows demonstrates the Promise api.
◆ testPendingResult()
Sabre\Event\PromiseTest::testPendingResult |
( |
| ) |
|
Definition at line 77 of file PromiseTest.php.
References $promise, and Sabre\Event\Loop\run().
82 $promise->then(
function($value) use (&$finalValue) {
83 $finalValue = $value + 2;
89 $this->assertEquals(6, $finalValue);
$promise
This example shows demonstrates the Promise api.
◆ testRace()
Sabre\Event\PromiseTest::testRace |
( |
| ) |
|
Definition at line 268 of file PromiseTest.php.
References Sabre\Event\Promise\race(), and Sabre\Event\Loop\run().
270 $promise1 =
new Promise();
271 $promise2 =
new Promise();
275 function($value) use (&$finalValue) {
276 $finalValue = $value;
278 function($value) use (&$finalValue) {
279 $finalValue = $value;
283 $promise1->fulfill(1);
285 $this->assertEquals(1, $finalValue);
286 $promise2->fulfill(2);
288 $this->assertEquals(1, $finalValue);
race(array $promises)
The race function returns a promise that resolves or rejects as soon as one of the promises in the ar...
◆ testRaceReject()
Sabre\Event\PromiseTest::testRaceReject |
( |
| ) |
|
Definition at line 292 of file PromiseTest.php.
References Sabre\Event\Promise\race(), and Sabre\Event\Loop\run().
294 $promise1 =
new Promise();
295 $promise2 =
new Promise();
299 function($value) use (&$finalValue) {
300 $finalValue = $value;
302 function($value) use (&$finalValue) {
303 $finalValue = $value;
307 $promise1->reject(1);
309 $this->assertEquals(1, $finalValue);
310 $promise2->reject(2);
312 $this->assertEquals(1, $finalValue);
race(array $promises)
The race function returns a promise that resolves or rejects as soon as one of the promises in the ar...
◆ testRejectTwice()
Sabre\Event\PromiseTest::testRejectTwice |
( |
| ) |
|
◆ testSuccess()
Sabre\Event\PromiseTest::testSuccess |
( |
| ) |
|
Definition at line 7 of file PromiseTest.php.
References $promise, and Sabre\Event\Loop\run().
13 $promise->then(
function($value) use (&$finalValue) {
14 $finalValue = $value + 2;
18 $this->assertEquals(3, $finalValue);
$promise
This example shows demonstrates the Promise api.
◆ testWaitRejectedException()
Sabre\Event\PromiseTest::testWaitRejectedException |
( |
| ) |
|
Definition at line 339 of file PromiseTest.php.
References $promise, and Sabre\Event\Loop\nextTick().
343 $promise->reject(
new \OutOfBoundsException(
'foo'));
347 $this->fail(
'We did not get the expected exception');
349 $this->assertInstanceOf(
'OutOfBoundsException', $e);
350 $this->assertEquals(
'foo', $e->getMessage());
$promise
This example shows demonstrates the Promise api.
nextTick(callable $cb)
Runs a function immediately at the next iteration of the loop.
◆ testWaitRejectedNonScalar()
Sabre\Event\PromiseTest::testWaitRejectedNonScalar |
( |
| ) |
|
Definition at line 371 of file PromiseTest.php.
References $promise, and Sabre\Event\Loop\nextTick().
379 $this->fail(
'We did not get the expected exception');
381 $this->assertInstanceOf(
'Exception', $e);
382 $this->assertEquals(
'Promise was rejected with reason of type: array', $e->getMessage());
$promise
This example shows demonstrates the Promise api.
nextTick(callable $cb)
Runs a function immediately at the next iteration of the loop.
◆ testWaitRejectedScalar()
Sabre\Event\PromiseTest::testWaitRejectedScalar |
( |
| ) |
|
Definition at line 355 of file PromiseTest.php.
References $promise, and Sabre\Event\Loop\nextTick().
363 $this->fail(
'We did not get the expected exception');
365 $this->assertInstanceOf(
'Exception', $e);
366 $this->assertEquals(
'foo', $e->getMessage());
$promise
This example shows demonstrates the Promise api.
nextTick(callable $cb)
Runs a function immediately at the next iteration of the loop.
◆ testWaitResolve()
Sabre\Event\PromiseTest::testWaitResolve |
( |
| ) |
|
◆ testWaitWillNeverResolve()
Sabre\Event\PromiseTest::testWaitWillNeverResolve |
( |
| ) |
|
The documentation for this class was generated from the following file: