File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -99,6 +99,30 @@ public function testSerialize()
9999 $ this ->assertTrue ($ db2 ->ping ());
100100 }
101101
102+ public function testConnectionTimeout ()
103+ {
104+ $ db = $ this ->getConnection (false );
105+ $ db ->configSet ('timeout ' , 1 );
106+ $ this ->assertTrue ($ db ->ping ());
107+ sleep (1 );
108+ $ this ->assertTrue ($ db ->ping ());
109+
110+ $ db ->close ();
111+ $ db ->on (Connection::EVENT_AFTER_OPEN , function () {
112+ // sleep 2 seconds after connect to make every command time out
113+ sleep (2 );
114+ });
115+
116+ $ exception = false ;
117+ try {
118+ sleep (3 );
119+ $ db ->ping ();
120+ } catch (SocketException $ e ) {
121+ $ exception = true ;
122+ }
123+ $ this ->assertTrue ($ exception , 'SocketException should have been thrown. ' );
124+ }
125+
102126 public function testConnectionTimeoutRetry ()
103127 {
104128 $ logger = new Logger ();
You can’t perform that action at this time.
0 commit comments