File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33namespace Clue \React \Ami ;
44
55use React \EventLoop \LoopInterface ;
6+ use React \SocketClient \ConnectorInterface ;
67use React \SocketClient \Connector ;
78use React \SocketClient \SecureConnector ;
89use React \Dns \Resolver \Factory as ResolverFactory ;
@@ -15,7 +16,7 @@ class Factory
1516 private $ connector ;
1617 private $ secureConnector ;
1718
18- public function __construct (LoopInterface $ loop , Connector $ connector = null , SecureConnector $ secureConnector = null )
19+ public function __construct (LoopInterface $ loop , ConnectorInterface $ connector = null , ConnectorInterface $ secureConnector = null )
1920 {
2021 if ($ connector === null ) {
2122 $ resolverFactory = new ResolverFactory ();
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ use Clue \React \Ami \Factory ;
4+ use React \Promise \Promise ;
5+ class FactoryTest extends TestCase
6+ {
7+ private $ loop ;
8+ private $ tcp ;
9+ private $ tls ;
10+ private $ factory ;
11+
12+ public function setUp ()
13+ {
14+ $ this ->loop = $ this ->getMockBuilder ('React\EventLoop\LoopInterface ' )->getMock ();
15+ $ this ->tcp = $ this ->getMockBuilder ('React\SocketClient\ConnectorInterface ' )->getMock ();
16+ $ this ->tls = $ this ->getMockBuilder ('React\SocketClient\ConnectorInterface ' )->getMock ();
17+
18+ $ this ->factory = new Factory ($ this ->loop , $ this ->tcp , $ this ->tls );
19+ }
20+
21+ public function testDefaultCtor ()
22+ {
23+ $ this ->factory = new Factory ($ this ->loop );
24+ }
25+
26+ public function testCreateClientUsesTcpConnectorWithDefaultLocation ()
27+ {
28+ $ promise = new Promise (function () { });
29+ $ this ->tcp ->expects ($ this ->once ())->method ('create ' )->with ('127.0.0.1 ' , 5038 )->willReturn ($ promise );
30+
31+ $ this ->factory ->createClient ();
32+ }
33+
34+ public function testCreateClientUsesTcpConnectorWithLocalhostLocation ()
35+ {
36+ $ promise = new Promise (function () { });
37+ $ this ->tcp ->expects ($ this ->once ())->method ('create ' )->with ('127.0.0.1 ' , 5038 )->willReturn ($ promise );
38+
39+ $ this ->factory ->createClient ('localhost ' );
40+ }
41+ }
You can’t perform that action at this time.
0 commit comments