Added phing for running tests & fixed issues in order to pass the tests
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
@ -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()
|
||||
{
|
||||
|
@ -51,4 +51,3 @@ class DateTimeTypeConverterTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertNull($date);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,4 +49,3 @@ class DateTypeConverterTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertNull($date);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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',
|
||||
|
Reference in New Issue
Block a user