Reorganized directories structure

This commit is contained in:
Francis Besset
2013-07-19 11:28:23 +02:00
parent 9328c98935
commit b78bf408bf
136 changed files with 179 additions and 365 deletions

View File

@ -0,0 +1,211 @@
<?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

@ -0,0 +1,94 @@
<?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 org\bovigo\vfs\vfsStream;
use org\bovigo\vfs\vfsStreamWrapper;
class SoapRequestTest extends \PHPUnit_Framework_TestCase
{
public function testSetEnabled()
{
Cache::setEnabled(Cache::ENABLED);
$this->assertEquals(Cache::ENABLED, Cache::isEnabled());
Cache::setEnabled(Cache::DISABLED);
$this->assertEquals(Cache::DISABLED, Cache::isEnabled());
}
public function testSetEnabledBadValue()
{
$this->setExpectedException('InvalidArgumentException');
Cache::setEnabled('foo');
}
public function testSetType()
{
Cache::setType(Cache::TYPE_DISK);
$this->assertEquals(Cache::TYPE_DISK, Cache::getType());
Cache::setType(Cache::TYPE_NONE);
$this->assertEquals(Cache::TYPE_NONE, Cache::getType());
}
public function testSetTypeBadValue()
{
$this->setExpectedException('InvalidArgumentException');
Cache::setType('foo');
}
public function testSetDirectory()
{
vfsStream::setup('Fixtures');
$this->assertFalse(vfsStreamWrapper::getRoot()->hasChild('foo'));
$dir = vfsStream::url('Fixtures/foo');
Cache::setDirectory($dir);
$this->assertEquals($dir, Cache::getDirectory());
$this->assertTrue(vfsStreamWrapper::getRoot()->hasChild('foo'));
$this->assertFalse(vfsStreamWrapper::getRoot()->hasChild('bar'));
$dir = vfsStream::url('Fixtures/bar');
Cache::setDirectory($dir);
$this->assertEquals($dir, Cache::getDirectory());
$this->assertTrue(vfsStreamWrapper::getRoot()->hasChild('bar'));
}
public function testSetLifetime()
{
Cache::setLifetime(1234);
$this->assertEquals(1234, Cache::getLifetime());
Cache::setLifetime(4321);
$this->assertEquals(4321, Cache::getLifetime());
}
public function testSetLimit()
{
Cache::setLimit(10);
$this->assertEquals(10, Cache::getLimit());
Cache::setLimit(1);
$this->assertEquals(1, Cache::getLimit());
}
public function setUp()
{
ini_restore('soap.wsdl_cache_enabled');
ini_restore('soap.wsdl_cache');
ini_restore('soap.wsdl_cache_dir');
ini_restore('soap.wsdl_cache_ttl');
ini_restore('soap.wsdl_cache_limit');
}
}

View File

@ -0,0 +1,81 @@
<?php
/*
* This file is part of the BeSimpleSoapCommon.
*
* (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\Classmap;
/**
* UnitTest for \BeSimple\SoapCommon\Classmap.
*
* @author Francis Besset <francis.besset@gmail.com>
*/
class ClassmapTest extends \PHPUnit_Framework_TestCase
{
public function testAll()
{
$classmap = new Classmap();
$this->assertSame(array(), $classmap->all());
}
public function testAdd()
{
$classmap = new Classmap();
$classmap->add('foobar', 'BeSimple\SoapCommon\Classmap');
$this->setExpectedException('InvalidArgumentException');
$classmap->add('foobar', 'BeSimple\SoapCommon\Classmap');
}
public function testGet()
{
$classmap = new Classmap();
$classmap->add('foobar', 'BeSimple\SoapCommon\Classmap');
$this->assertSame('BeSimple\SoapCommon\Classmap', $classmap->get('foobar'));
$this->setExpectedException('InvalidArgumentException');
$classmap->get('bar');
}
public function testSet()
{
$classmap = new Classmap();
$classmap->add('foobar', 'BeSimple\SoapCommon\Tests\ClassmapTest');
$classmap->add('foo', 'BeSimple\SoapCommon\Tests\Classmap');
$map = array(
'foobar' => 'BeSimple\SoapCommon\Classmap',
'barfoo' => 'BeSimple\SoapCommon\Tests\ClassmapTest',
);
$classmap->set($map);
$this->assertSame($map, $classmap->all());
}
public function testAddClassmap()
{
$classmap1 = new Classmap();
$classmap2 = new Classmap();
$classmap2->add('foobar', 'BeSimple\SoapCommon\Classmap');
$classmap1->addClassmap($classmap2);
$this->assertEquals(array('foobar' => 'BeSimple\SoapCommon\Classmap'), $classmap1->all());
$this->setExpectedException('InvalidArgumentException');
$classmap1->addClassmap($classmap2);
}
}

View File

@ -0,0 +1,54 @@
<?php
/*
* This file is part of the BeSimpleSoapCommon.
*
* (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\Converter;
use BeSimple\SoapCommon\Converter\DateTimeTypeConverter;
/**
* UnitTest for \BeSimple\SoapCommon\Converter\DateTimeTypeConverter.
*
* @author Christian Kerl <christian-kerl@web.de>
*/
class DateTimeTypeConverterTest extends \PHPUnit_Framework_TestCase
{
public function testConvertXmlToPhp()
{
$converter = new DateTimeTypeConverter();
$dateXml = '<sometag>2002-10-10T12:00:00-05:00</sometag>';
$date = $converter->convertXmlToPhp($dateXml);
$this->assertEquals(new \DateTime('2002-10-10T12:00:00-05:00'), $date);
}
public function testConvertPhpToXml()
{
$converter = new DateTimeTypeConverter();
$date = new \DateTime('2002-10-10T12:00:00-05:00');
$dateXml = $converter->convertPhpToXml($date);
$this->assertEquals('<dateTime>2002-10-10T12:00:00-05:00</dateTime>', $dateXml);
}
public function testConvertNullDateTimeXmlToPhp()
{
$converter = new DateTimeTypeConverter();
$dateXml = '<sometag xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>';
$date = $converter->convertXmlToPhp($dateXml);
$this->assertNull($date);
}
}

View File

@ -0,0 +1,52 @@
<?php
/*
* This file is part of the BeSimpleSoapCommon.
*
* (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\Converter;
use BeSimple\SoapCommon\Converter\DateTypeConverter;
/**
* UnitTest for \BeSimple\SoapCommon\Converter\DateTypeConverter.
*/
class DateTypeConverterTest extends \PHPUnit_Framework_TestCase
{
public function testConvertXmlToPhp()
{
$converter = new DateTypeConverter();
$dateXml = '<sometag>2002-10-10</sometag>';
$date = $converter->convertXmlToPhp($dateXml);
$this->assertEquals(new \DateTime('2002-10-10'), $date);
}
public function testConvertPhpToXml()
{
$converter = new DateTypeConverter();
$date = new \DateTime('2002-10-10');
$dateXml = $converter->convertPhpToXml($date);
$this->assertEquals('<date>2002-10-10</date>', $dateXml);
}
public function testConvertNullDateTimeXmlToPhp()
{
$converter = new DateTypeConverter();
$dateXml = '<sometag xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>';
$date = $converter->convertXmlToPhp($dateXml);
$this->assertNull($date);
}
}

