Fixed typo and added unit tests
This commit is contained in:
@ -12,8 +12,12 @@
|
||||
|
||||
namespace BeSimple\Tests\SoapCommon\Soap;
|
||||
|
||||
use BeSimple\Tests\SoapCommon\Fixtures\SoapBuilder;
|
||||
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\Tests\SoapCommon\Fixtures\SoapBuilder;
|
||||
|
||||
class AbstractSoapBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
@ -67,6 +71,9 @@ class AbstractSoapBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$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());
|
||||
|
||||
@ -80,6 +87,14 @@ class AbstractSoapBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
$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
|
||||
@ -131,6 +146,50 @@ class AbstractSoapBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
$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();
|
||||
|
@ -25,6 +25,12 @@ class SoapRequestTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(Cache::DISABLED, Cache::isEnabled());
|
||||
}
|
||||
|
||||
public function testSetEnabledBadValue()
|
||||
{
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
Cache::setEnabled('foo');
|
||||
}
|
||||
|
||||
public function testSetType()
|
||||
{
|
||||
Cache::setType(Cache::TYPE_DISK);
|
||||
@ -34,6 +40,12 @@ class SoapRequestTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(Cache::TYPE_NONE, Cache::getType());
|
||||
}
|
||||
|
||||
public function testSetTypeBadValue()
|
||||
{
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
Cache::setType('foo');
|
||||
}
|
||||
|
||||
public function testSetDirectory()
|
||||
{
|
||||
\vfsStream::setup('Fixtures');
|
||||
|
@ -42,11 +42,11 @@ class ClassmapTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$classmap = new Classmap();
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
$classmap->get('foobar');
|
||||
|
||||
$classmap->add('foobar', 'BeSimple\SoapCommon\Classmap');
|
||||
$this->assertSame(array('foobar' => 'BeSimple\SoapCommon\Classmap'), $classmap->get('foobar'));
|
||||
$this->assertSame('BeSimple\SoapCommon\Classmap', $classmap->get('foobar'));
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
$classmap->get('bar');
|
||||
}
|
||||
|
||||
public function testSet()
|
||||
|
Reference in New Issue
Block a user