public function testEmptyInstance() { /** @var PlatformConfig $platFormConfig */ $platFormConfig = FactoryMuffin::create('WebservicesNl\\Platform\\Webservices\\PlatformConfig'); $soapConfig = new SoapConfig($platFormConfig); static::assertFalse($soapConfig->hasConverter()); static::assertEmpty($soapConfig->getSoapHeaders()); static::assertEquals($platFormConfig, $soapConfig->getPlatformConfig()); static::assertAttributeInstanceOf('WebservicesNl\\Platform\\Webservices\\PlatformConfig', 'platformConfig', $soapConfig); static::assertEquals($soapConfig::getEndPoints(), SoapConfig::getEndPoints()); static::assertCount(5, $soapConfig->toArray()); $static = SoapConfig::configure($platFormConfig); static::assertEquals($static, $soapConfig); }
/** * Creates a SoapClient with configured SoapConfig object and given additional settings. * * @param array $settings additional settings go here * * @return SoapClient * @throws InputException * @throws NoServerAvailableException * @throws \InvalidArgumentException */ public function create(array $settings = []) { // create soap settings, with given settings and platform settings $soapSettings = SoapSettings::loadFromArray($settings); // create a manager for endpoint management $manager = $this->createEndpointManager($settings); // replace the native soap client transport with a curl client $curlClient = $this->createCurlClient($soapSettings->toArray(), $manager); // build a SoapClient (extends the native soap client) $soapClient = new SoapClient($soapSettings, $manager, $curlClient); // set custom headers $soapHeaders = array_key_exists('soapHeaders', $settings) ? array_merge($settings['soapHeaders'], $this->config->getSoapHeaders()) : $this->config->getSoapHeaders(); $soapClient->__setSoapHeaders($soapHeaders); if ($this->config->hasConverter() === true) { $soapClient->setConverter($this->config->getConverter()); } if ($this->hasLogger() === true) { $soapClient->setLogger($this->logger); $this->logger->info('Created SoapClient for ' . $this->config->getPlatformConfig()->getPlatformName()); $this->logger->debug('Created SoapClient', ['SoapClient' => print_r($soapClient, true)]); $this->logger->debug('Settings', ['settings' => (array) $settings]); } return $soapClient; }