View File

@ -0,0 +1,93 @@
<?php
/*
* This file is part of the BeSimpleSoapCommon.
*
* (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\Converter;
use BeSimple\SoapCommon\Converter\TypeConverterCollection;
use BeSimple\SoapCommon\Converter\DateTimeTypeConverter;
use BeSimple\SoapCommon\Converter\DateTypeConverter;
/**
* UnitTest for \BeSimple\SoapCommon\Converter\TypeConverterCollection.
*
* @author Francis Besset <francis.besset@gmail.com>
*/
class TypeConverterCollectionTest extends \PHPUnit_Framework_TestCase
{
public function testAdd()
{
$converters = new TypeConverterCollection();
$dateTimeTypeConverter = new DateTimeTypeConverter();
$converters->add($dateTimeTypeConverter);
$this->assertSame(array($dateTimeTypeConverter), $converters->all());
$dateTypeConverter = new DateTypeConverter();
$converters->add($dateTypeConverter);
$this->assertSame(array($dateTimeTypeConverter, $dateTypeConverter), $converters->all());
}
public function testGetTypemap()
{
$converters = new TypeConverterCollection();
$this->assertEquals(array(), $converters->getTypemap());
$dateTimeTypeConverter = new DateTimeTypeConverter();
$converters->add($dateTimeTypeConverter);
$dateTypeConverter = new DateTypeConverter();
$converters->add($dateTypeConverter);
$typemap = $converters->getTypemap();
$this->assertEquals('http://www.w3.org/2001/XMLSchema', $typemap[0]['type_ns']);
$this->assertEquals('dateTime', $typemap[0]['type_name']);
$this->assertInstanceOf('Closure', $typemap[0]['from_xml']);
$this->assertInstanceOf('Closure', $typemap[0]['to_xml']);
$this->assertEquals('http://www.w3.org/2001/XMLSchema', $typemap[1]['type_ns']);
$this->assertEquals('date', $typemap[1]['type_name']);
$this->assertInstanceOf('Closure', $typemap[1]['from_xml']);
$this->assertInstanceOf('Closure', $typemap[1]['to_xml']);
}
public function testSet()
{
$converters = new TypeConverterCollection();
$dateTimeTypeConverter = new DateTimeTypeConverter();
$converters->add($dateTimeTypeConverter);
$converter = array(new DateTypeConverter);
$converters->set($converter);
$this->assertSame($converter, $converters->all());
}
public function testAddCollection()
{
$converters1 = new TypeConverterCollection();
$converters2 = new TypeConverterCollection();
$dateTimeTypeConverter = new DateTimeTypeConverter();
$converters2->add($dateTimeTypeConverter);
$converters1->addCollection($converters2);
$this->assertSame(array($dateTimeTypeConverter), $converters1->all());
$this->setExpectedException('InvalidArgumentException');
$converters1->addCollection($converters2);
}
}

View File

@ -0,0 +1,9 @@
<?php
namespace BeSimple\SoapCommon\Tests\Fixtures;
use BeSimple\SoapCommon\Mime\PartHeader;
class MimePartHeader extends PartHeader
{
}

View File

@ -0,0 +1,9 @@
<?php
namespace BeSimple\SoapCommon\Tests\Fixtures;
use BeSimple\SoapCommon\AbstractSoapBuilder;
class SoapBuilder extends AbstractSoapBuilder
{
}

View File

@ -0,0 +1,29 @@
HTTP/1.1 401 Authorization Required
Date: Fri, 12 Feb 2010 15:46:00 GMT
Server: Server
WWW-Authenticate: Basic realm="Realm"
Content-Length: 0
Cneonction: close
Content-Type: text/plain
HTTP/1.1 200 OK
Date: Fri, 12 Feb 2010 15:46:00 GMT
Server: Server
MIME-Version: 1.0
Cneonction: close
Transfer-Encoding: chunked
Content-Type: multipart/related; boundary="xxx-MIME-Boundary-xxx-0xa36cb38-0a36cb38-xxx-END-xxx"; type="text/xml"
--xxx-MIME-Boundary-xxx-0xa36cb38-0a36cb38-xxx-END-xxx
Content-Type: text/xml; charset="UTF-8"
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SE="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:doc href="cid:0x9d6ad00-0xa19ef48-0x9de7500-0xa4fae78-0xa382698" xmlns:ns1="http://myservice/schema/"/></SOAP-ENV:Body></SOAP-ENV:Envelope>
--xxx-MIME-Boundary-xxx-0xa36cb38-0a36cb38-xxx-END-xxx
Content-ID: <0x9d6ad00-0xa19ef48-0x9de7500-0xa4fae78-0xa382698>
Content-Type: application/binary
<?xml version="1.0" encoding="UTF-8"?>
<XmlDocument><NoContent/></XmlDocument>
--xxx-MIME-Boundary-xxx-0xa36cb38-0a36cb38-xxx-END-xxx--

View File

@ -0,0 +1,13 @@
HTTP/1.1 200 OK
Date: Sat, 11 Sep 2010 12:52:57 GMT
Server: Simple-Server/1.1
Transfer-Encoding: chunked
Content-Type: multipart/related; boundary=MIMEBoundaryurn_uuid_2DB7ABF3DC5BED7FA51284209577582; type="application/soap+xml"; start="<0.urn:uuid:2DB7ABF3DC5BED7FA51284209577583@apache.org>"; action="urn:getVersionResponse"
--MIMEBoundaryurn_uuid_2DB7ABF3DC5BED7FA51284209577582
Content-Type: application/soap+xml; charset=utf-8
Content-Transfer-Encoding: 8bit
Content-ID: <0.urn:uuid:2DB7ABF3DC5BED7FA51284209577583@apache.org>
<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"><wsa:Action>urn:getVersionResponse</wsa:Action><wsa:RelatesTo>uuid:665aab53-4cef-4435-8934-4c10ed24fd42</wsa:RelatesTo></soapenv:Header><soapenv:Body><ns:getVersionResponse xmlns:ns="http://axisversion.sample"><ns:return>Hi - the Axis2 version is 1.5.1</ns:return></ns:getVersionResponse></soapenv:Body></soapenv:Envelope>
--MIMEBoundaryurn_uuid_2DB7ABF3DC5BED7FA51284209577582--

