[SoapClient] Moved TypeConverterCollection parameter in the constructor

This commit is contained in:
Francis Besset 2011-10-08 12:22:17 +02:00
parent d29f0caa8d
commit 7be719ffc5
2 changed files with 12 additions and 13 deletions

View File

@ -28,10 +28,11 @@ class SoapClient
* @param string $wsdl * @param string $wsdl
* @param array $options * @param array $options
*/ */
public function __construct($wsdl, TypeConverterCollection $converters = null, array $options = array()) public function __construct($wsdl, array $options = array(), TypeConverterCollection $converters = null)
{ {
$this->wsdl = $wsdl; $this->wsdl = $wsdl;
$this->converters = $converters; $this->converters = $converters;
$this->setOptions($options); $this->setOptions($options);
} }
@ -155,17 +156,15 @@ class SoapClient
*/ */
public function getSoapOptions() public function getSoapOptions()
{ {
$options = array();
if (null === $this->options['cache_type']) { if (null === $this->options['cache_type']) {
$this->options['cache_type'] = Cache::getType(); $this->options['cache_type'] = Cache::getType();
} }
$options['cache_wsdl'] = $this->options['cache_type']; return array(
$options['trace'] = $this->options['debug']; 'cache_wsdl' => $this->options['cache_type'],
$options['typemap'] = $this->getTypemap(); 'trace' => $this->options['debug'],
'typemap' => $this->getTypemap(),
return $options; );
} }
/** /**

View File

@ -67,7 +67,7 @@ class SoapClientTest extends \PHPUnit_Framework_TestCase
public function testCreateSoapHeader() public function testCreateSoapHeader()
{ {
$soapClient = new SoapClient('foo.wsdl', null, array('namespace' => 'http://foobar/soap/User/1.0/')); $soapClient = new SoapClient('foo.wsdl', array('namespace' => 'http://foobar/soap/User/1.0/'));
$soapHeader = $soapClient->createSoapHeader('foo', 'bar'); $soapHeader = $soapClient->createSoapHeader('foo', 'bar');
$this->assertInstanceOf('SoapHeader', $soapHeader); $this->assertInstanceOf('SoapHeader', $soapHeader);
@ -87,10 +87,10 @@ class SoapClientTest extends \PHPUnit_Framework_TestCase
public function testGetSoapOptions() public function testGetSoapOptions()
{ {
Cache::setType(Cache::TYPE_MEMORY); Cache::setType(Cache::TYPE_MEMORY);
$soapClient = new SoapClient('foo.wsdl', null, array('debug' => true)); $soapClient = new SoapClient('foo.wsdl', array('debug' => true));
$this->assertEquals(array('cache_wsdl' => Cache::getType(), 'trace' => true, 'typemap' => array()), $soapClient->getSoapOptions()); $this->assertEquals(array('cache_wsdl' => Cache::getType(), 'trace' => true, 'typemap' => array()), $soapClient->getSoapOptions());
$soapClient = new SoapClient('foo.wsdl', null, array('debug' => false, 'cache_type' => Cache::TYPE_NONE)); $soapClient = new SoapClient('foo.wsdl', array('debug' => false, 'cache_type' => Cache::TYPE_NONE));
$this->assertEquals(array('cache_wsdl' => Cache::TYPE_NONE, 'trace' => false, 'typemap' => array()), $soapClient->getSoapOptions()); $this->assertEquals(array('cache_wsdl' => Cache::TYPE_NONE, 'trace' => false, 'typemap' => array()), $soapClient->getSoapOptions());
} }
@ -104,7 +104,7 @@ class SoapClientTest extends \PHPUnit_Framework_TestCase
$dateTypeConverter = new DateTypeConverter(); $dateTypeConverter = new DateTypeConverter();
$converters->add($dateTypeConverter); $converters->add($dateTypeConverter);
$soapClient = new SoapClient('foo.wsdl', $converters); $soapClient = new SoapClient('foo.wsdl', array(), $converters);
$soapOptions = $soapClient->getSoapOptions(); $soapOptions = $soapClient->getSoapOptions();
$this->assertEquals('http://www.w3.org/2001/XMLSchema', $soapOptions['typemap'][0]['type_ns']); $this->assertEquals('http://www.w3.org/2001/XMLSchema', $soapOptions['typemap'][0]['type_ns']);
@ -120,7 +120,7 @@ class SoapClientTest extends \PHPUnit_Framework_TestCase
public function testGetNativeSoapClient() public function testGetNativeSoapClient()
{ {
$soapClient = new SoapClient(__DIR__.'/Fixtures/foobar.wsdl', null, array('debug' => true)); $soapClient = new SoapClient(__DIR__.'/Fixtures/foobar.wsdl', array('debug' => true));
$this->assertInstanceOf('SoapClient', $soapClient->getNativeSoapClient()); $this->assertInstanceOf('SoapClient', $soapClient->getNativeSoapClient());
} }