@@ -31,6 +31,14 @@ public function testInvalidProxyScheme()
3131 new ProxyConnector ('ftp://example.com ' , $ this ->connector );
3232 }
3333
34+ /**
35+ * @expectedException InvalidArgumentException
36+ */
37+ public function testInvalidHttpsUnixScheme ()
38+ {
39+ new ProxyConnector ('https+unix:///tmp/proxy.sock ' , $ this ->connector );
40+ }
41+
3442 public function testCreatesConnectionToHttpPort ()
3543 {
3644 $ promise = new Promise (function () { });
@@ -71,6 +79,16 @@ public function testCreatesConnectionToHttpsPort()
7179 $ proxy ->connect ('google.com:80 ' );
7280 }
7381
82+ public function testCreatesConnectionToUnixPath ()
83+ {
84+ $ promise = new Promise (function () { });
85+ $ this ->connector ->expects ($ this ->once ())->method ('connect ' )->with ('unix:///tmp/proxy.sock ' )->willReturn ($ promise );
86+
87+ $ proxy = new ProxyConnector ('http+unix:///tmp/proxy.sock ' , $ this ->connector );
88+
89+ $ proxy ->connect ('google.com:80 ' );
90+ }
91+
7492 public function testCancelPromiseWillCancelPendingConnection ()
7593 {
7694 $ promise = new Promise (function () { }, $ this ->expectCallableOnce ());
@@ -140,6 +158,19 @@ public function testWillProxyAuthorizationHeaderIfProxyUriContainsAuthentication
140158 $ proxy ->connect ('google.com:80 ' );
141159 }
142160
161+ public function testWillProxyAuthorizationHeaderIfUnixProxyUriContainsAuthentication ()
162+ {
163+ $ stream = $ this ->getMockBuilder ('React\Socket\Connection ' )->disableOriginalConstructor ()->setMethods (array ('close ' , 'write ' ))->getMock ();
164+ $ stream ->expects ($ this ->once ())->method ('write ' )->with ("CONNECT google.com:80 HTTP/1.1 \r\nHost: google.com:80 \r\nProxy-Authorization: Basic dXNlcjpwYXNz \r\n\r\n" );
165+
166+ $ promise = \React \Promise \resolve ($ stream );
167+ $ this ->connector ->expects ($ this ->once ())->method ('connect ' )->with ('unix:///tmp/proxy.sock ' )->willReturn ($ promise );
168+
169+ $ proxy = new ProxyConnector ('http+unix://user:pass@/tmp/proxy.sock ' , $ this ->connector );
170+
171+ $ proxy ->connect ('google.com:80 ' );
172+ }
173+
143174 public function testRejectsInvalidUri ()
144175 {
145176 $ this ->connector ->expects ($ this ->never ())->method ('connect ' );
0 commit comments