View File

@ -0,0 +1,22 @@
POST http://131.107.72.15/Mtom/svc/service.svc/Soap12MtomUTF8 HTTP/1.1
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"
Host: 131.107.72.15
Content-Length: 1941
Expect: 100-continue
HTTP/1.1 100 Continue
--uuid:0ca0e16e-feb1-426c-97d8-c4508ada5e82+id=7
Content-ID: <http://tempuri.org/0>
Content-Transfer-Encoding: 8bit
Content-Type: application/xop+xml;charset=utf-8;type="application/soap+xml"
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing"><s:Header><a:Action s:mustUnderstand="1">http://xmlsoap.org/echoBinaryAsString</a:Action><a:MessageID>urn:uuid:1bf061d6-d532-4b0c-930b-8b8202c38b8a</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><a:To s:mustUnderstand="1">http://131.107.72.15/Mtom/svc/service.svc/Soap12MtomUTF8</a:To></s:Header><s:Body><EchoBinaryAsString xmlns="http://xmlsoap.org/Ping"><array><xop:Include href="cid:http%3A%2F%2Ftempuri.org%2F1%2F632618206527087310" xmlns:xop="http://www.w3.org/2004/08/xop/include"/></array></EchoBinaryAsString></s:Body></s:Envelope>
--uuid:0ca0e16e-feb1-426c-97d8-c4508ada5e82+id=7
Content-ID: <http://tempuri.org/1/632618206527087310>
Content-Transfer-Encoding: binary
Content-Type: application/octet-stream
H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d !
--uuid:0ca0e16e-feb1-426c-97d8-c4508ada5e82+id=7--

View File

@ -0,0 +1,16 @@
--uuid:0ca0e16e-feb1-426c-97d8-c4508ada5e82+id=7
Content-ID: <http://tempuri.org/0>
Content-Transfer-Encoding: 8bit
Content-Type: application/xop+xml;charset=utf-8;type="application/soap+xml"
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing"><s:Header><a:Action s:mustUnderstand="1">http://xmlsoap.org/echoBinaryAsString</a:Action><a:MessageID>urn:uuid:1bf061d6-d532-4b0c-930b-8b8202c38b8a</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><a:To s:mustUnderstand="1">http://131.107.72.15/Mtom/svc/service.svc/Soap12MtomUTF8</a:To></s:Header><s:Body><EchoBinaryAsString xmlns="http://xmlsoap.org/Ping"><array><xop:Include href="cid:http%3A%2F%2Ftempuri.org%2F1%2F632618206527087310" xmlns:xop="http://www.w3.org/2004/08/xop/include"/></array></EchoBinaryAsString></s:Body></s:Envelope>
--uuid:0ca0e16e-feb1-426c-97d8-c4508ada5e82+id=7
Content-ID: <http://tempuri.org/1/632618206527087310>
Content-Transfer-Encoding: binary
Content-Type: application/octet-stream
H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d ! H e l l o W o r l d !
--uuid:0ca0e16e-feb1-426c-97d8-c4508ada5e82+id=7--

View File

@ -0,0 +1,17 @@
HTTP/1.1 200 OK
Proxy-Connection: Keep-Alive
Connection: Keep-Alive
Content-Length: 1166
Via: 1.1 RED-PRXY-03
Date: Fri, 09 Sep 2005 06:57:22 GMT
Content-Type: multipart/related; type="application/xop+xml";start="<http://tempuri.org/0>";boundary="uuid:b71dc628-ec8f-4422-8a4a-992f041cb94c+id=46";start-info="application/soap+xml"
--uuid:b71dc628-ec8f-4422-8a4a-992f041cb94c+id=46
Content-ID: <http://tempuri.org/0>
Content-Transfer-Encoding: 8bit
Content-Type: application/xop+xml;charset=utf-8;type="application/soap+xml"
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing"><s:Header><a:Action s:mustUnderstand="1">*</a:Action><a:RelatesTo>urn:uuid:1bf061d6-d532-4b0c-930b-8b8202c38b8a</a:RelatesTo><a:To s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:To></s:Header><s:Body><EchoBinaryAsStringResponse xmlns="http://xmlsoap.org/Ping"><EchoBinaryAsStringResult>Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!</EchoBinaryAsStringResult></EchoBinaryAsStringResponse></s:Body></s:Envelope>
--uuid:b71dc628-ec8f-4422-8a4a-992f041cb94c+id=46--

View File

@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8" ?>
<wsdl:definitions xmlns:types="http://example.com/mimetypes"
xmlns:ref="http://ws-i.org/profiles/basic/1.1/xsd"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapbind="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
targetNamespace="http://example.com/mimewsdl"
xmlns:tns="http://example.com/mimewsdl">
<wsdl:types>
<xsd:schema targetNamespace="http://example.com/mimetypes"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="ClaimDetail" type="types:ClaimDetailType"/>
<xsd:complexType name="ClaimDetailType">
<xsd:sequence>
<xsd:element name="Name" type="xsd:string"/>
<!-- lots of other claim detail stuff -->
</xsd:sequence>
</xsd:complexType>
<xsd:element name="ClaimRefNo" type="xsd:string"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="ClaimIn">
<wsdl:part name="body" element="types:ClaimDetail"/>
<wsdl:part name="ClaimPhoto" type="xsd:base64Binary"/>
</wsdl:message>
<wsdl:message name="ClaimOut">
<wsdl:part name="out" element="types:ClaimRefNo"/>
</wsdl:message>
<wsdl:portType name="ClaimPortType">
<wsdl:operation name="SendClaim">
<wsdl:input message="tns:ClaimIn"/>
<wsdl:output message="tns:ClaimOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ClaimBinding" type="tns:ClaimPortType">
<soapbind:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="SendClaim">
<soapbind:operation soapAction="http://example.com/soapaction"/>
<wsdl:input>
<mime:multipartRelated>
<mime:part>
<soapbind:body parts="body" use="literal"/>
</mime:part>
<mime:part>
<mime:content part="ClaimPhoto" type="image/jpeg"/>
</mime:part>
</mime:multipartRelated>
</wsdl:input>
<wsdl:output>
<soapbind:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
</wsdl:definitions>

View File

