示例#1
0
 public function testConnectionResetIfSocketExceptionIsThrown()
 {
     $pheanstalk = new Pheanstalk(self::SERVER_HOST, self::SERVER_PORT, self::CONNECT_TIMEOUT);
     Mock::generate('Pheanstalk_Connection');
     $connection = new MockPheanstalk_Connection('');
     $connection->returns('getHost', self::SERVER_HOST);
     $connection->returns('getPort', self::SERVER_PORT);
     $connection->returns('getConnectTimeout', self::CONNECT_TIMEOUT);
     $connection->throwOn('dispatchCommand', new Pheanstalk_Exception_SocketException('socket error simulated'));
     $pheanstalk->putInTube('testconnectionreset', __METHOD__);
     $pheanstalk->watchOnly('testconnectionreset');
     $pheanstalk->setConnection($connection);
     $connection->expectOnce('dispatchCommand');
     $job = $pheanstalk->reserve();
     $this->assertEqual(__METHOD__, $job->getData());
 }