Added phing for running tests & fixed issues in order to pass the tests

This commit is contained in:
Petr Bechyně
2017-06-07 15:50:04 +02:00
parent b9e36b4900
commit 2264e329a1
47 changed files with 1349 additions and 394 deletions

View File

@ -12,7 +12,7 @@ namespace BeSimple\SoapBundle\Converter;
use BeSimple\SoapBundle\Soap\SoapRequest;
use BeSimple\SoapBundle\Soap\SoapResponse;
use BeSimple\SoapBundle\Util\String;
use BeSimple\SoapBundle\Util\StringUtility;
use BeSimple\SoapCommon\Converter\TypeConverterInterface;
/**
@ -40,7 +40,7 @@ class XopIncludeTypeConverter implements TypeConverterInterface
$ref = $include->getAttribute('href');
if (String::startsWith($ref, 'cid:')) {
if (StringUtility::startsWith($ref, 'cid:')) {
$cid = urldecode(substr($ref, 4));
return $request->getSoapAttachments()->get($cid)->getContent();

View File

@ -12,7 +12,7 @@
namespace BeSimple\SoapBundle\Handler;
use BeSimple\SoapServer\Exception\ReceiverSoapFault;
use SoapFault;
use Symfony\Component\Debug\Exception\FlattenException;
use Symfony\Component\HttpFoundation\Response;
@ -44,7 +44,8 @@ class ExceptionHandler
$code = $this->exception->getStatusCode();
throw new ReceiverSoapFault(
throw new SoapFault(
'receiver',
isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '',
null,
$this->details

View File

@ -7,7 +7,7 @@ Pre-existent Type
+------------------------------------------------+-----------------+
| Php Type | Value Type |
+================================================+=================+
| BeSimple\\SoapCommon\\Type\\KeyValue\\String | String |
| BeSimple\\SoapCommon\\Type\\KeyValue\\StringUtility | StringUtility |
+------------------------------------------------+-----------------+
| BeSimple\\SoapCommon\\Type\\KeyValue\\Boolean | Boolean |
+------------------------------------------------+-----------------+
@ -34,7 +34,7 @@ Controller
{
/**
* @Soap\Method("returnAssocArray")
* @Soap\Result(phpType = "BeSimple\SoapCommon\Type\KeyValue\String[]")
* @Soap\Result(phpType = "BeSimple\SoapCommon\Type\KeyValue\StringUtility[]")
*/
public function assocArrayOfStringAction()
{
@ -46,8 +46,8 @@ Controller
/**
* @Soap\Method("sendAssocArray")
* @Soap\Param("assocArray", phpType = "BeSimple\SoapCommon\Type\KeyValue\String[]")
* @Soap\Result(phpType = "BeSimple\SoapCommon\Type\KeyValue\String[]")
* @Soap\Param("assocArray", phpType = "BeSimple\SoapCommon\Type\KeyValue\StringUtility[]")
* @Soap\Result(phpType = "BeSimple\SoapCommon\Type\KeyValue\StringUtility[]")
*/
public function sendAssocArrayOfStringAction(array $assocArray)
{

View File

@ -11,11 +11,11 @@
namespace BeSimple\SoapBundle\Util;
/**
* String provides utility methods for strings.
* StringUtility provides utility methods for strings.
*
* @author Christian Kerl <christian-kerl@web.de>
*/
class String
class StringUtility
{
/**
* Checks if a string starts with a given string.

View File

@ -120,7 +120,7 @@ class Curl
$httpAuthenticationBasic = $options->getHttpAuthentication();
curl_setopt($curlSession, CURLOPT_HTTPAUTH, $httpAuthenticationBasic->getAuthenticationType());
curl_setopt($curlSession, CURLOPT_USERPWD, $httpAuthenticationBasic->getUsername() . ':' . $httpAuthenticationBasic->getPassword());
} else if ($options->hasHttpAuthenticationDigest()) {
} elseif ($options->hasHttpAuthenticationDigest()) {
/** @var HttpAuthenticationDigestOptions $httpAuthenticationDigest */
$httpAuthenticationDigest = $options->getHttpAuthentication();
curl_setopt($curlSession, CURLOPT_HTTPAUTH, $httpAuthenticationDigest->getAuthenticationType());

View File

@ -50,13 +50,14 @@ class CurlOptionsBuilder
$basicAuthentication->getPassword()
);
} else if ($soapClientOptions->hasAuthenticationDigest()) {
}
if ($soapClientOptions->hasAuthenticationDigest()) {
return new HttpAuthenticationDigestOptions();
} else {
throw new Exception('Unresolved authentication type: '.get_class($soapClientOptions->getAuthentication()));
}
throw new Exception('Unresolved authentication type: '.get_class($soapClientOptions->getAuthentication()));
}
return null;