@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8" ?>
<wsdl:definitions xmlns:types="http://example.com/mimetypes"
xmlns:ref="http://ws-i.org/profiles/basic/1.1/xsd"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapbind="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
targetNamespace="http://example.com/mimewsdl"
xmlns:tns="http://example.com/mimewsdl">
<wsdl:types>
<xsd:schema targetNamespace="http://example.com/mimetypes"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="ClaimDetail" type="types:ClaimDetailType"/>
<xsd:complexType name="ClaimDetailType">
<xsd:sequence>
<xsd:element name="Name" type="xsd:string"/>
<!-- lots of other claim detail stuff -->
</xsd:sequence>
</xsd:complexType>
<xsd:element name="ClaimRefNo" type="xsd:string"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="ClaimIn">
<wsdl:part name="body" element="types:ClaimDetail"/>
<wsdl:part name="ClaimPhoto" type="xsd:base64Binary"/>
</wsdl:message>
<wsdl:message name="ClaimOut">
<wsdl:part name="out" element="types:ClaimRefNo"/>
</wsdl:message>
<wsdl:portType name="ClaimPortType">
<wsdl:operation name="SendClaim">
<wsdl:input message="tns:ClaimIn"/>
<wsdl:output message="tns:ClaimOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ClaimBinding" type="tns:ClaimPortType">
<soapbind:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="SendClaim">
<soapbind:operation soapAction="http://example.com/soapaction"/>
<wsdl:input>
<mime:multipartRelated>
<mime:part>
<soapbind:body parts="body" use="literal"/>
</mime:part>
<mime:part>
<mime:content part="ClaimPhoto" type="image/*"/>
</mime:part>
</mime:multipartRelated>
</wsdl:input>
<wsdl:output>
<soapbind:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
</wsdl:definitions>

View File

@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8" ?>
<wsdl:definitions xmlns:types="http://example.com/mimetypes"
xmlns:ref="http://ws-i.org/profiles/basic/1.1/xsd"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapbind="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
targetNamespace="http://example.com/mimewsdl"
xmlns:tns="http://example.com/mimewsdl">
<wsdl:types>
<xsd:schema targetNamespace="http://example.com/mimetypes"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="ClaimDetail" type="types:ClaimDetailType"/>
<xsd:complexType name="ClaimDetailType">
<xsd:sequence>
<xsd:element name="Name" type="xsd:string"/>
<!-- lots of other claim detail stuff -->
</xsd:sequence>
</xsd:complexType>
<xsd:element name="ClaimRefNo" type="xsd:string"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="ClaimIn">
<wsdl:part name="body" element="types:ClaimDetail"/>
<wsdl:part name="ClaimPhoto" type="xsd:base64Binary"/>
</wsdl:message>
<wsdl:message name="ClaimOut">
<wsdl:part name="out" element="types:ClaimRefNo"/>
</wsdl:message>
<wsdl:portType name="ClaimPortType">
<wsdl:operation name="SendClaim">
<wsdl:input message="tns:ClaimIn"/>
<wsdl:output message="tns:ClaimOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ClaimBinding" type="tns:ClaimPortType">
<soapbind:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="SendClaim">
<soapbind:operation soapAction="http://example.com/soapaction"/>
<wsdl:input>
<mime:multipartRelated>
<mime:part>
<soapbind:body parts="body" use="literal"/>
</mime:part>
<mime:part>
<mime:content part="ClaimPhoto" type="*/*"/>
</mime:part>
</mime:multipartRelated>
</wsdl:input>
<wsdl:output>
<soapbind:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
</wsdl:definitions>

View File

@ -0,0 +1,17 @@
-----BEGIN CERTIFICATE-----
MIICoDCCAgkCBEnhw2IwDQYJKoZIhvcNAQEFBQAwgZYxCzAJBgNVBAYTAk5aMRMw
EQYDVQQIEwpXZWxsaW5ndG9uMRowGAYDVQQHExFQYXJhcGFyYXVtdSBCZWFjaDEq
MCgGA1UEChMhU29zbm9za2kgU29mdHdhcmUgQXNzb2NpYXRlcyBMdGQuMRAwDgYD
VQQLEwdVbmtub3duMRgwFgYDVQQDEw9EZW5uaXMgU29zbm9za2kwHhcNMDkwNDEy
MTAzMzA2WhcNMzYwODI3MTAzMzA2WjCBljELMAkGA1UEBhMCTloxEzARBgNVBAgT
CldlbGxpbmd0b24xGjAYBgNVBAcTEVBhcmFwYXJhdW11IEJlYWNoMSowKAYDVQQK
EyFTb3Nub3NraSBTb2Z0d2FyZSBBc3NvY2lhdGVzIEx0ZC4xEDAOBgNVBAsTB1Vu
a25vd24xGDAWBgNVBAMTD0Rlbm5pcyBTb3Nub3NraTCBnzANBgkqhkiG9w0BAQEF
AAOBjQAwgYkCgYEAhOVyNK8xyxtb4DnKtU6mF9KoiFqCk7eKoLE26+9h410CtTkx
zWAfgnR+8i+LPbdsPY+yXAo6NYpCCKolXfDLe+AG2GwnMZGrIl6+BLF3hqTmIXBF
TLGUmC7A7uBTivaWgdH1w3hb33rASoVU67BVtQ3QQi99juZX4vU9o9pScocCAwEA
ATANBgkqhkiG9w0BAQUFAAOBgQBMNPo1KAGbz8Jl6HGbtAcetieSJ3bEAXmv1tcj
ysBS67AXzdu1Ac+onHh2EpzBM7kuGbw+trU+AhulooPpewIQRApXP1F0KHRDcbqW
jwvknS6HnomN9572giLGKn2601bHiRUj35hiA8aLmMUBppIRPFFAoQ0QUBCPx+m8
/0n33w==
-----END CERTIFICATE-----

View File

@ -0,0 +1,14 @@
-----BEGIN PRIVATE KEY-----
MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAITlcjSvMcsbW+A5yrVOphfSqIha
gpO3iqCxNuvvYeNdArU5Mc1gH4J0fvIviz23bD2PslwKOjWKQgiqJV3wy3vgBthsJzGRqyJevgSx
d4ak5iFwRUyxlJguwO7gU4r2loHR9cN4W996wEqFVOuwVbUN0EIvfY7mV+L1PaPaUnKHAgMBAAEC
gYAZ6UqtLwN8YGc3fs0hMKZ9upsViuAuwPiMgED/G3twgzAF+ZLWQkmie+hMfCyf6eV200+pVm0n
Bz/8xH/oowxpX0Kk3szoB4vFghjU84GKUcrbhu/NRIm7l3drnfbzqhQkHDCx6n1CotI4Gs49cDWu
4uEAuxJkEIVY553unZjZgQJBAOJVIallNKmD0iQlvtWRmRzpmYDjt9vhNY6WBTIOx6SDn9SRaoSA
fkipQ2HXo04r78TQ674+zfZ1lRTkFG7px6ECQQCWUPHp3pSZOM1oGzJrNvNaw+MizZAZjq34npHm
9GRquFLG7BlCaI9QNGE7pN2ryYsYCRUMaM2e4GR0tUXxVGknAkAgrxqFU9AfCqI2Bh1gyf3KZxF7
w2axofwR8ygc6nV6FGfoUneHWubhp0/LuVAj4cRmL6Vbe8ZSaPh2Y9lviuMBAkEAicP8Q+1E4j1m
PPEYP51oYprANOiUFmhnWEL00+jPk+QFsd03tV6hYs/vAbwzkjuwqMHCMdJoCiH8z95IEUvc5wJA
MvLOuZdu4dmhOXg/YKsbMSPjFNEVskLQNSXqw6O2wIrpPg1NQvBBAOTbiuZj3vind4VPos1wc4vB
QocvdUC6dA==
-----END PRIVATE KEY-----

