File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ public function __construct(AsyncResource $resource)
3434 public function __clone ()
3535 {
3636 $ this ->asyncResource = clone $ this ->asyncResource ;
37+ // Throttle is not cloned because it most likely wants to be shared between imports.
3738
3839 parent ::__clone ();
3940 }
Original file line number Diff line number Diff line change @@ -198,4 +198,22 @@ public function testPorterAwareAsyncTransformer(): void
198198 )
199199 );
200200 }
201+
202+ /**
203+ * Tests that the throttle is invoked during fetch operations.
204+ */
205+ public function testThrottle (): \Generator
206+ {
207+ $ throttle = $ this ->specification ->getThrottle ();
208+ $ throttle ->setMaxPerSecond (1 );
209+
210+ $ start = microtime (true );
211+
212+ $ records = $ this ->porter ->importAsync ($ this ->specification );
213+ self ::assertTrue ($ throttle ->isThrottling ());
214+
215+ yield $ records ->advance ();
216+ self ::assertFalse ($ throttle ->isThrottling ());
217+ self ::assertGreaterThan (1 , microtime (true ) - $ start );
218+ }
201219}
You can’t perform that action at this time.
0 commit comments