File tree Expand file tree Collapse file tree 2 files changed +45
-1
lines changed
Expand file tree Collapse file tree 2 files changed +45
-1
lines changed Original file line number Diff line number Diff line change @@ -218,7 +218,7 @@ public function open()
218218 throw new TTransportException ('Cannot open null host ' , TTransportException::NOT_OPEN );
219219 }
220220
221- if ($ this ->port_ <= 0 ) {
221+ if ($ this ->port_ <= 0 && strpos ( $ this -> host_ , ' unix:// ' ) !== 0 ) {
222222 throw new TTransportException ('Cannot open without port ' , TTransportException::NOT_OPEN );
223223 }
224224
Original file line number Diff line number Diff line change @@ -246,6 +246,50 @@ public function testOpenPersist()
246246 $ this ->assertTrue ($ transport ->isOpen ());
247247 }
248248
249+ public function testOpenUnixSocket ()
250+ {
251+ $ host = 'unix:///tmp/ipc.sock ' ;
252+ $ port = -1 ;
253+ $ persist = false ;
254+ $ debugHandler = null ;
255+ $ handle = fopen ('php://memory ' , 'r+ ' );
256+
257+ $ this ->getFunctionMock ('Thrift\Transport ' , 'fsockopen ' )
258+ ->expects ($ this ->once ())
259+ ->with (
260+ $ host ,
261+ $ port ,
262+ $ this ->anything (), #$errno,
263+ $ this ->anything (), #$errstr,
264+ $ this ->anything () #$this->sendTimeoutSec_ + ($this->sendTimeoutUsec_ / 1000000),
265+ )
266+ ->willReturn ($ handle );
267+
268+ $ this ->getFunctionMock ('Thrift\Transport ' , 'socket_import_stream ' )
269+ ->expects ($ this ->once ())
270+ ->with ($ handle )
271+ ->willReturn (true );
272+
273+ $ this ->getFunctionMock ('Thrift\Transport ' , 'socket_set_option ' )
274+ ->expects ($ this ->once ())
275+ ->with (
276+ $ this ->anything (), #$socket,
277+ SOL_TCP , #$level
278+ TCP_NODELAY , #$option
279+ 1 #$value
280+ )
281+ ->willReturn (true );
282+
283+ $ transport = new TSocket (
284+ $ host ,
285+ $ port ,
286+ $ persist ,
287+ $ debugHandler
288+ );
289+
290+ $ transport ->open ();
291+ }
292+
249293 /**
250294 * @dataProvider open_THRIFT_5132_DataProvider
251295 */
You can’t perform that action at this time.
0 commit comments