View File

@ -0,0 +1,17 @@
-----BEGIN CERTIFICATE-----
MIICoDCCAgkCBEnhwzMwDQYJKoZIhvcNAQEFBQAwgZYxCzAJBgNVBAYTAk5aMRMw
EQYDVQQIEwpXZWxsaW5ndG9uMRowGAYDVQQHExFQYXJhcGFyYXVtdSBCZWFjaDEq
MCgGA1UEChMhU29zbm9za2kgU29mdHdhcmUgQXNzb2NpYXRlcyBMdGQuMRAwDgYD
VQQLEwdVbmtub3duMRgwFgYDVQQDEw9EZW5uaXMgU29zbm9za2kwHhcNMDkwNDEy
MTAzMjE5WhcNMzYwODI3MTAzMjE5WjCBljELMAkGA1UEBhMCTloxEzARBgNVBAgT
CldlbGxpbmd0b24xGjAYBgNVBAcTEVBhcmFwYXJhdW11IEJlYWNoMSowKAYDVQQK
EyFTb3Nub3NraSBTb2Z0d2FyZSBBc3NvY2lhdGVzIEx0ZC4xEDAOBgNVBAsTB1Vu
a25vd24xGDAWBgNVBAMTD0Rlbm5pcyBTb3Nub3NraTCBnzANBgkqhkiG9w0BAQEF
AAOBjQAwgYkCgYEA1H3mjQCF9uce2jmm/Yq9kE4ytfvkp4c8G90cDfJXJvOiGQds
p2vDZXKuCkHQ7vsBBXPNTt8J/d8ZbEwyuB9Ccz5pJqi6Ig6Y2/mEsPthDyh5SrJV
yQ/wxUGwmfSuwdrIMnplMTq+OR9BOfT3CvjSvuy9d6BQNo4wOMkDvmZTtI8CAwEA
ATANBgkqhkiG9w0BAQUFAAOBgQCqv4475QaqlKcN2QCZJbLVKZEX+76XLQurGkgf
2fCgesRHjfUfOHyTTlhWQdEKTcBB2XviUyyW6I//fmKfXUIiQqvgh4LHdXRPEXDf
Y9nr89MjyQpDlnl6AlrvSej30a9iwVRUeVk4d6gxWHMRonKBFgh+TGexxUXHtPkf
B1Pdtg==
-----END CERTIFICATE-----

View File

@ -0,0 +1,144 @@
<?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\Mime\MultiPart;
use BeSimple\SoapCommon\Mime\Part;
use BeSimple\SoapCommon\Mime\PartHeader;
class MultiPartTest extends \PHPUnit_Framework_TestCase
{
public function testConstructor()
{
$mp = new MultiPart();
$this->assertEquals('1.0', $mp->getHeader('MIME-Version'));
$this->assertEquals('multipart/related', $mp->getHeader('Content-Type'));
$this->assertEquals('text/xml', $mp->getHeader('Content-Type', 'type'));
$this->assertEquals('utf-8', $mp->getHeader('Content-Type', 'charset'));
$this->assertRegExp('~urn:uuid:.*~', $mp->getHeader('Content-Type', 'boundary'));
}
public function testGetMimeMessage()
{
$mp = new MultiPart();
/*
string(51) "
--urn:uuid:a81ca327-591e-4656-91a1-8f177ada95b0--"
*/
$this->assertEquals(51, strlen($mp->getMimeMessage()));
$p = new Part('test');
$mp->addPart($p, true);
/*
string(259) "
--urn:uuid:a81ca327-591e-4656-91a1-8f177ada95b0
Content-Type: application/octet-stream; charset=utf-8
Content-Transfer-Encoding: binary
Content-ID: <urn:uuid:a0ad4376-5b08-4471-9f6f-c29aee881e84>
test
--urn:uuid:a81ca327-591e-4656-91a1-8f177ada95b0--"
*/
$this->assertEquals(259, strlen($mp->getMimeMessage()));
}
public function testGetMimeMessageWithHeaders()
{
$mp = new MultiPart();
/*
string(189) "MIME-Version: 1.0
Content-Type: multipart/related; type="text/xml"; charset=utf-8; boundary="urn:uuid:231833e2-a23b-410a-862e-250524fc38f6"
--urn:uuid:231833e2-a23b-410a-862e-250524fc38f6--"
*/
$this->assertEquals(193, strlen($mp->getMimeMessage(true)));
$p = new Part('test');
$mp->addPart($p, true);
/*
string(452) "MIME-Version: 1.0
Content-Type: multipart/related; type="text/xml"; charset=utf-8; boundary="urn:uuid:231833e2-a23b-410a-862e-250524fc38f6"; start="<urn:uuid:9389c081-56f7-4f57-b66e-c81892c3d4db>"
--urn:uuid:231833e2-a23b-410a-862e-250524fc38f6
Content-Type: application/octet-stream; charset=utf-8
Content-Transfer-Encoding: binary
Content-ID: <urn:uuid:9389c081-56f7-4f57-b66e-c81892c3d4db>
test
--urn:uuid:231833e2-a23b-410a-862e-250524fc38f6--"
*/
$this->assertEquals(458, strlen($mp->getMimeMessage(true)));
}
public function testGetHeadersForHttp()
{
$mp = new MultiPart();
$result = array(
'Content-Type: multipart/related; type="text/xml"; charset=utf-8; boundary="' . $mp->getHeader('Content-Type', 'boundary') . '"',
);
$this->assertEquals($result, $mp->getHeadersForHttp());
$result = array(
'Content-Type: multipart/related; type="text/xml"; charset=utf-8; boundary="' . $mp->getHeader('Content-Type', 'boundary') . '"',
'Content-Description: test',
);
$mp->setHeader('Content-Description', 'test');
$this->assertEquals($result, $mp->getHeadersForHttp());
}
public function testAddGetPart()
{
$mp = new MultiPart();
$p = new Part('test');
$p->setHeader('Content-ID', 'mycontentid');
$mp->addPart($p);
$this->assertEquals($p, $mp->getPart('mycontentid'));
}
public function testAddGetPartWithMain()
{
$mp = new MultiPart();
$p = new Part('test');
$mp->addPart($p, true);
$this->assertEquals($p, $mp->getPart());
}
public function testGetParts()
{
$mp = new MultiPart();
$p1 = new Part('test');
$mp->addPart($p1, true);
$p2 = new Part('test');
$mp->addPart($p2);
$withoutMain = array(
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,
);
$this->assertEquals($withMain, $mp->getParts(true));
}
}

