Fixed SyncPromiseAdapter::all() to not change the order of arrays

This commit is contained in:
Bernhard Schussek 2017-02-23 11:45:13 +01:00
parent ed41a4ce43
commit e35b57601d
2 changed files with 8 additions and 7 deletions

View File

@ -96,6 +96,7 @@ class SyncPromiseAdapter implements PromiseAdapter
foreach ($promisesOrValues as $index => $promiseOrValue) { foreach ($promisesOrValues as $index => $promiseOrValue) {
if ($promiseOrValue instanceof Promise) { if ($promiseOrValue instanceof Promise) {
$result[$index] = null;
$promiseOrValue->then( $promiseOrValue->then(
function($value) use ($index, &$count, $total, &$result, $all) { function($value) use ($index, &$count, $total, &$result, $all) {
$result[$index] = $value; $result[$index] = $value;

View File

@ -186,18 +186,18 @@ class SyncPromiseAdapterTest extends \PHPUnit_Framework_TestCase
} }
); );
$this->assertEquals($onFulfilledCalled, false); $this->assertSame($onFulfilledCalled, false);
$this->assertEquals($onRejectedCalled, false); $this->assertSame($onRejectedCalled, false);
SyncPromise::runQueue(); SyncPromise::runQueue();
if ($expectedNextState !== SyncPromise::PENDING) { if ($expectedNextState !== SyncPromise::PENDING) {
$this->assertEquals(!$expectedNextReason, $onFulfilledCalled); $this->assertSame(!$expectedNextReason, $onFulfilledCalled);
$this->assertEquals(!!$expectedNextReason, $onRejectedCalled); $this->assertSame(!!$expectedNextReason, $onRejectedCalled);
} }
$this->assertEquals($expectedNextValue, $actualNextValue); $this->assertSame($expectedNextValue, $actualNextValue);
$this->assertEquals($expectedNextReason, $actualNextReason); $this->assertSame($expectedNextReason, $actualNextReason);
$this->assertEquals($expectedNextState, $promise->adoptedPromise->state); $this->assertSame($expectedNextState, $promise->adoptedPromise->state);
} }
} }