Added SoapClientBuilder::withProxy()

This commit is contained in:
Francis Besset 2011-10-11 22:07:16 +02:00
parent 55a9b6e233
commit d6c9074c94
2 changed files with 24 additions and 0 deletions

View File

@ -108,6 +108,19 @@ class SoapClientBuilder extends AbstractSoapBuilder
return $this;
}
public function withProxy($host, $port, $username = null, $password = null)
{
$this->soapOptions['proxy_host'] = $host;
$this->soapOptions['proxy_port'] = $port;
if ($username) {
$this->soapOptions['proxy_login'] = $username;
$this->soapOptions['proxy_password'] = $password;
}
return $this;
}
protected function validateOptions()
{
$this->validateWsdl();

View File

@ -76,6 +76,17 @@ class SoapClientBuilderTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($this->mergeOptions(array('authentication' => SOAP_AUTHENTICATION_BASIC, 'login' => 'foo', 'password' => 'bar')), $builder->getSoapOptions());
}
public function testWithProxy()
{
$builder = $this->getSoapBuilder();
$builder->withProxy('localhost', 8080);
$this->assertEquals($this->mergeOptions(array('proxy_host' => 'localhost', 'proxy_port' => 8080)), $builder->getSoapOptions());
$builder->withProxy('127.0.0.1', 8585, 'foo', 'bar');
$this->assertEquals($this->mergeOptions(array('proxy_host' => '127.0.0.1', 'proxy_port' => 8585, 'proxy_login' => 'foo', 'proxy_password' => 'bar')), $builder->getSoapOptions());
}
public function testCreateWithDefaults()
{
$builder = SoapClientBuilder::createWithDefaults();