View File

@ -0,0 +1,153 @@
<?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\Mime\MultiPart;
use BeSimple\SoapCommon\Mime\Parser;
use BeSimple\SoapCommon\Mime\Part;
use BeSimple\SoapCommon\Mime\PartHeader;
class ParserTest extends \PHPUnit_Framework_TestCase
{
public function testParserRequestWsi()
{
$filename = dirname(__DIR__).DIRECTORY_SEPARATOR.'Fixtures/WS-I-MTOM-request.txt';
$mimeMessage = file_get_contents($filename);
$mp = Parser::parseMimeMessage($mimeMessage);
$this->assertsForWsiMtomRequest($mp);
}
public function testParserResponseAmazon()
{
$filename = dirname(__DIR__).DIRECTORY_SEPARATOR.'Fixtures/SwA-response-amazon.txt';
$mimeMessage = file_get_contents($filename);
$mp = Parser::parseMimeMessage($mimeMessage);
$this->assertEquals('Fri, 12 Feb 2010 15:46:00 GMT', $mp->getHeader('Date'));
$this->assertEquals('Server', $mp->getHeader('Server'));
$this->assertEquals('1.0', $mp->getHeader('MIME-Version'));
$this->assertEquals('close', $mp->getHeader('Cneonction'));
$this->assertEquals('chunked', $mp->getHeader('Transfer-Encoding'));
$this->assertEquals('multipart/related', $mp->getHeader('Content-Type'));
$this->assertEquals('text/xml', $mp->getHeader('Content-Type', 'type'));
$this->assertEquals('utf-8', $mp->getHeader('Content-Type', 'charset'));
$this->assertEquals('xxx-MIME-Boundary-xxx-0xa36cb38-0a36cb38-xxx-END-xxx', $mp->getHeader('Content-Type', 'boundary'));
$p1 = $mp->getPart();
$this->assertEquals('text/xml', $p1->getHeader('Content-Type'));
$this->assertEquals('UTF-8', $p1->getHeader('Content-Type', 'charset'));
$this->assertEquals(389, strlen($p1->getContent()));
$p2 = $mp->getPart('0x9d6ad00-0xa19ef48-0x9de7500-0xa4fae78-0xa382698');
$this->assertEquals('binary', $p2->getHeader('Content-Transfer-Encoding'));
$this->assertEquals('application/binary', $p2->getHeader('Content-Type'));
$this->assertEquals(79, strlen($p2->getContent()));
}
public function testParserResponseAxis()
{
$filename = dirname(__DIR__).DIRECTORY_SEPARATOR.'Fixtures/SwA-response-axis.txt';
$mimeMessage = file_get_contents($filename);
$mp = Parser::parseMimeMessage($mimeMessage);
$this->assertEquals('Sat, 11 Sep 2010 12:52:57 GMT', $mp->getHeader('Date'));
$this->assertEquals('Simple-Server/1.1', $mp->getHeader('Server'));
$this->assertEquals('1.0', $mp->getHeader('MIME-Version'));
$this->assertEquals('chunked', $mp->getHeader('Transfer-Encoding'));
$this->assertEquals('multipart/related', $mp->getHeader('Content-Type'));
$this->assertEquals('application/soap+xml', $mp->getHeader('Content-Type', 'type'));
$this->assertEquals('utf-8', $mp->getHeader('Content-Type', 'charset'));
$this->assertEquals('<0.urn:uuid:2DB7ABF3DC5BED7FA51284209577583@apache.org>', $mp->getHeader('Content-Type', 'start'));
$this->assertEquals('urn:getVersionResponse', $mp->getHeader('Content-Type', 'action'));
$this->assertEquals('MIMEBoundaryurn_uuid_2DB7ABF3DC5BED7FA51284209577582', $mp->getHeader('Content-Type', 'boundary'));
$p1 = $mp->getPart('0.urn:uuid:2DB7ABF3DC5BED7FA51284209577583@apache.org');
$this->assertEquals('8bit', $p1->getHeader('Content-Transfer-Encoding'));
$this->assertEquals('application/soap+xml', $p1->getHeader('Content-Type'));
$this->assertEquals('utf-8', $p1->getHeader('Content-Type', 'charset'));
$this->assertEquals(499, strlen($p1->getContent()));
}
public function testParserResponseWsi()
{
$filename = dirname(__DIR__).DIRECTORY_SEPARATOR.'Fixtures/WS-I-MTOM-response.txt';
$mimeMessage = file_get_contents($filename);
$mp = Parser::parseMimeMessage($mimeMessage);
$this->assertEquals('Keep-Alive', $mp->getHeader('Proxy-Connection'));
$this->assertEquals('Keep-Alive', $mp->getHeader('Connection'));
$this->assertEquals('1166', $mp->getHeader('Content-Length'));
$this->assertEquals('1.1 RED-PRXY-03', $mp->getHeader('Via'));
$this->assertEquals('Fri, 09 Sep 2005 06:57:22 GMT', $mp->getHeader('Date'));
$this->assertEquals('multipart/related', $mp->getHeader('Content-Type'));
$this->assertEquals('application/xop+xml', $mp->getHeader('Content-Type', 'type'));
$this->assertEquals('utf-8', $mp->getHeader('Content-Type', 'charset'));
$this->assertEquals('<http://tempuri.org/0>', $mp->getHeader('Content-Type', 'start'));
$this->assertEquals('application/soap+xml', $mp->getHeader('Content-Type', 'start-info'));
$this->assertEquals('uuid:b71dc628-ec8f-4422-8a4a-992f041cb94c+id=46', $mp->getHeader('Content-Type', 'boundary'));
$p1 = $mp->getPart('http://tempuri.org/0');
$this->assertEquals('8bit', $p1->getHeader('Content-Transfer-Encoding'));
$this->assertEquals('application/xop+xml', $p1->getHeader('Content-Type'));
$this->assertEquals('utf-8', $p1->getHeader('Content-Type', 'charset'));
$this->assertEquals('application/soap+xml', $p1->getHeader('Content-Type', 'type'));
$this->assertEquals(910, strlen($p1->getContent()));
}
public function testParserWithHeaderArray()
{
$filename = dirname(__DIR__).DIRECTORY_SEPARATOR.'Fixtures/WS-I-MTOM-request_noheader.txt';
$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-Length' => 1941,
'Host' => '131.107.72.15',
'Expect' => '100-continue',
);
$mp = Parser::parseMimeMessage($mimeMessage, $headers);
$this->assertsForWsiMtomRequest($mp);
}
/*
* used in:
* - testParserWithHeaderArray
* - testParserRequestWsi
*/
private function assertsForWsiMtomRequest(MultiPart $mp)
{
$this->assertEquals('multipart/related', $mp->getHeader('Content-Type'));
$this->assertEquals('application/xop+xml', $mp->getHeader('Content-Type', 'type'));
$this->assertEquals('utf-8', $mp->getHeader('Content-Type', 'charset'));
$this->assertEquals('<http://tempuri.org/0>', $mp->getHeader('Content-Type', 'start'));
$this->assertEquals('application/soap+xml', $mp->getHeader('Content-Type', 'start-info'));
$this->assertEquals('uuid:0ca0e16e-feb1-426c-97d8-c4508ada5e82+id=7', $mp->getHeader('Content-Type', 'boundary'));
$this->assertEquals('1941', $mp->getHeader('Content-Length'));
$this->assertEquals('131.107.72.15', $mp->getHeader('Host'));
$this->assertEquals('100-continue', $mp->getHeader('Expect'));
$p1 = $mp->getPart('http://tempuri.org/0');
$this->assertEquals('8bit', $p1->getHeader('Content-Transfer-Encoding'));
$this->assertEquals('application/xop+xml', $p1->getHeader('Content-Type'));
$this->assertEquals('utf-8', $p1->getHeader('Content-Type', 'charset'));
$this->assertEquals('application/soap+xml', $p1->getHeader('Content-Type', 'type'));
$this->assertEquals(737, strlen($p1->getContent()));
$p2 = $mp->getPart('http://tempuri.org/1/632618206527087310');
$this->assertEquals('binary', $p2->getHeader('Content-Transfer-Encoding'));
$this->assertEquals('application/octet-stream', $p2->getHeader('Content-Type'));
$this->assertEquals(769, strlen($p2->getContent()));
}
}