View File

@ -43,8 +43,6 @@ class SoapClient extends \SoapClient
{
use SoapClientNativeMethodsTrait;
/** @var SoapClientOptions */
protected $soapClientOptions;
/** @var SoapOptions */
protected $soapOptions;
/** @var Curl */

View File

@ -9,6 +9,7 @@ use Exception;
trait SoapClientNativeMethodsTrait
{
protected $soapClientOptions;
/** @var SoapAttachment[] */
private $soapAttachmentsOnRequestStorage;
/** @var SoapResponse */

View File

@ -94,16 +94,16 @@ class WsAddressingFilter implements SoapRequestFilter, SoapResponseFilter
/**
* List of reference parameters associated with this soap message.
*
* @var unknown_type
* @var array
*/
protected $referenceParametersSet = array();
protected $referenceParametersSet;
/**
* List of reference parameters recieved with this soap message.
*
* @var unknown_type
* @var array
*/
protected $referenceParametersRecieved = array();
protected $referenceParametersRecieved;
/**
* RelatesTo.
@ -214,7 +214,7 @@ class WsAddressingFilter implements SoapRequestFilter, SoapResponseFilter
public function setMessageId($messageId = null)
{
if (null === $messageId) {
$messageId = 'uuid:' . Helper::generateUUID();
$messageId = 'uuid:' . Helper::generateUuid();
}
$this->messageId = $messageId;
}
@ -259,7 +259,7 @@ class WsAddressingFilter implements SoapRequestFilter, SoapResponseFilter
*
* @return void
*/
public function filterRequest(CommonSoapRequest $request)
public function filterRequest(CommonSoapRequest $request, $attachmentType)
{
// get \DOMDocument from SOAP request
$dom = $request->getContentDocument();
@ -328,7 +328,7 @@ class WsAddressingFilter implements SoapRequestFilter, SoapResponseFilter
*
* @return void
*/
public function filterResponse(CommonSoapResponse $response)
public function filterResponse(CommonSoapResponse $response, $attachmentType)
{
// get \DOMDocument from SOAP response
$dom = $response->getContentDocument();
@ -344,4 +344,4 @@ class WsAddressingFilter implements SoapRequestFilter, SoapResponseFilter
}
}
}
}
}

View File

