Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ CHANGELOG for 3.x
`some()`, `map()`, `reduce()`) now require an array of promises or values
as input. Before, arrays and promises which resolve to an array were
supported, other input types resolved to empty arrays or `null` (#35).
* BC break: `race()` now returns a forever pending promise when called with
an empty array (#83).
The behavior is now also in line with the ES6 specification.
* BC break: The interfaces `PromiseInterface`, `ExtendedPromiseInterface`
and `CancellablePromiseInterface` have been merged into a single
`PromiseInterface` (#75).
Expand Down
2 changes: 1 addition & 1 deletion src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function all(array $promisesOrValues)
function race(array $promisesOrValues)
{
if (!$promisesOrValues) {
return resolve();
return new Promise(function() {});
}

$cancellationQueue = new Internal\CancellationQueue();
Expand Down
10 changes: 2 additions & 8 deletions tests/FunctionRaceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,11 @@
class FunctionRaceTest extends TestCase
{
/** @test */
public function shouldResolveEmptyInput()
public function shouldReturnForeverPendingPromiseForEmptyInput()
{
$mock = $this->createCallableMock();
$mock
->expects($this->once())
->method('__invoke')
->with($this->identicalTo(null));

race(
[]
)->then($mock);
)->then($this->expectCallableNever(), $this->expectCallableNever());
}

/** @test */
Expand Down