44use Amp \Delayed ;
55use Amp \Promise ;
66use Amp \Success ;
7+ use PHPUnit \Framework \TestCase ;
78use ScriptFUSION \Retry \FailingTooHardException ;
9+ use function Amp \Promise \wait ;
10+ use function ScriptFUSION \Retry \retryAsync ;
811
9- final class RetryAsyncTest extends \PHPUnit_Framework_TestCase
12+ final class RetryAsyncTest extends TestCase
1013{
1114 /**
1215 * Tests that a successful promise is returned without retrying.
@@ -15,8 +18,8 @@ public function testWithoutFailingAsync()
1518 {
1619 $ invocations = 0 ;
1720
18- $ value = \ Amp \ Promise \ wait (
19- \ ScriptFUSION \ Retry \ retryAsync ($ tries = 1 , static function () use (&$ invocations ) {
21+ $ value = wait (
22+ retryAsync ($ tries = 1 , static function () use (&$ invocations ) {
2023 ++$ invocations ;
2124
2225 return new Delayed (0 , 'foo ' );
@@ -35,8 +38,8 @@ public function testFailingOnceAsync()
3538 $ invocations = 0 ;
3639 $ failed = false ;
3740
38- $ value = \ Amp \ Promise \ wait (
39- \ ScriptFUSION \ Retry \ retryAsync ($ tries = 2 , static function () use (&$ invocations , &$ failed ) {
41+ $ value = wait (
42+ retryAsync ($ tries = 2 , static function () use (&$ invocations , &$ failed ) {
4043 ++$ invocations ;
4144
4245 if (!$ failed ) {
@@ -61,8 +64,8 @@ public function testZeroTriesAsync()
6164 {
6265 $ invocations = 0 ;
6366
64- $ value = \ Amp \ Promise \ wait (
65- \ ScriptFUSION \ Retry \ retryAsync ($ tries = 0 , static function () use (&$ invocations ) {
67+ $ value = wait (
68+ retryAsync ($ tries = 0 , static function () use (&$ invocations ) {
6669 ++$ invocations ;
6770
6871 return new Delayed (0 , 'foo ' );
@@ -82,7 +85,7 @@ public function testFailingTooHardAsync()
8285 $ outerException = $ innerException = null ;
8386
8487 try {
85- \ ScriptFUSION \ Retry \ retryAsync ($ tries = 3 , static function () use (&$ invocations , &$ innerException ) {
88+ retryAsync ($ tries = 3 , static function () use (&$ invocations , &$ innerException ) {
8689 ++$ invocations ;
8790
8891 throw $ innerException = new \RuntimeException ;
@@ -104,7 +107,7 @@ public function testErrorCallbackAsync()
104107 $ outerException = $ innerException = null ;
105108
106109 try {
107- \ ScriptFUSION \ Retry \ retryAsync ($ tries = 2 , static function () use (&$ invocations , &$ innerException ) {
110+ retryAsync ($ tries = 2 , static function () use (&$ invocations , &$ innerException ) {
108111 ++$ invocations ;
109112
110113 throw $ innerException = new \RuntimeException ;
@@ -132,8 +135,8 @@ public function testPromiseErrorCallback()
132135 $ start = microtime (true );
133136
134137 try {
135- \ Amp \ Promise \ wait (
136- \ ScriptFUSION \ Retry \ retryAsync ($ tries = 3 , static function () {
138+ wait (
139+ retryAsync ($ tries = 3 , static function () {
137140 throw new \DomainException ;
138141 }, static function () use ($ delay ): Promise {
139142 return new Delayed ($ delay );
@@ -154,7 +157,7 @@ public function testErrorCallbackHaltAsync()
154157 {
155158 $ invocations = 0 ;
156159
157- \ ScriptFUSION \ Retry \ retryAsync (2 , static function () use (&$ invocations ) {
160+ retryAsync (2 , static function () use (&$ invocations ) {
158161 ++$ invocations ;
159162
160163 throw new \RuntimeException ;
@@ -172,7 +175,7 @@ public function testPromiseErrorCallbackHaltAsync()
172175 {
173176 $ invocations = 0 ;
174177
175- \ ScriptFUSION \ Retry \ retryAsync (2 , static function () use (&$ invocations ) {
178+ retryAsync (2 , static function () use (&$ invocations ) {
176179 ++$ invocations ;
177180
178181 throw new \RuntimeException ;
@@ -188,9 +191,9 @@ public function testPromiseErrorCallbackHaltAsync()
188191 */
189192 public function testErrorCallbackCanThrow ()
190193 {
191- $ this ->setExpectedException (\LogicException::class);
194+ $ this ->expectException (\LogicException::class);
192195
193- \ ScriptFUSION \ Retry \ retryAsync (2 , static function () {
196+ retryAsync (2 , static function () {
194197 throw new \RuntimeException ;
195198 }, static function () {
196199 throw new \LogicException ;
0 commit comments