66use React \EventLoop \Loop ;
77use React \Promise ;
88use React \Promise \Deferred ;
9- use React \Promise \Timer \TimeoutException ;
109
1110class AwaitTest extends TestCase
1211{
@@ -93,40 +92,6 @@ public function testAwaitOneInterrupted()
9392 $ this ->assertEquals (2 , React \Async \await ($ promise , $ this ->loop ));
9493 }
9594
96- public function testAwaitOncePendingWillThrowOnTimeout ()
97- {
98- $ promise = new Promise \Promise (function () { });
99-
100- $ this ->setExpectedException ('React\Promise\Timer\TimeoutException ' );
101- React \Async \await ($ promise , $ this ->loop , 0.001 );
102- }
103-
104- public function testAwaitOncePendingWillThrowAndCallCancellerOnTimeout ()
105- {
106- $ cancelled = false ;
107- $ promise = new Promise \Promise (function () { }, function () use (&$ cancelled ) {
108- $ cancelled = true ;
109- });
110-
111- try {
112- React \Async \await ($ promise , $ this ->loop , 0.001 );
113- } catch (TimeoutException $ expected ) {
114- $ this ->assertTrue ($ cancelled );
115- }
116- }
117-
118- public function testAwaitOnceWithTimeoutWillResolvemmediatelyAndCleanUpTimeout ()
119- {
120- $ promise = Promise \resolve (true );
121-
122- $ time = microtime (true );
123- React \Async \await ($ promise , $ this ->loop , 5.0 );
124- $ this ->loop ->run ();
125- $ time = microtime (true ) - $ time ;
126-
127- $ this ->assertLessThan (0.1 , $ time );
128- }
129-
13095 public function testAwaitOneResolvesShouldNotCreateAnyGarbageReferences ()
13196 {
13297 if (class_exists ('React\Promise\When ' ) && PHP_VERSION_ID >= 50400 ) {
@@ -161,25 +126,6 @@ public function testAwaitOneRejectedShouldNotCreateAnyGarbageReferences()
161126 $ this ->assertEquals (0 , gc_collect_cycles ());
162127 }
163128
164- public function testAwaitOneRejectedWithTimeoutShouldNotCreateAnyGarbageReferences ()
165- {
166- if (class_exists ('React\Promise\When ' ) && PHP_VERSION_ID >= 50400 ) {
167- $ this ->markTestSkipped ('Not supported on legacy Promise v1 API with PHP 5.4+ ' );
168- }
169-
170- gc_collect_cycles ();
171-
172- $ promise = Promise \reject (new \RuntimeException ());
173- try {
174- React \Async \await ($ promise , $ this ->loop , 0.001 );
175- } catch (\Exception $ e ) {
176- // no-op
177- }
178- unset($ promise , $ e );
179-
180- $ this ->assertEquals (0 , gc_collect_cycles ());
181- }
182-
183129 public function testAwaitNullValueShouldNotCreateAnyGarbageReferences ()
184130 {
185131 if (!interface_exists ('React\Promise\CancellablePromiseInterface ' )) {
@@ -203,68 +149,6 @@ public function testAwaitNullValueShouldNotCreateAnyGarbageReferences()
203149 $ this ->assertEquals (0 , gc_collect_cycles ());
204150 }
205151
206- /**
207- * @requires PHP 7
208- */
209- public function testAwaitPendingPromiseWithTimeoutAndCancellerShouldNotCreateAnyGarbageReferences ()
210- {
211- if (class_exists ('React\Promise\When ' )) {
212- $ this ->markTestSkipped ('Not supported on legacy Promise v1 API ' );
213- }
214-
215- gc_collect_cycles ();
216-
217- $ promise = new \React \Promise \Promise (function () { }, function () {
218- throw new \RuntimeException ();
219- });
220- try {
221- React \Async \await ($ promise , $ this ->loop , 0.001 );
222- } catch (\Exception $ e ) {
223- // no-op
224- }
225- unset($ promise , $ e );
226-
227- $ this ->assertEquals (0 , gc_collect_cycles ());
228- }
229-
230- /**
231- * @requires PHP 7
232- */
233- public function testAwaitPendingPromiseWithTimeoutAndWithoutCancellerShouldNotCreateAnyGarbageReferences ()
234- {
235- gc_collect_cycles ();
236-
237- $ promise = new \React \Promise \Promise (function () { });
238- try {
239- React \Async \await ($ promise , $ this ->loop , 0.001 );
240- } catch (\Exception $ e ) {
241- // no-op
242- }
243- unset($ promise , $ e );
244-
245- $ this ->assertEquals (0 , gc_collect_cycles ());
246- }
247-
248- /**
249- * @requires PHP 7
250- */
251- public function testAwaitPendingPromiseWithTimeoutAndNoOpCancellerShouldNotCreateAnyGarbageReferences ()
252- {
253- gc_collect_cycles ();
254-
255- $ promise = new \React \Promise \Promise (function () { }, function () {
256- // no-op
257- });
258- try {
259- React \Async \await ($ promise , $ this ->loop , 0.001 );
260- } catch (\Exception $ e ) {
261- // no-op
262- }
263- unset($ promise , $ e );
264-
265- $ this ->assertEquals (0 , gc_collect_cycles ());
266- }
267-
268152 protected function createPromiseResolved ($ value = null , $ delay = 0.01 )
269153 {
270154 $ deferred = new Deferred ();
0 commit comments