BeSimpleSoap/tests/BeSimple/Tests/SoapClient/SoapClientBuilderTest.php

83 lines
2.4 KiB
PHP
Raw Normal View History

2011-10-09 20:17:50 +02:00
<?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\Tests\SoapCommon\Soap;
use BeSimple\SoapClient\SoapClientBuilder;
class SoapClientBuilderTest extends \PHPUnit_Framework_TestCase
{
private $defaultOptions = array(
'features' => 0,
2011-10-10 00:02:20 +02:00
'classmap' => array(),
'typemap' => array(),
2011-10-09 20:17:50 +02:00
);
public function testContruct()
{
$options = $this
->getSoapBuilder()
2011-10-10 00:02:20 +02:00
->getSoapOptions()
2011-10-09 20:17:50 +02:00
;
$this->assertEquals($this->mergeOptions(array()), $options);
}
public function testWithTrace()
{
$builder = $this->getSoapBuilder();
$builder->withTrace();
2011-10-10 00:02:20 +02:00
$this->assertEquals($this->mergeOptions(array('trace' => true)), $builder->getSoapOptions());
2011-10-09 20:17:50 +02:00
$builder->withTrace(false);
2011-10-10 00:02:20 +02:00
$this->assertEquals($this->mergeOptions(array('trace' => false)), $builder->getSoapOptions());
2011-10-09 20:17:50 +02:00
}
public function testWithExceptions()
{
$builder = $this->getSoapBuilder();
$builder->withExceptions();
2011-10-10 00:02:20 +02:00
$this->assertEquals($this->mergeOptions(array('exceptions' => true)), $builder->getSoapOptions());
2011-10-09 20:17:50 +02:00
$builder->withExceptions(false);
2011-10-10 00:02:20 +02:00
$this->assertEquals($this->mergeOptions(array('exceptions' => false)), $builder->getSoapOptions());
2011-10-09 20:17:50 +02:00
}
public function testWithUserAgent()
{
$builder = $this->getSoapBuilder();
$builder->withUserAgent('BeSimpleSoap Test');
2011-10-10 00:02:20 +02:00
$this->assertEquals($this->mergeOptions(array('user_agent' => 'BeSimpleSoap Test')), $builder->getSoapOptions());
2011-10-09 20:17:50 +02:00
}
public function testCreateWithDefaults()
{
$builder = SoapClientBuilder::createWithDefaults();
$this->assertInstanceOf('BeSimple\SoapClient\SoapClientBuilder', $builder);
2011-10-10 00:02:20 +02:00
$this->assertEquals($this->mergeOptions(array('soap_version' => SOAP_1_2, 'encoding' => 'UTF-8', 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, 'user_agent' => 'BeSimpleSoap')), $builder->getSoapOptions());
2011-10-09 20:17:50 +02:00
}
private function getSoapBuilder()
{
return new SoapClientBuilder();
}
private function mergeOptions(array $options)
{
return array_merge($this->defaultOptions, $options);
}
}