View File

@ -0,0 +1,57 @@
<?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\Mime\PartHeader;
use BeSimple\SoapCommon\Tests\Fixtures\MimePartHeader;
class PartHeaderTest extends \PHPUnit_Framework_TestCase
{
public function testSetGetHeader()
{
$ph = new MimePartHeader();
$ph->setHeader('Content-Type', 'text/xml');
$this->assertEquals('text/xml', $ph->getHeader('Content-Type'));
}
public function testSetGetHeaderSubvalue()
{
$ph = new MimePartHeader();
$ph->setHeader('Content-Type', 'utf-8', 'charset');
$this->assertEquals(null, $ph->getHeader('Content-Type', 'charset'));
$ph->setHeader('Content-Type', 'text/xml');
$ph->setHeader('Content-Type', 'charset', 'utf-8');
$this->assertEquals('utf-8', $ph->getHeader('Content-Type', 'charset'));
}
public function testGenerateHeaders()
{
$ph = new MimePartHeader();
$class = new \ReflectionClass($ph);
$method = $class->getMethod('generateHeaders');
$method->setAccessible(true);
$this->assertEquals('', $method->invoke($ph));
$ph->setHeader('Content-Type', 'text/xml');
$this->assertEquals("Content-Type: text/xml\r\n", $method->invoke($ph));
$ph->setHeader('Content-Type', 'charset', 'utf-8');
$this->assertEquals("Content-Type: text/xml; charset=utf-8\r\n", $method->invoke($ph));
$ph->setHeader('Content-Type', 'type', 'text/xml');
$this->assertEquals("Content-Type: text/xml; charset=utf-8; type=\"text/xml\"\r\n", $method->invoke($ph));
}
}

View File

@ -0,0 +1,62 @@
<?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\Mime\Part;
use BeSimple\SoapCommon\Mime\PartHeader;
class PartTest extends \PHPUnit_Framework_TestCase
{
public function testConstructor()
{
$p = new Part('<xml1/>', 'text/xml', 'utf-8', Part::ENCODING_BINARY, 'urn:myuniqueresource');
$this->assertEquals('<xml1/>', $p->getContent());
$this->assertEquals('text/xml', $p->getHeader('Content-Type'));
$this->assertEquals('utf-8', $p->getHeader('Content-Type', 'charset'));
$this->assertEquals(Part::ENCODING_BINARY, $p->getHeader('Content-Transfer-Encoding'));
$this->assertEquals('<urn:myuniqueresource>', $p->getHeader('Content-ID'));
}
public function testDefaultConstructor()
{
$p = new Part();
$this->assertNull($p->getContent());
$this->assertEquals('application/octet-stream', $p->getHeader('Content-Type'));
$this->assertEquals('utf-8', $p->getHeader('Content-Type', 'charset'));
$this->assertEquals(Part::ENCODING_BINARY, $p->getHeader('Content-Transfer-Encoding'));
$this->assertRegExp('~<urn:uuid:.*>~', $p->getHeader('Content-ID'));
}
public function testSetContent()
{
$p = new Part();
$p->setContent('<xml1/>');
$this->assertEquals('<xml1/>', $p->getContent());
}
public function testGetMessagePart()
{
$p = new Part('<xml1/>', 'text/xml', 'utf-8', Part::ENCODING_BINARY, 'urn:myuniqueresource');
$messagePart = "Content-Type: text/xml; charset=utf-8\r\n" .
"Content-Transfer-Encoding: binary\r\n" .
"Content-ID: <urn:myuniqueresource>\r\n" .
"\r\n".
"<xml1/>";
$this->assertEquals($messagePart, $p->getMessagePart());
}
}

View File

