Пример #1
0
 public function testConnectionResetIfSocketExceptionIsThrown()
 {
     $pheanstalk = new \Pheanstalk\Pheanstalk(self::SERVER_HOST, self::SERVER_PORT, self::CONNECT_TIMEOUT);
     Mock::generate('Pheanstalk\\Connection', 'MockPheanstalk_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());
 }