@@ -93,6 +93,7 @@ public function heartbeat_should_interrupt_non_blocking_action()
9393
9494 /**
9595 * @test
96+ * @runInSeparateProcess
9697 */
9798 public function alarm_sig_should_be_registered_when_conn_is_writing ()
9899 {
@@ -101,7 +102,7 @@ public function alarm_sig_should_be_registered_when_conn_is_writing()
101102 ->disableOriginalConstructor ()
102103 ->getMockForAbstractClass ();
103104
104- $ connection ->expects ($ this ->exactly ( 3 ))->method ('isConnected ' )->willReturn (true );
105+ $ connection ->expects ($ this ->atLeast ( 2 ))->method ('isConnected ' )->willReturn (true );
105106 $ connection ->expects ($ this ->once ())->method ('getHeartbeat ' )->willReturn ($ this ->heartbeatTimeout );
106107 $ connection ->expects ($ this ->exactly (2 ))
107108 ->method ('isWriting ' )
@@ -120,4 +121,26 @@ public function alarm_sig_should_be_registered_when_conn_is_writing()
120121
121122 $ sender ->unregister ();
122123 }
124+
125+ /**
126+ * @test
127+ * @runInSeparateProcess
128+ * @outputBuffering disabled
129+ * @covers \PhpAmqpLib\Connection\Heartbeat\SIGHeartbeatSender::unregister()
130+ */
131+ public function child_process_must_be_terminated_after_unregister ()
132+ {
133+ $ property = new \ReflectionProperty (get_class ($ this ->sender ), 'childPid ' );
134+ $ property ->setAccessible (true );
135+
136+ $ this ->sender ->register ();
137+ $ pid = $ property ->getValue ($ this ->sender );
138+ self ::assertGreaterThan (0 , $ pid );
139+
140+ $ this ->sender ->unregister ();
141+
142+ $ result = pcntl_waitpid ($ pid , $ status , WNOHANG );
143+ self ::assertEquals (-1 , $ result );
144+ self ::assertEquals (0 , $ status );
145+ }
123146}
0 commit comments