@ -104,10 +104,11 @@ class WsSecurityFilter extends WsSecurityFilterClientServer implements SoapReque
* Modify the given request XML.
*
* @param \BeSimple\SoapCommon\SoapRequest $request SOAP request
* @param int $attachmentType
*
* @return void
*/
public function filterRequest(CommonSoapRequest $request)
public function filterRequest(CommonSoapRequest $request, $attachmentType)
{
// get \DOMDocument from SOAP request
$dom = $request->getContentDocument();
@ -174,7 +175,7 @@ class WsSecurityFilter extends WsSecurityFilterClientServer implements SoapReque
}
if (null !== $this->userSecurityKey && $this->userSecurityKey->hasKeys()) {
$guid = 'CertId-' . Helper::generateUUID();
$guid = 'CertId-' . Helper::generateUuid();
// add token references
$keyInfo = null;
if (null !== $this->tokenReferenceSignature) {
@ -200,7 +201,7 @@ class WsSecurityFilter extends WsSecurityFilterClientServer implements SoapReque
// encrypt soap document
if (null !== $this->serviceSecurityKey && $this->serviceSecurityKey->hasKeys()) {
$guid = 'EncKey-' . Helper::generateUUID();
$guid = 'EncKey-' . Helper::generateUuid();
// add token references
$keyInfo = null;
if (null !== $this->tokenReferenceEncryption) {
@ -226,10 +227,11 @@ class WsSecurityFilter extends WsSecurityFilterClientServer implements SoapReque
* Modify the given request XML.
*
* @param \BeSimple\SoapCommon\SoapResponse $response SOAP response
* @param int $attachmentType
*
* @return void
*/
public function filterResponse(CommonSoapResponse $response)
public function filterResponse(CommonSoapResponse $response, $attachmentType)
{
// get \DOMDocument from SOAP response
$dom = $response->getContentDocument();

View File

@ -78,8 +78,8 @@ class WsdlDownloader
throw new Exception('Could not write WSDL cache file: empty curl response from: '.$wsdlPath);
}
if ($resolveRemoteIncludes === true) {
$document = $this->getXmlFileDOMDocument($curl, $cacheType, $curlResponse->getResponseBody(), $wsdlPath);
$this->saveXmlDOMDocument($document, $cacheFilePath);
$document = $this->getXmlFileDomDocument($curl, $cacheType, $curlResponse->getResponseBody(), $wsdlPath);
$this->saveXmlDomDocument($document, $cacheFilePath);
} else {
file_put_contents($cacheFilePath, $curlResponse->getResponseBody());
}
@ -88,8 +88,8 @@ class WsdlDownloader
}
} else {
if (file_exists($wsdlPath)) {
$document = $this->getXmlFileDOMDocument($curl, $cacheType, file_get_contents($wsdlPath));
$this->saveXmlDOMDocument($document, $cacheFilePath);
$document = $this->getXmlFileDomDocument($curl, $cacheType, file_get_contents($wsdlPath));
$this->saveXmlDomDocument($document, $cacheFilePath);
} else {
throw new Exception('Could write WSDL cache file: local file does not exist: '.$wsdlPath);
}
@ -102,9 +102,9 @@ class WsdlDownloader
return realpath($wsdlPath);
} else {
throw new Exception('Could not download WSDL: local file does not exist: '.$wsdlPath);
}
throw new Exception('Could not download WSDL: local file does not exist: '.$wsdlPath);
}
/**
@ -118,11 +118,9 @@ class WsdlDownloader
if (isset($parsedUrlOrFalse['scheme']) && substr($parsedUrlOrFalse['scheme'], 0, 4) === 'http') {
return true;
} else {
return false;
}
return false;
}
throw new Exception('Could not determine wsdlPath is remote: '.$wsdlPath);
@ -137,7 +135,7 @@ class WsdlDownloader
* @param boolean $parentFilePath Parent file name
* @return DOMDocument
*/
private function getXmlFileDOMDocument(Curl $curl, $cacheType, $xmlFileSource, $parentFilePath = null)
private function getXmlFileDomDocument(Curl $curl, $cacheType, $xmlFileSource, $parentFilePath = null)
{
$document = new DOMDocument('1.0', 'utf-8');
if ($document->loadXML($xmlFileSource) === false) {
@ -151,7 +149,7 @@ class WsdlDownloader
return $document;
}
private function saveXmlDOMDocument(DOMDocument $document, $cacheFilePath)
private function saveXmlDomDocument(DOMDocument $document, $cacheFilePath)
{
try {
$xmlContents = $document->saveXML();
@ -191,7 +189,7 @@ class WsdlDownloader
true
)
);
} else if ($parentFilePath !== null) {
} elseif ($parentFilePath !== null) {
$node->setAttribute(
$locationAttributeName,
$this->getWsdlPath(

View File

@ -113,4 +113,4 @@ class Cache
{
ini_set($key, $value);
}
}
}

View File

@ -44,4 +44,3 @@ class DateTimeTypeConverter implements TypeConverterInterface
return sprintf('<%1$s>%2$s</%1$s>', $this->getTypeName(), $data->format('Y-m-d\TH:i:sP'));
}
}

View File

@ -44,4 +44,3 @@ class DateTypeConverter implements TypeConverterInterface
return sprintf('<%1$s>%2$s</%1$s>', $this->getTypeName(), $data->format('Y-m-d'));
}
}

View File

@ -74,10 +74,10 @@ class TypeConverterCollection
$typemap[] = array(
'type_name' => $converter->getTypeName(),
'type_ns' => $converter->getTypeNamespace(),
'from_xml' => function($input) use ($converter) {
'from_xml' => function ($input) use ($converter) {
return $converter->convertXmlToPhp($input);
},
'to_xml' => function($input) use ($converter) {
'to_xml' => function ($input) use ($converter) {
return $converter->convertPhpToXml($input);
},
);

View File

@ -24,14 +24,14 @@ interface TypeConverterInterface
*
* @return string
*/
function getTypeNamespace();
public function getTypeNamespace();
/**
* Get type name.
*
* @return string
*/
function getTypeName();
public function getTypeName();
/**
* Convert given XML string to PHP type.
@ -40,7 +40,7 @@ interface TypeConverterInterface
*
* @return mixed
*/
function convertXmlToPhp($data);
public function convertXmlToPhp($data);
/**
* Convert PHP type to XML string.
@ -49,5 +49,5 @@ interface TypeConverterInterface
*
* @return string
*/
function convertPhpToXml($data);
}
public function convertPhpToXml($data);
}

View File

@ -175,4 +175,4 @@ class FilterHelper
$this->namespaces[$namespaceURI] = $prefix;
}
}
}
}

