/** * Provides backwards compatibility - older versions used this * class as the "facade" rather than the Pheanstalk class. * * @param string $name * @param array $arguments */ public function __call($name, $arguments) { $methods = array('put', 'reserve', 'release', 'delete', 'bury', 'kick', 'getCurrentTube', 'useTube', 'getWatchedTubes', 'watchTube', 'ignoreTube'); if (!in_array($name, $methods)) { throw new BadMethodCallException(__METHOD__ . ' not implemented'); } trigger_error(sprintf('%s::%s() deprecated, use Pheanstalk::%s()', __CLASS__, $name, $name), E_USER_NOTICE); $pheanstalk = new Pheanstalk($this->_hostname, $this->_port); $pheanstalk->setConnection($this); return call_user_func_array(array($pheanstalk, $name), $arguments); }
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()); }