@@ -12,7 +12,7 @@ class FactoryTest extends TestCase
1212 public function setUp ()
1313 {
1414 $ this ->loop = $ this ->getMockBuilder ('React\EventLoop\LoopInterface ' )->getMock ();
15- $ this ->connector = $ this ->getMockBuilder ('React\SocketClient \ConnectorInterface ' )->getMock ();
15+ $ this ->connector = $ this ->getMockBuilder ('React\Socket \ConnectorInterface ' )->getMock ();
1616 $ this ->factory = new Factory ($ this ->loop , $ this ->connector );
1717 }
1818
@@ -39,9 +39,18 @@ public function testWillConnectToLocalIpWhenTargetIsLocalhost()
3939 $ this ->factory ->createClient ('tcp://localhost:1337 ' );
4040 }
4141
42+ public function testWillUpcastLegacyConnectorAndConnect ()
43+ {
44+ $ this ->connector = $ this ->getMockBuilder ('React\SocketClient\ConnectorInterface ' )->getMock ();
45+ $ this ->factory = new Factory ($ this ->loop , $ this ->connector );
46+
47+ $ this ->connector ->expects ($ this ->once ())->method ('connect ' )->with ('example.com:1337 ' )->willReturn (Promise \reject (new \RuntimeException ()));
48+ $ this ->factory ->createClient ('tcp://example.com:1337 ' );
49+ }
50+
4251 public function testWillResolveIfConnectorResolves ()
4352 {
44- $ stream = $ this ->getMockBuilder ('React\Stream\Stream ' )-> disableOriginalConstructor ( )->getMock ();
53+ $ stream = $ this ->getMockBuilder ('React\Socket\ConnectionInterface ' )->getMock ();
4554 $ stream ->expects ($ this ->never ())->method ('write ' );
4655
4756 $ this ->connector ->expects ($ this ->once ())->method ('connect ' )->willReturn (Promise \resolve ($ stream ));
@@ -52,7 +61,7 @@ public function testWillResolveIfConnectorResolves()
5261
5362 public function testWillWriteSelectCommandIfTargetContainsPath ()
5463 {
55- $ stream = $ this ->getMockBuilder ('React\Stream\Stream ' )-> disableOriginalConstructor ( )->getMock ();
64+ $ stream = $ this ->getMockBuilder ('React\Socket\ConnectionInterface ' )->getMock ();
5665 $ stream ->expects ($ this ->once ())->method ('write ' )->with ("*2 \r\n$6 \r\nselect \r\n$4 \r\ndemo \r\n" );
5766
5867 $ this ->connector ->expects ($ this ->once ())->method ('connect ' )->willReturn (Promise \resolve ($ stream ));
@@ -61,7 +70,7 @@ public function testWillWriteSelectCommandIfTargetContainsPath()
6170
6271 public function testWillWriteAuthCommandIfTargetContainsUserInfo ()
6372 {
64- $ stream = $ this ->getMockBuilder ('React\Stream\Stream ' )-> disableOriginalConstructor ( )->getMock ();
73+ $ stream = $ this ->getMockBuilder ('React\Socket\ConnectionInterface ' )->getMock ();
6574 $ stream ->expects ($ this ->once ())->method ('write ' )->with ("*2 \r\n$4 \r\nauth \r\n$11 \r\nhello:world \r\n" );
6675
6776 $ this ->connector ->expects ($ this ->once ())->method ('connect ' )->willReturn (Promise \resolve ($ stream ));
0 commit comments