-
-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Throw when end of chain has been reached
- Loading branch information
1 parent
6019855
commit b615618
Showing
12 changed files
with
165 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
namespace React\Promise\PromiseTest; | ||
|
||
use React\Promise\PromiseAdapter\PromiseAdapterInterface; | ||
|
||
trait PromiseLastInChainTestTrait | ||
{ | ||
/** | ||
* @return PromiseAdapterInterface | ||
*/ | ||
abstract public function getPromiseTestAdapter(callable $canceller = null); | ||
|
||
/** @test */ | ||
public function notResolvedOrNotRejectedPromiseShouldNoThrow() | ||
{ | ||
$adapter = $this->getPromiseTestAdapter(); | ||
|
||
$adapter->promise()->then(); | ||
|
||
self::assertTrue(true); | ||
} | ||
|
||
/** @test */ | ||
public function unresolvedOrRejectedPromiseShouldNoThrow() | ||
{ | ||
$adapter = $this->getPromiseTestAdapter(); | ||
|
||
$adapter->resolve(true); | ||
|
||
self::assertTrue(true); | ||
} | ||
|
||
/** @test */ | ||
public function throwWhenLastInChainWhenRejected() | ||
{ | ||
$this->expectException(\Exception::class); | ||
|
||
$adapter = $this->getPromiseTestAdapter(); | ||
|
||
$adapter->reject(new \Exception('Boom!')); | ||
} | ||
|
||
/** @test */ | ||
public function doNotThrowWhenLastInChainWhenRejectedAndTheRejectionIsHandled() | ||
{ | ||
$caught = false; | ||
$adapter = $this->getPromiseTestAdapter(); | ||
|
||
$adapter->promise()->catch(static function () use (&$caught) { | ||
$caught = true; | ||
}); | ||
$adapter->reject(new \Exception('Boom!')); | ||
self::assertTrue($caught); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.