@ -0,0 +1,119 @@
<?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\WsSecurityKey;
use ass\XmlSecurity\Key as XmlSecurityKey;
class WsSecurityKeyTest extends \PHPUnit_Framework_TestCase
{
public function testHasKeys()
{
$wsk = new WsSecurityKey();
$filename = __DIR__.DIRECTORY_SEPARATOR.'Fixtures/clientkey.pem';
$wsk->addPrivateKey(\ass\XmlSecurity\Key::RSA_SHA1, $filename);
$filename = __DIR__.DIRECTORY_SEPARATOR.'Fixtures/clientcert.pem';
$wsk->addPublicKey(\ass\XmlSecurity\Key::RSA_SHA1, $filename);
$this->assertTrue($wsk->hasKeys());
$this->assertTrue($wsk->hasPrivateKey());
$this->assertTrue($wsk->hasPublicKey());
}
public function testHasKeysNone()
{
$wsk = new WsSecurityKey();
$this->assertFalse($wsk->hasKeys());
$this->assertFalse($wsk->hasPrivateKey());
$this->assertFalse($wsk->hasPublicKey());
}
public function testHasPrivateKey()
{
$wsk = new WsSecurityKey();
$filename = __DIR__.DIRECTORY_SEPARATOR.'Fixtures/clientkey.pem';
$wsk->addPrivateKey(\ass\XmlSecurity\Key::RSA_SHA1, $filename);
$this->assertFalse($wsk->hasKeys());
$this->assertTrue($wsk->hasPrivateKey());
}
public function testHasPublicKey()
{
$wsk = new WsSecurityKey();
$filename = __DIR__.DIRECTORY_SEPARATOR.'Fixtures/clientcert.pem';
$wsk->addPublicKey(\ass\XmlSecurity\Key::RSA_SHA1, $filename);
$this->assertFalse($wsk->hasKeys());
$this->assertTrue($wsk->hasPublicKey());
}
public function testAddPrivateKey()
{
$wsk = new WsSecurityKey();
$filename = __DIR__.DIRECTORY_SEPARATOR.'Fixtures/clientkey.pem';
$wsk->addPrivateKey(\ass\XmlSecurity\Key::RSA_SHA1, $filename);
$this->assertTrue($wsk->hasPrivateKey());
$this->assertInstanceOf('ass\XmlSecurity\Key', $wsk->getPrivateKey());
}
public function testAddPrivateKeySessionKey()
{
$wsk = new WsSecurityKey();
$filename = __DIR__.DIRECTORY_SEPARATOR.'Fixtures/clientkey.pem';
$wsk->addPrivateKey(\ass\XmlSecurity\Key::TRIPLEDES_CBC);
$this->assertTrue($wsk->hasPrivateKey());
$this->assertInstanceOf('ass\XmlSecurity\Key', $wsk->getPrivateKey());
}
public function testAddPrivateKeyNoFile()
{
$wsk = new WsSecurityKey();
$filename = __DIR__.DIRECTORY_SEPARATOR.'Fixtures/clientkey.pem';
$wsk->addPrivateKey(\ass\XmlSecurity\Key::RSA_SHA1, file_get_contents($filename), false);
$this->assertTrue($wsk->hasPrivateKey());
$this->assertInstanceOf('ass\XmlSecurity\Key', $wsk->getPrivateKey());
}
public function testAddPublicKey()
{
$wsk = new WsSecurityKey();
$filename = __DIR__.DIRECTORY_SEPARATOR.'Fixtures/clientcert.pem';
$wsk->addPublicKey(\ass\XmlSecurity\Key::RSA_SHA1, $filename);
$this->assertTrue($wsk->hasPublicKey());
$this->assertInstanceOf('ass\XmlSecurity\Key', $wsk->getPublicKey());
}
public function testAddPublicKeyNoFile()
{
$wsk = new WsSecurityKey();
$filename = __DIR__.DIRECTORY_SEPARATOR.'Fixtures/clientcert.pem';
$wsk->addPublicKey(\ass\XmlSecurity\Key::RSA_SHA1, file_get_contents($filename), false);
$this->assertTrue($wsk->hasPublicKey());
$this->assertInstanceOf('ass\XmlSecurity\Key', $wsk->getPublicKey());
}
}

View File

@ -0,0 +1,48 @@
<?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\WsdlHandler;
class WsdlHandlerTest extends \PHPUnit_Framework_TestCase
{
public function testIsValidMimeTypeType()
{
$filename = __DIR__.DIRECTORY_SEPARATOR.'Fixtures/WsdlMimeContent.wsdl';
$wh = new WsdlHandler($filename, SOAP_1_1);
$this->assertTrue($wh->isValidMimeTypeType('http://example.com/soapaction', WsdlHandler::BINDING_OPERATION_INPUT, 'body', 'text/xml'));
$this->assertFalse($wh->isValidMimeTypeType('http://example.com/soapaction', WsdlHandler::BINDING_OPERATION_INPUT, 'body', 'image/gif'));
$this->assertTrue($wh->isValidMimeTypeType('http://example.com/soapaction', WsdlHandler::BINDING_OPERATION_INPUT, 'ClaimPhoto', 'image/jpeg'));
$this->assertFalse($wh->isValidMimeTypeType('http://example.com/soapaction', WsdlHandler::BINDING_OPERATION_INPUT, 'ClaimPhoto', 'image/gif'));
$this->assertFalse($wh->isValidMimeTypeType('http://example.com/soapaction', WsdlHandler::BINDING_OPERATION_INPUT, 'ClaimPhoto', 'text/xml'));
$filename = __DIR__.DIRECTORY_SEPARATOR.'Fixtures/WsdlMimeContent2.wsdl';
$wh = new WsdlHandler($filename, SOAP_1_1);
$this->assertTrue($wh->isValidMimeTypeType('http://example.com/soapaction', WsdlHandler::BINDING_OPERATION_INPUT, 'body', 'text/xml'));
$this->assertFalse($wh->isValidMimeTypeType('http://example.com/soapaction', WsdlHandler::BINDING_OPERATION_INPUT, 'body', 'image/gif'));
$this->assertTrue($wh->isValidMimeTypeType('http://example.com/soapaction', WsdlHandler::BINDING_OPERATION_INPUT, 'ClaimPhoto', 'image/jpeg'));
$this->assertTrue($wh->isValidMimeTypeType('http://example.com/soapaction', WsdlHandler::BINDING_OPERATION_INPUT, 'ClaimPhoto', 'image/gif'));
$this->assertFalse($wh->isValidMimeTypeType('http://example.com/soapaction', WsdlHandler::BINDING_OPERATION_INPUT, 'ClaimPhoto', 'text/xml'));
$filename = __DIR__.DIRECTORY_SEPARATOR.'Fixtures/WsdlMimeContent3.wsdl';
$wh = new WsdlHandler($filename, SOAP_1_1);
$this->assertTrue($wh->isValidMimeTypeType('http://example.com/soapaction', WsdlHandler::BINDING_OPERATION_INPUT, 'body', 'text/xml'));
$this->assertFalse($wh->isValidMimeTypeType('http://example.com/soapaction', WsdlHandler::BINDING_OPERATION_INPUT, 'body', 'image/gif'));
$this->assertTrue($wh->isValidMimeTypeType('http://example.com/soapaction', WsdlHandler::BINDING_OPERATION_INPUT, 'ClaimPhoto', 'image/jpeg'));
$this->assertTrue($wh->isValidMimeTypeType('http://example.com/soapaction', WsdlHandler::BINDING_OPERATION_INPUT, 'ClaimPhoto', 'image/gif'));
$this->assertTrue($wh->isValidMimeTypeType('http://example.com/soapaction', WsdlHandler::BINDING_OPERATION_INPUT, 'ClaimPhoto', 'text/xml'));
}
}