Fixed typo and added unit tests
This commit is contained in:
parent
24a912b50d
commit
55a9b6e233
|
@ -39,7 +39,12 @@ class SoapClientBuilder extends AbstractSoapBuilder
|
||||||
{
|
{
|
||||||
$this->validateOptions();
|
$this->validateOptions();
|
||||||
|
|
||||||
return new SoapClient($this->wsdl, $this->getSoapOptions() + $this->soapOptionAuthentication);
|
return new SoapClient($this->wsdl, $this->getSoapOptions());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSoapOptions()
|
||||||
|
{
|
||||||
|
return parent::getSoapOptions() + $this->soapOptionAuthentication;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -80,7 +85,7 @@ class SoapClientBuilder extends AbstractSoapBuilder
|
||||||
$this->soapOptionAuthentication = array(
|
$this->soapOptionAuthentication = array(
|
||||||
'authentication' => SOAP_AUTHENTICATION_BASIC,
|
'authentication' => SOAP_AUTHENTICATION_BASIC,
|
||||||
'login' => $username,
|
'login' => $username,
|
||||||
'password' => $password
|
'password' => $password,
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -89,14 +94,17 @@ class SoapClientBuilder extends AbstractSoapBuilder
|
||||||
/**
|
/**
|
||||||
* @return SoapClientBuilder
|
* @return SoapClientBuilder
|
||||||
*/
|
*/
|
||||||
public function withDigestAuthentication($certificate, $password)
|
public function withDigestAuthentication($certificate, $passphrase = null)
|
||||||
{
|
{
|
||||||
$this->soapOptionAuthentication = array(
|
$this->soapOptionAuthentication = array(
|
||||||
'authentication' => SOAP_AUTHENTICATION_DIGEST,
|
'authentication' => SOAP_AUTHENTICATION_DIGEST,
|
||||||
'local_cert' => $certificate,
|
'local_cert' => $certificate,
|
||||||
'passphrase' => $password
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ($passphrase) {
|
||||||
|
$this->soapOptionAuthentication['passphrase'] = $passphrase;
|
||||||
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,20 @@ class SoapClientBuilderTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertEquals($this->mergeOptions(array('user_agent' => 'BeSimpleSoap Test')), $builder->getSoapOptions());
|
$this->assertEquals($this->mergeOptions(array('user_agent' => 'BeSimpleSoap Test')), $builder->getSoapOptions());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testWithAuthentication()
|
||||||
|
{
|
||||||
|
$builder = $this->getSoapBuilder();
|
||||||
|
|
||||||
|
$builder->withDigestAuthentication(__DIR__.'/Fixtures/cert.pem', 'foobar');
|
||||||
|
$this->assertEquals($this->mergeOptions(array('authentication' => SOAP_AUTHENTICATION_DIGEST, 'local_cert' => __DIR__.'/Fixtures/cert.pem', 'passphrase' => 'foobar')), $builder->getSoapOptions());
|
||||||
|
|
||||||
|
$builder->withDigestAuthentication(__DIR__.'/Fixtures/cert.pem');
|
||||||
|
$this->assertEquals($this->mergeOptions(array('authentication' => SOAP_AUTHENTICATION_DIGEST, 'local_cert' => __DIR__.'/Fixtures/cert.pem')), $builder->getSoapOptions());
|
||||||
|
|
||||||
|
$builder->withBasicAuthentication('foo', 'bar');
|
||||||
|
$this->assertEquals($this->mergeOptions(array('authentication' => SOAP_AUTHENTICATION_BASIC, 'login' => 'foo', 'password' => 'bar')), $builder->getSoapOptions());
|
||||||
|
}
|
||||||
|
|
||||||
public function testCreateWithDefaults()
|
public function testCreateWithDefaults()
|
||||||
{
|
{
|
||||||
$builder = SoapClientBuilder::createWithDefaults();
|
$builder = SoapClientBuilder::createWithDefaults();
|
||||||
|
|
Loading…
Reference in New Issue