View File

@ -167,12 +167,13 @@ class Helper
* @see http://de.php.net/manual/en/function.uniqid.php#94959
* @return string
*/
public static function generateUUID()
public static function generateUuid()
{
return sprintf(
'%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
// 32 bits for "time_low"
mt_rand(0, 0xffff), mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
// 16 bits for "time_mid"
mt_rand(0, 0xffff),
// 16 bits for "time_hi_and_version",
@ -183,7 +184,9 @@ class Helper
// two most significant bits holds zero and one for variant DCE1.1
mt_rand(0, 0x3fff) | 0x8000,
// 48 bits for "node"
mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
mt_rand(0, 0xffff)
);
}
@ -198,9 +201,9 @@ class Helper
{
if ($version === SOAP_1_2) {
return self::NS_SOAP_1_2;
} else {
return self::NS_SOAP_1_1;
}
return self::NS_SOAP_1_1;
}
/**
@ -214,8 +217,8 @@ class Helper
{
if ($namespace === self::NS_SOAP_1_2) {
return SOAP_1_2;
} else {
return SOAP_1_1;
}
return SOAP_1_1;
}
}
}

View File

@ -179,11 +179,11 @@ class MultiPart extends PartHeader
*/
public function generateBoundary()
{
return 'multipart-boundary-' . Helper::generateUUID() . '@response.info';
return 'multipart-boundary-' . Helper::generateUuid() . '@response.info';
}
public function getMainPartContentId()
{
return $this->mainPartContentId;
}
}
}

View File

@ -113,7 +113,7 @@ class ParsedPartsGetter
$hitFirstBoundary = true;
$inHeader = true;
$messagePartStringContent = '';
} else if (MimeBoundaryAnalyser::isMessageLineLastBoundary($mimeMessageLine, $contentTypeBoundary)) {
} elseif (MimeBoundaryAnalyser::isMessageLineLastBoundary($mimeMessageLine, $contentTypeBoundary)) {
$currentPartContent = self::decodeContent(
$currentPart,
substr($messagePartStringContent, 0, -1)
@ -166,7 +166,7 @@ class ParsedPartsGetter
if ($encoding === Part::ENCODING_BASE64) {
$partStringContent = base64_decode($partStringContent);
} else if ($encoding === Part::ENCODING_QUOTED_PRINTABLE) {
} elseif ($encoding === Part::ENCODING_QUOTED_PRINTABLE) {
$partStringContent = quoted_printable_decode($partStringContent);
}

View File

@ -154,6 +154,6 @@ class Part extends PartHeader
*/
protected function generateContentId()
{
return 'part-' . Helper::generateUUID() . '@response.info';
return 'part-' . Helper::generateUuid() . '@response.info';
}
}
}

View File

@ -92,14 +92,14 @@ abstract class SoapMessage
/**
* SOAP version (SOAP_1_1|SOAP_1_2)
*
* @var string
* @var int
*/
protected $version;
/**
* Get content type for given SOAP version.
*
* @param string $version SOAP version constant SOAP_1_1|SOAP_1_2
* @param int $version SOAP version constant SOAP_1_1|SOAP_1_2
*
* @return string
* @throws \InvalidArgumentException
@ -232,9 +232,9 @@ abstract class SoapMessage
}
/**
* Get version.
* Get SOAP version SOAP_1_1|SOAP_1_2
*
* @return string
* @return int
*/
public function getVersion()
{
@ -244,7 +244,7 @@ abstract class SoapMessage
/**
* Set version.
*
* @param string $version SOAP version SOAP_1_1|SOAP_1_2
* @param int $version SOAP version SOAP_1_1|SOAP_1_2
*/
public function setVersion($version)
{

View File

@ -36,7 +36,7 @@ class SoapRequestFactory
*
* @param string $location Location
* @param string $action SOAP action
* @param string $version SOAP version
* @param int $version SOAP version
* @param string $content Content
* @return SoapRequest
*/

View File

@ -27,4 +27,4 @@ interface SoapRequestFilter
* @param int $attachmentType = SoapOptions::SOAP_ATTACHMENTS_TYPE_SWA|SoapOptions::ATTACHMENTS_TYPE_MTOM|SoapOptions::ATTACHMENTS_TYPE_BASE64
*/
public function filterRequest(SoapRequest $request, $attachmentType);
}
}

View File

@ -29,4 +29,4 @@ interface SoapResponseFilter
* @param int $attachmentType = SoapOptions::SOAP_ATTACHMENTS_TYPE_SWA|SoapOptions::ATTACHMENTS_TYPE_MTOM|SoapOptions::ATTACHMENTS_TYPE_BASE64
*/
public function filterResponse(SoapResponse $response, $attachmentType);
}
}

