From d6c9074c942af4395eb8ae10cff77892618d3aeb Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Tue, 11 Oct 2011 22:07:16 +0200 Subject: [PATCH] Added SoapClientBuilder::withProxy() --- src/BeSimple/SoapClient/SoapClientBuilder.php | 13 +++++++++++++ .../Tests/SoapClient/SoapClientBuilderTest.php | 11 +++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/BeSimple/SoapClient/SoapClientBuilder.php b/src/BeSimple/SoapClient/SoapClientBuilder.php index a8d5e15..9d5cfa2 100644 --- a/src/BeSimple/SoapClient/SoapClientBuilder.php +++ b/src/BeSimple/SoapClient/SoapClientBuilder.php @@ -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(); diff --git a/tests/BeSimple/Tests/SoapClient/SoapClientBuilderTest.php b/tests/BeSimple/Tests/SoapClient/SoapClientBuilderTest.php index d256a01..b04f145 100644 --- a/tests/BeSimple/Tests/SoapClient/SoapClientBuilderTest.php +++ b/tests/BeSimple/Tests/SoapClient/SoapClientBuilderTest.php @@ -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();