11<?php
22
3+ namespace Clue \Tests \React \SshProxy ;
4+
35use PHPUnit \Framework \TestCase ;
46use Clue \React \SshProxy \SshSocksConnector ;
57use React \Promise \Deferred ;
@@ -11,7 +13,7 @@ public function testConstructorAcceptsUri()
1113 $ loop = $ this ->getMockBuilder ('React\EventLoop\LoopInterface ' )->getMock ();
1214 $ connector = new SshSocksConnector ('host ' , $ loop );
1315
14- $ ref = new ReflectionProperty ($ connector , 'cmd ' );
16+ $ ref = new \ ReflectionProperty ($ connector , 'cmd ' );
1517 $ ref ->setAccessible (true );
1618
1719 $ this ->assertEquals ('exec ssh -v -o ExitOnForwardFailure=yes -N -o BatchMode=yes -D \'127.0.0.1:1080 \' \'host \'' , $ ref ->getValue ($ connector ));
@@ -22,7 +24,7 @@ public function testConstructorAcceptsUriWithDefaultPortWillNotBeAddedToCommand(
2224 $ loop = $ this ->getMockBuilder ('React\EventLoop\LoopInterface ' )->getMock ();
2325 $ connector = new SshSocksConnector ('host:22 ' , $ loop );
2426
25- $ ref = new ReflectionProperty ($ connector , 'cmd ' );
27+ $ ref = new \ ReflectionProperty ($ connector , 'cmd ' );
2628 $ ref ->setAccessible (true );
2729
2830 $ this ->assertEquals ('exec ssh -v -o ExitOnForwardFailure=yes -N -o BatchMode=yes -D \'127.0.0.1:1080 \' \'host \'' , $ ref ->getValue ($ connector ));
@@ -33,7 +35,7 @@ public function testConstructorAcceptsUriWithUserAndCustomPort()
3335 $ loop = $ this ->getMockBuilder ('React\EventLoop\LoopInterface ' )->getMock ();
3436 $ connector = new SshSocksConnector ('user@host:2222 ' , $ loop );
3537
36- $ ref = new ReflectionProperty ($ connector , 'cmd ' );
38+ $ ref = new \ ReflectionProperty ($ connector , 'cmd ' );
3739 $ ref ->setAccessible (true );
3840
3941 $ this ->assertEquals ('exec ssh -v -o ExitOnForwardFailure=yes -N -o BatchMode=yes -p 2222 -D \'127.0.0.1:1080 \' \'user@host \'' , $ ref ->getValue ($ connector ));
@@ -44,7 +46,7 @@ public function testConstructorAcceptsUriWithPasswordWillPrefixSshCommandWithSsh
4446 $ loop = $ this ->getMockBuilder ('React\EventLoop\LoopInterface ' )->getMock ();
4547 $ connector = new SshSocksConnector ('user:pass@host ' , $ loop );
4648
47- $ ref = new ReflectionProperty ($ connector , 'cmd ' );
49+ $ ref = new \ ReflectionProperty ($ connector , 'cmd ' );
4850 $ ref ->setAccessible (true );
4951
5052 $ this ->assertEquals ('exec sshpass -p \'pass \' ssh -v -o ExitOnForwardFailure=yes -N -D \'127.0.0.1:1080 \' \'user@host \'' , $ ref ->getValue ($ connector ));
@@ -55,7 +57,7 @@ public function testConstructorAcceptsUriWithCustomBindUrl()
5557 $ loop = $ this ->getMockBuilder ('React\EventLoop\LoopInterface ' )->getMock ();
5658 $ connector = new SshSocksConnector ('host?bind=127.1.0.1:2711 ' , $ loop );
5759
58- $ ref = new ReflectionProperty ($ connector , 'cmd ' );
60+ $ ref = new \ ReflectionProperty ($ connector , 'cmd ' );
5961 $ ref ->setAccessible (true );
6062
6163 $ this ->assertEquals ('exec ssh -v -o ExitOnForwardFailure=yes -N -o BatchMode=yes -D \'127.1.0.1:2711 \' \'host \'' , $ ref ->getValue ($ connector ));
@@ -66,7 +68,7 @@ public function testConstructorAcceptsUriWithCustomBindUrlIpv6()
6668 $ loop = $ this ->getMockBuilder ('React\EventLoop\LoopInterface ' )->getMock ();
6769 $ connector = new SshSocksConnector ('host?bind=[::1]:2711 ' , $ loop );
6870
69- $ ref = new ReflectionProperty ($ connector , 'cmd ' );
71+ $ ref = new \ ReflectionProperty ($ connector , 'cmd ' );
7072 $ ref ->setAccessible (true );
7173
7274 $ this ->assertEquals ('exec ssh -v -o ExitOnForwardFailure=yes -N -o BatchMode=yes -D \'[::1]:2711 \' \'host \'' , $ ref ->getValue ($ connector ));
@@ -189,7 +191,7 @@ public function testConnectWillCancelPendingIdleTimerAndWaitForSshListener()
189191 $ connector = new SshSocksConnector ('host ' , $ loop );
190192
191193 $ timer = $ this ->getMockBuilder ('React\EventLoop\TimerInterface ' )->getMock ();
192- $ ref = new ReflectionProperty ($ connector , 'idleTimer ' );
194+ $ ref = new \ ReflectionProperty ($ connector , 'idleTimer ' );
193195 $ ref ->setAccessible (true );
194196 $ ref ->setValue ($ connector , $ timer );
195197
@@ -207,13 +209,13 @@ public function testConnectWithFailingSshListenerShouldReturnRejectedPromise()
207209 $ connector = new SshSocksConnector ('host ' , $ loop );
208210
209211 $ deferred = new Deferred ();
210- $ ref = new ReflectionProperty ($ connector , 'listen ' );
212+ $ ref = new \ ReflectionProperty ($ connector , 'listen ' );
211213 $ ref ->setAccessible (true );
212214 $ ref ->setValue ($ connector , $ deferred ->promise ());
213215
214216 $ promise = $ connector ->connect ('google.com:80 ' );
215217
216- $ deferred ->reject (new RuntimeException ('foobar ' ));
218+ $ deferred ->reject (new \ RuntimeException ('foobar ' ));
217219
218220 $ exception = null ;
219221 $ promise ->then (null , function ($ reason ) use (&$ exception ) {
@@ -229,7 +231,7 @@ public function testConnectTwiceWithFailingSshListenerShouldRejectBothPromises()
229231 $ connector = new SshSocksConnector ('host ' , $ loop );
230232
231233 $ deferred = new Deferred ();
232- $ ref = new ReflectionProperty ($ connector , 'listen ' );
234+ $ ref = new \ ReflectionProperty ($ connector , 'listen ' );
233235 $ ref ->setAccessible (true );
234236 $ ref ->setValue ($ connector , $ deferred ->promise ());
235237
@@ -239,7 +241,7 @@ public function testConnectTwiceWithFailingSshListenerShouldRejectBothPromises()
239241 $ second = $ connector ->connect ('google.com:80 ' );
240242 $ second ->then (null , $ this ->expectCallableOnceWith ($ this ->isInstanceOf ('RuntimeException ' )));
241243
242- $ deferred ->reject (new InvalidArgumentException ());
244+ $ deferred ->reject (new \ InvalidArgumentException ());
243245 }
244246
245247 public function testConnectCancellationWithFailingSshListenerShouldAddTimerOnce ()
@@ -250,14 +252,14 @@ public function testConnectCancellationWithFailingSshListenerShouldAddTimerOnce(
250252 $ connector = new SshSocksConnector ('host ' , $ loop );
251253
252254 $ deferred = new Deferred ();
253- $ ref = new ReflectionProperty ($ connector , 'listen ' );
255+ $ ref = new \ ReflectionProperty ($ connector , 'listen ' );
254256 $ ref ->setAccessible (true );
255257 $ ref ->setValue ($ connector , $ deferred ->promise ());
256258
257259 $ promise = $ connector ->connect ('google.com:80 ' );
258260 $ promise ->cancel ();
259261
260- $ deferred ->reject (new InvalidArgumentException ());
262+ $ deferred ->reject (new \ InvalidArgumentException ());
261263 }
262264
263265 public function testConnectWithSuccessfulSshListenerWillInvokeSocksConnector ()
@@ -266,15 +268,15 @@ public function testConnectWithSuccessfulSshListenerWillInvokeSocksConnector()
266268
267269 $ connector = new SshSocksConnector ('host ' , $ loop );
268270
269- $ ref = new ReflectionProperty ($ connector , 'listen ' );
271+ $ ref = new \ ReflectionProperty ($ connector , 'listen ' );
270272 $ ref ->setAccessible (true );
271273 $ ref ->setValue ($ connector , \React \Promise \resolve (null ));
272274
273275 $ deferred = new Deferred ();
274276 $ socks = $ this ->getMockBuilder ('React\Socket\ConnectorInterface ' )->getMock ();
275277 $ socks ->expects ($ this ->once ())->method ('connect ' )->with ('google.com:80 ' )->willReturn ($ deferred ->promise ());
276278
277- $ ref = new ReflectionProperty ($ connector , 'socks ' );
279+ $ ref = new \ ReflectionProperty ($ connector , 'socks ' );
278280 $ ref ->setAccessible (true );
279281 $ ref ->setValue ($ connector , $ socks );
280282
@@ -292,17 +294,17 @@ public function testConnectCancellationWithSuccessfulSshListenerWillCancelSocksC
292294
293295 $ connector = new SshSocksConnector ('host ' , $ loop );
294296
295- $ ref = new ReflectionProperty ($ connector , 'listen ' );
297+ $ ref = new \ ReflectionProperty ($ connector , 'listen ' );
296298 $ ref ->setAccessible (true );
297299 $ ref ->setValue ($ connector , \React \Promise \resolve (null ));
298300
299301 $ deferred = new Deferred (function () {
300- throw new RuntimeException ('SOCKS cancelled ' );
302+ throw new \ RuntimeException ('SOCKS cancelled ' );
301303 });
302304 $ socks = $ this ->getMockBuilder ('React\Socket\ConnectorInterface ' )->getMock ();
303305 $ socks ->expects ($ this ->once ())->method ('connect ' )->willReturn ($ deferred ->promise ());
304306
305- $ ref = new ReflectionProperty ($ connector , 'socks ' );
307+ $ ref = new \ ReflectionProperty ($ connector , 'socks ' );
306308 $ ref ->setAccessible (true );
307309 $ ref ->setValue ($ connector , $ socks );
308310
@@ -327,21 +329,21 @@ public function testConnectWithSuccessfulSshListenerButFailingSocksConnectorShou
327329
328330 $ connector = new SshSocksConnector ('host ' , $ loop );
329331
330- $ ref = new ReflectionProperty ($ connector , 'listen ' );
332+ $ ref = new \ ReflectionProperty ($ connector , 'listen ' );
331333 $ ref ->setAccessible (true );
332334 $ ref ->setValue ($ connector , \React \Promise \resolve (null ));
333335
334336 $ deferred = new Deferred ();
335337 $ socks = $ this ->getMockBuilder ('React\Socket\ConnectorInterface ' )->getMock ();
336338 $ socks ->expects ($ this ->once ())->method ('connect ' )->willReturn ($ deferred ->promise ());
337339
338- $ ref = new ReflectionProperty ($ connector , 'socks ' );
340+ $ ref = new \ ReflectionProperty ($ connector , 'socks ' );
339341 $ ref ->setAccessible (true );
340342 $ ref ->setValue ($ connector , $ socks );
341343
342344 $ promise = $ connector ->connect ('google.com:80 ' );
343345
344- $ deferred ->reject (new RuntimeException ('Connection failed ' ));
346+ $ deferred ->reject (new \ RuntimeException ('Connection failed ' ));
345347
346348 $ exception = null ;
347349 $ promise ->then (null , function ($ reason ) use (&$ exception ) {
@@ -356,7 +358,7 @@ public function testConnectWithSuccessfulSshListenerAndSuccessfulSocksConnectorS
356358
357359 $ connector = new SshSocksConnector ('host ' , $ loop );
358360
359- $ ref = new ReflectionProperty ($ connector , 'listen ' );
361+ $ ref = new \ ReflectionProperty ($ connector , 'listen ' );
360362 $ ref ->setAccessible (true );
361363 $ ref ->setValue ($ connector , \React \Promise \resolve (null ));
362364
@@ -367,7 +369,7 @@ public function testConnectWithSuccessfulSshListenerAndSuccessfulSocksConnectorS
367369 $ socks = $ this ->getMockBuilder ('React\Socket\ConnectorInterface ' )->getMock ();
368370 $ socks ->expects ($ this ->once ())->method ('connect ' )->willReturn ($ deferred ->promise ());
369371
370- $ ref = new ReflectionProperty ($ connector , 'socks ' );
372+ $ ref = new \ ReflectionProperty ($ connector , 'socks ' );
371373 $ ref ->setAccessible (true );
372374 $ ref ->setValue ($ connector , $ socks );
373375
@@ -383,7 +385,7 @@ public function testConnectWithSuccessfulSshListenerAndSuccessfulSocksConnectorW
383385
384386 $ connector = new SshSocksConnector ('host ' , $ loop );
385387
386- $ ref = new ReflectionProperty ($ connector , 'listen ' );
388+ $ ref = new \ ReflectionProperty ($ connector , 'listen ' );
387389 $ ref ->setAccessible (true );
388390 $ ref ->setValue ($ connector , \React \Promise \resolve (null ));
389391
@@ -394,7 +396,7 @@ public function testConnectWithSuccessfulSshListenerAndSuccessfulSocksConnectorW
394396 $ socks = $ this ->getMockBuilder ('React\Socket\ConnectorInterface ' )->getMock ();
395397 $ socks ->expects ($ this ->once ())->method ('connect ' )->willReturn ($ deferred ->promise ());
396398
397- $ ref = new ReflectionProperty ($ connector , 'socks ' );
399+ $ ref = new \ ReflectionProperty ($ connector , 'socks ' );
398400 $ ref ->setAccessible (true );
399401 $ ref ->setValue ($ connector , $ socks );
400402
0 commit comments