View File

@ -1,211 +0,0 @@
<?php
/*
* This file is part of the BeSimpleSoapBundle.
*
* (c) Christian Kerl <christian-kerl@web.de>
* (c) Francis Besset <francis.besset@gmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace BeSimple\SoapCommon\Tests;
use BeSimple\SoapCommon\Cache;
use BeSimple\SoapCommon\Classmap;
use BeSimple\SoapCommon\Converter\DateTimeTypeConverter;
use BeSimple\SoapCommon\Converter\DateTypeConverter;
use BeSimple\SoapCommon\Converter\TypeConverterCollection;
use BeSimple\SoapCommon\Tests\Fixtures\SoapBuilder;
class AbstractSoapBuilderTest extends \PHPUnit_Framework_TestCase
{
private $defaultOptions = array(
'features' => 0,
'classmap' => array(),
'typemap' => array(),
);
public function testContruct()
{
$options = $this
->getSoapBuilder()
->getSoapOptions()
;
$this->assertEquals($this->mergeOptions(array()), $options);
}
public function testWithWsdl()
{
$builder = $this->getSoapBuilder();
$this->assertNull($builder->getWsdl());
$builder->withWsdl('http://myWsdl/?wsdl');
$this->assertEquals('http://myWsdl/?wsdl', $builder->getWsdl());
}
public function testWithSoapVersion()
{
$builder = $this->getSoapBuilder();
$builder->withSoapVersion11();
$this->assertEquals($this->mergeOptions(array('soap_version' => SOAP_1_1)), $builder->getSoapOptions());
$builder->withSoapVersion12();
$this->assertEquals($this->mergeOptions(array('soap_version' => SOAP_1_2)), $builder->getSoapOptions());
}
public function testWithEncoding()
{
$builder = $this
->getSoapBuilder()
->withEncoding('ISO 8859-15')
;
$this->assertEquals($this->mergeOptions(array('encoding' => 'ISO 8859-15')), $builder->getSoapOptions());
}
public function testWithWsdlCache()
{
$builder = $this->getSoapBuilder();
$builder->withWsdlCache(Cache::TYPE_DISK_MEMORY);
$this->assertEquals($this->mergeOptions(array('cache_wsdl' => Cache::TYPE_DISK_MEMORY)), $builder->getSoapOptions());
$builder->withWsdlCacheNone();
$this->assertEquals($this->mergeOptions(array('cache_wsdl' => Cache::TYPE_NONE)), $builder->getSoapOptions());
$builder->withWsdlCacheDisk();
$this->assertEquals($this->mergeOptions(array('cache_wsdl' => Cache::TYPE_DISK)), $builder->getSoapOptions());
$builder->withWsdlCacheMemory();
$this->assertEquals($this->mergeOptions(array('cache_wsdl' => Cache::TYPE_MEMORY)), $builder->getSoapOptions());
$builder->withWsdlCacheDiskAndMemory();
$this->assertEquals($this->mergeOptions(array('cache_wsdl' => Cache::TYPE_DISK_MEMORY)), $builder->getSoapOptions());
}
public function testWithWsdlCacheBadValue()
{
$builder = $this->getSoapBuilder();
$this->setExpectedException('InvalidArgumentException');
$builder->withWsdlCache('foo');
}
public function testWithSingleElementArrays()
{
$options = $this
->getSoapBuilder()
->withSingleElementArrays()
->getSoapOptions()
;
$this->assertEquals($this->mergeOptions(array('features' => SOAP_SINGLE_ELEMENT_ARRAYS)), $options);
}
public function testWithWaitOneWayCalls()
{
$options = $this
->getSoapBuilder()
->withWaitOneWayCalls()
->getSoapOptions()
;
$this->assertEquals($this->mergeOptions(array('features' => SOAP_WAIT_ONE_WAY_CALLS)), $options);
}
public function testWithUseXsiArrayType()
{
$options = $this
->getSoapBuilder()
->withUseXsiArrayType()
->getSoapOptions()
;
$this->assertEquals($this->mergeOptions(array('features' => SOAP_USE_XSI_ARRAY_TYPE)), $options);
}
public function testFeatures()
{
$builder = $this->getSoapBuilder();
$features = 0;
$builder->withSingleElementArrays();
$features |= SOAP_SINGLE_ELEMENT_ARRAYS;
$this->assertEquals($this->mergeOptions(array('features' => $features)), $builder->getSoapOptions());
$builder->withWaitOneWayCalls();
$features |= SOAP_WAIT_ONE_WAY_CALLS;
$this->assertEquals($this->mergeOptions(array('features' => $features)), $builder->getSoapOptions());
$builder->withUseXsiArrayType();
$features |= SOAP_USE_XSI_ARRAY_TYPE;
$this->assertEquals($this->mergeOptions(array('features' => $features)), $builder->getSoapOptions());
}
public function testWithTypeConverters()
{
$builder = $this->getSoapBuilder();
$builder->withTypeConverter(new DateTypeConverter());
$options = $builder->getSoapOptions();
$this->assertEquals(1, count($options['typemap']));
$converters = new TypeConverterCollection();
$converters->add(new DateTimeTypeConverter());
$builder->withTypeConverters($converters);
$options = $builder->getSoapOptions();
$this->assertEquals(2, count($options['typemap']));
$builder->withTypeConverters($converters, false);
$options = $builder->getSoapOptions();
$this->assertEquals(1, count($options['typemap']));
}
public function testClassmap()
{
$builder = $this->getSoapBuilder();
$builder->withClassMapping('foo', __CLASS__);
$options = $builder->getSoapOptions();
$this->assertEquals(1, count($options['classmap']));
$classmap = new ClassMap();
$classmap->add('bar', __CLASS__);
$builder->withClassmap($classmap);
$options = $builder->getSoapOptions();
$this->assertEquals(2, count($options['classmap']));
$builder->withClassmap($classmap, false);
$options = $builder->getSoapOptions();
$this->assertEquals(1, count($options['classmap']));
}
public function testCreateWithDefaults()
{
$builder = SoapBuilder::createWithDefaults();
$this->assertInstanceOf('BeSimple\SoapCommon\Tests\Fixtures\SoapBuilder', $builder);
$this->assertEquals($this->mergeOptions(array('soap_version' => SOAP_1_2, 'encoding' => 'UTF-8', 'features' => SOAP_SINGLE_ELEMENT_ARRAYS)), $builder->getSoapOptions());
}
private function getSoapBuilder()
{
return new SoapBuilder();
}
private function mergeOptions(array $options)
{
return array_merge($this->defaultOptions, $options);
}
}

View File

@ -16,7 +16,7 @@ use BeSimple\SoapCommon\Cache;
use org\bovigo\vfs\vfsStream;
use org\bovigo\vfs\vfsStreamWrapper;
class SoapRequestTest extends \PHPUnit_Framework_TestCase
class CacheTest extends \PHPUnit_Framework_TestCase
{
public function testSetEnabled()
{

View File

@ -51,4 +51,3 @@ class DateTimeTypeConverterTest extends \PHPUnit_Framework_TestCase
$this->assertNull($date);
}
}

View File

@ -49,4 +49,3 @@ class DateTypeConverterTest extends \PHPUnit_Framework_TestCase
$this->assertNull($date);
}
}

View File

@ -30,19 +30,19 @@ class TypeConverterCollectionTest extends \PHPUnit_Framework_TestCase
$dateTimeTypeConverter = new DateTimeTypeConverter();
$converters->add($dateTimeTypeConverter);
$this->assertSame(array($dateTimeTypeConverter), $converters->getAll());
$this->assertSame([$dateTimeTypeConverter], $converters->getAll());
$dateTypeConverter = new DateTypeConverter();
$converters->add($dateTypeConverter);
$this->assertSame(array($dateTimeTypeConverter, $dateTypeConverter), $converters->getAll());
$this->assertSame([$dateTimeTypeConverter, $dateTypeConverter], $converters->getAll());
}
public function testGetTypemap()
{
$converters = new TypeConverterCollection();
$this->assertEquals(array(), $converters->getTypemap());
$this->assertEquals([], $converters->getTypemap());
$dateTimeTypeConverter = new DateTimeTypeConverter();
$converters->add($dateTimeTypeConverter);
@ -70,7 +70,9 @@ class TypeConverterCollectionTest extends \PHPUnit_Framework_TestCase
$dateTimeTypeConverter = new DateTimeTypeConverter();
$converters->add($dateTimeTypeConverter);
$converter = array(new DateTypeConverter);
$converter = [
new DateTypeConverter()
];
$converters->set($converter);
$this->assertSame($converter, $converters->getAll());
@ -85,9 +87,9 @@ class TypeConverterCollectionTest extends \PHPUnit_Framework_TestCase
$converters2->add($dateTimeTypeConverter);
$converters1->addCollection($converters2);
$this->assertSame(array($dateTimeTypeConverter), $converters1->getAll());
$this->assertSame([$dateTimeTypeConverter], $converters1->getAll());
$this->setExpectedException('InvalidArgumentException');
$converters1->addCollection($converters2);
}
}
}

View File

@ -131,13 +131,13 @@ class MultiPartTest extends \PHPUnit_Framework_TestCase
$mp->addPart($p2);
$withoutMain = array(
trim($p2->getHeader('Content-ID'),'<>') => $p2,
trim($p2->getHeader('Content-ID'), '<>') => $p2,
);
$this->assertEquals($withoutMain, $mp->getParts());
$withMain = array(
trim($p1->getHeader('Content-ID'),'<>') => $p1,
trim($p2->getHeader('Content-ID'),'<>') => $p2,
trim($p1->getHeader('Content-ID'), '<>') => $p1,
trim($p2->getHeader('Content-ID'), '<>') => $p2
);
$this->assertEquals($withMain, $mp->getParts(true));
}

View File

@ -115,7 +115,8 @@ class ParserTest extends \PHPUnit_Framework_TestCase
$mimeMessage = file_get_contents($filename);
$headers = array(
'Content-Type' => 'multipart/related; type="application/xop+xml";start="<http://tempuri.org/0>";boundary="uuid:0ca0e16e-feb1-426c-97d8-c4508ada5e82+id=7";start-info="application/soap+xml"',
'Content-Type' =>
'multipart/related; type="application/xop+xml";start="<http://tempuri.org/0>";boundary="uuid:0ca0e16e-feb1-426c-97d8-c4508ada5e82+id=7";start-info="application/soap+xml"',
'Content-Length' => 1941,
'Host' => '131.107.72.15',
'Expect' => '100-continue',

View File

@ -325,7 +325,6 @@ abstract class WsSecurityFilterClientServer
if (Helper::NS_WSS === $key->namespaceURI) {
switch ($key->localName) {
case 'KeyIdentifier':
return $this->serviceSecurityKey->getPublicKey();
case 'Reference':
$uri = $key->getAttribute('URI');
@ -336,7 +335,8 @@ abstract class WsSecurityFilterClientServer
$key = XmlSecurityEnc::decryptEncryptedKey($referencedNode, $this->userSecurityKey->getPrivateKey());
return XmlSecurityKey::factory($algorithm, $key, false, XmlSecurityKey::TYPE_PRIVATE);
} elseif (Helper::NS_WSS === $referencedNode->namespaceURI
}
if (Helper::NS_WSS === $referencedNode->namespaceURI
&& 'BinarySecurityToken' == $referencedNode->localName) {
$key = XmlSecurityPem::formatKeyInPemFormat($referencedNode->textContent);

View File

@ -113,4 +113,4 @@ class WsSecurityKey
{
return null !== $this->publicKey;
}
}
}

View File

@ -1,26 +0,0 @@
<?php
/*
* This file is part of the BeSimpleSoapCommon.
*
* (c) Christian Kerl <christian-kerl@web.de>
* (c) Francis Besset <francis.besset@gmail.com>
* (c) Andreas Schamberger <mail@andreass.net>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace BeSimple\SoapServer\Exception;
/**
* ReceiverSoapFault send a "Receiver" fault code to client.
* This fault code is standardized: http://www.w3.org/TR/soap12-part1/#tabsoapfaultcodes
*/
class ReceiverSoapFault extends \SoapFault
{
public function __construct($faultstring, $faultactor = null, $detail = null, $faultname = null, $headerfault = null)
{
parent::__construct('Receiver', $faultstring, $faultactor, $detail, $faultname, $headerfault);
}
}

