Skip to content

Commit

Permalink
Merge pull request #92 from webmozart/sync-promise-adapter-indices
Browse files Browse the repository at this point in the history
Fixed SyncPromiseAdapter::all() to not change the order of arrays
  • Loading branch information
vladar authored Feb 23, 2017
2 parents ed41a4c + e35b576 commit dd4acfd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/Executor/Promise/Adapter/SyncPromiseAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public function all(array $promisesOrValues)

foreach ($promisesOrValues as $index => $promiseOrValue) {
if ($promiseOrValue instanceof Promise) {
$result[$index] = null;
$promiseOrValue->then(
function($value) use ($index, &$count, $total, &$result, $all) {
$result[$index] = $value;
Expand Down
14 changes: 7 additions & 7 deletions tests/Executor/Promise/SyncPromiseAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,18 +186,18 @@ function(\Exception $reason) use (&$actualNextReason, &$onRejectedCalled) {
}
);

$this->assertEquals($onFulfilledCalled, false);
$this->assertEquals($onRejectedCalled, false);
$this->assertSame($onFulfilledCalled, false);
$this->assertSame($onRejectedCalled, false);

SyncPromise::runQueue();

if ($expectedNextState !== SyncPromise::PENDING) {
$this->assertEquals(!$expectedNextReason, $onFulfilledCalled);
$this->assertEquals(!!$expectedNextReason, $onRejectedCalled);
$this->assertSame(!$expectedNextReason, $onFulfilledCalled);
$this->assertSame(!!$expectedNextReason, $onRejectedCalled);
}

$this->assertEquals($expectedNextValue, $actualNextValue);
$this->assertEquals($expectedNextReason, $actualNextReason);
$this->assertEquals($expectedNextState, $promise->adoptedPromise->state);
$this->assertSame($expectedNextValue, $actualNextValue);
$this->assertSame($expectedNextReason, $actualNextReason);
$this->assertSame($expectedNextState, $promise->adoptedPromise->state);
}
}

0 comments on commit dd4acfd

Please sign in to comment.