File tree Expand file tree Collapse file tree 6 files changed +17
-20
lines changed
Expand file tree Collapse file tree 6 files changed +17
-20
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ language: php
88php :
99 - 7.1
1010 - 7.2
11+ - 7.3
1112
1213env :
1314 matrix :
Original file line number Diff line number Diff line change 1818 "psr/cache" : " ^1"
1919 },
2020 "require-dev" : {
21+ "amphp/phpunit-util" : " ^1.1" ,
2122 "phpunit/phpunit" : " ^7.1.3" ,
2223 "mockery/mockery" : " ^1.1"
2324 },
Original file line number Diff line number Diff line change 33
44namespace ScriptFUSION \Porter \Connector ;
55
6+ use Amp \Promise ;
7+
68/**
79 * Provides a method for fetching data from a remote source asynchronously.
810 */
@@ -13,7 +15,7 @@ interface AsyncConnector
1315 *
1416 * @param string $source Source.
1517 *
16- * @return mixed Async generator function or any return value compatible with Amp\call .
18+ * @return Promise Fetched data .
1719 */
18- public function fetchAsync (string $ source );
20+ public function fetchAsync (string $ source ): Promise ;
1921}
Original file line number Diff line number Diff line change 88use ScriptFUSION \Porter \Connector \Recoverable \RecoverableException ;
99use ScriptFUSION \Porter \Connector \Recoverable \RecoverableExceptionHandler ;
1010use ScriptFUSION \Porter \Connector \Recoverable \StatelessRecoverableExceptionHandler ;
11- use function Amp \call ;
1211use function Amp \Promise \all ;
1312use function ScriptFUSION \Retry \retry ;
1413use function ScriptFUSION \Retry \retryAsync ;
@@ -83,11 +82,7 @@ public function fetchAsync(string $source): Promise
8382 return retryAsync (
8483 $ this ->maxFetchAttempts ,
8584 function () use ($ source ): Promise {
86- return call (
87- function () use ($ source ) {
88- return $ this ->connector ->fetchAsync ($ source );
89- }
90- );
85+ return $ this ->connector ->fetchAsync ($ source );
9186 },
9287 $ this ->createExceptionHandler ()
9388 );
Original file line number Diff line number Diff line change @@ -22,21 +22,17 @@ protected function setUp(): void
2222 $ this ->specification = new AsyncImportSpecification ($ this ->resource );
2323 }
2424
25- public function testImportAsync (): void
25+ public function testImportAsync (): \ Generator
2626 {
27- Loop::run (function () {
28- $ records = $ this ->porter ->importAsync ($ this ->specification );
27+ $ records = $ this ->porter ->importAsync ($ this ->specification );
2928
30- self ::assertTrue (yield $ records ->advance ());
31- self ::assertSame (['foo ' ], $ records ->getCurrent ());
32- });
29+ self ::assertTrue (yield $ records ->advance ());
30+ self ::assertSame (['foo ' ], $ records ->getCurrent ());
3331 }
3432
35- public function testImportOneAsync (): void
33+ public function testImportOneAsync (): \ Generator
3634 {
37- Loop::run (function () {
38- self ::assertSame (['foo ' ], yield $ this ->porter ->importOneAsync ($ this ->specification ));
39- });
35+ self ::assertSame (['foo ' ], yield $ this ->porter ->importOneAsync ($ this ->specification ));
4036 }
4137
4238 /**
Original file line number Diff line number Diff line change 33
44namespace ScriptFUSIONTest \Integration \Porter ;
55
6+ use Amp \PHPUnit \AsyncTestCase ;
67use Mockery \Adapter \Phpunit \MockeryPHPUnitIntegration ;
78use Mockery \MockInterface ;
8- use PHPUnit \Framework \TestCase ;
99use Psr \Container \ContainerInterface ;
1010use ScriptFUSION \Porter \Connector \AsyncConnector ;
1111use ScriptFUSION \Porter \Connector \Connector ;
1818use ScriptFUSION \Porter \Specification \ImportSpecification ;
1919use ScriptFUSIONTest \MockFactory ;
2020
21- abstract class PorterTest extends TestCase
21+ abstract class PorterTest extends AsyncTestCase
2222{
2323 use MockeryPHPUnitIntegration;
2424
@@ -54,6 +54,8 @@ abstract class PorterTest extends TestCase
5454
5555 protected function setUp (): void
5656 {
57+ parent ::setUp ();
58+
5759 $ this ->porter = new Porter ($ this ->container = \Mockery::spy (ContainerInterface::class));
5860
5961 $ this ->registerProvider ($ this ->provider = MockFactory::mockProvider ());
You can’t perform that action at this time.
0 commit comments