View File

@ -1,26 +0,0 @@
<?php
/*
* This file is part of the BeSimpleSoapCommon.
*
* (c) Christian Kerl <christian-kerl@web.de>
* (c) Francis Besset <francis.besset@gmail.com>
* (c) Andreas Schamberger <mail@andreass.net>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace BeSimple\SoapServer\Exception;
/**
* SenderSoapFault send a "Sender" fault code to client.
* This fault code is standardized: http://www.w3.org/TR/soap12-part1/#tabsoapfaultcodes
*/
class SenderSoapFault extends \SoapFault
{
public function __construct($faultstring, $faultactor = null, $detail = null, $faultname = null, $headerfault = null)
{
parent::__construct('Sender', $faultstring, $faultactor, $detail, $faultname, $headerfault);
}
}

View File

@ -21,6 +21,7 @@ class SoapServerOptions
private $handlerObject;
private $keepAlive;
private $errorReporting;
private $exceptions;
private $persistence;
/**
@ -47,18 +48,20 @@ class SoapServerOptions
public function getHandler()
{
if ($this->hasHandlerObject() && $this->hasHandlerClass()) {
throw new Exception('Both HandlerClass and HandlerObject set: please specify only one');
}
if ($this->hasHandlerObject()) {
return $this->getHandlerObject();
} else if ($this->hasHandlerClass()) {
}
if ($this->hasHandlerClass()) {
return $this->getHandlerClass();
} else {
throw new Exception('No HandlerClass or HandlerObject set');
}
throw new Exception('No HandlerClass or HandlerObject set');
}
public function getHandlerInstance()
@ -94,7 +97,7 @@ class SoapServerOptions
public function hasPersistence()
{
return $this->persistence !== SoapServerOptions::SOAP_SERVER_PERSISTENCE_NONE;
return $this->persistence !== self::SOAP_SERVER_PERSISTENCE_NONE;
}
public function getPersistence()
@ -136,14 +139,13 @@ class SoapServerOptions
if (is_string($handler) && class_exists($handler)) {
return null;
} elseif (is_object($handler)) {
}
if (is_object($handler)) {
return $handler;
} else {
throw new \InvalidArgumentException('The handler has to be a class name or an object');
}
throw new \InvalidArgumentException('The handler has to be a class name or an object');
}
/**
@ -155,13 +157,12 @@ class SoapServerOptions
if (is_string($handler) && class_exists($handler)) {
return $handler;
} elseif (is_object($handler)) {
}
if (is_object($handler)) {
return null;
} else {
throw new \InvalidArgumentException('The handler has to be a class name or an object');
}
throw new \InvalidArgumentException('The handler has to be a class name or an object');
}
}

View File

@ -14,6 +14,7 @@ namespace BeSimple\SoapServer;
use BeSimple\SoapCommon\SoapOptions\SoapOptions;
use BeSimple\SoapServer\SoapOptions\SoapServerOptions;
use Exception;
/**
* SoapServerBuilder provides a SoapServer instance from SoapServerOptions and SoapOptions.
@ -40,9 +41,16 @@ class SoapServerBuilder
}
if ($soapServerOptions->hasHandlerClass()) {
$server->setClass($soapServerOptions->getHandlerClass());
} else if ($soapServerOptions->hasHandlerObject()) {
}
if ($soapServerOptions->hasHandlerObject()) {
$server->setObject($soapServerOptions->getHandlerObject());
}
if ($soapServerOptions->hasHandlerClass() && $soapServerOptions->hasHandlerObject()) {
throw new Exception(
'Could not create SoapServer: HandlerClass and HandlerObject are set: please specify only one'
);
}
return $server;
}

View File

@ -67,10 +67,11 @@ class WsSecurityFilter extends WsSecurityFilterClientServer implements SoapReque
* Modify the given request XML.
*
* @param \BeSimple\SoapCommon\SoapRequest $request SOAP request
* @param int $attachmentType
*
* @return void
*/
public function filterRequest(CommonSoapRequest $request)
public function filterRequest(CommonSoapRequest $request, $attachmentType)
{
// get \DOMDocument from SOAP request
$dom = $request->getContentDocument();
@ -152,10 +153,11 @@ class WsSecurityFilter extends WsSecurityFilterClientServer implements SoapReque
* Modify the given request XML.
*
* @param \BeSimple\SoapCommon\SoapResponse $response SOAP response
* @param int $attachmentType
*
* @return void
*/
public function filterResponse(CommonSoapResponse $response)
public function filterResponse(CommonSoapResponse $response, $attachmentType)
{
// get \DOMDocument from SOAP response
$dom = $response->getContentDocument();
@ -190,7 +192,7 @@ class WsSecurityFilter extends WsSecurityFilterClientServer implements SoapReque
}
if (null !== $this->userSecurityKey && $this->userSecurityKey->hasKeys()) {
$guid = 'CertId-' . Helper::generateUUID();
$guid = 'CertId-' . Helper::generateUuid();
// add token references
$keyInfo = null;
if (null !== $this->tokenReferenceSignature) {
@ -216,7 +218,7 @@ class WsSecurityFilter extends WsSecurityFilterClientServer implements SoapReque
// encrypt soap document
if (null !== $this->serviceSecurityKey && $this->serviceSecurityKey->hasKeys()) {
$guid = 'EncKey-' . Helper::generateUUID();
$guid = 'EncKey-' . Helper::generateUuid();
// add token references
$keyInfo = null;
if (null !== $this->tokenReferenceEncryption) {