-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathSoapClientBuilderTest.php
More file actions
119 lines (90 loc) · 4.23 KB
/
SoapClientBuilderTest.php
File metadata and controls
119 lines (90 loc) · 4.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
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\SoapClient\Tests;
use BeSimple\SoapClient\SoapClientBuilder;
class SoapClientBuilderTest 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 testWithTrace()
{
$builder = $this->getSoapBuilder();
$builder->withTrace();
$this->assertEquals($this->mergeOptions(array('trace' => true)), $builder->getSoapOptions());
$builder->withTrace(false);
$this->assertEquals($this->mergeOptions(array('trace' => false)), $builder->getSoapOptions());
}
public function testWithExceptions()
{
$builder = $this->getSoapBuilder();
$builder->withExceptions();
$this->assertEquals($this->mergeOptions(array('exceptions' => true)), $builder->getSoapOptions());
$builder->withExceptions(false);
$this->assertEquals($this->mergeOptions(array('exceptions' => false)), $builder->getSoapOptions());
}
public function testWithUserAgent()
{
$builder = $this->getSoapBuilder();
$builder->withUserAgent('BeSimpleSoap Test');
$this->assertEquals($this->mergeOptions(array('user_agent' => 'BeSimpleSoap Test')), $builder->getSoapOptions());
}
public function testWithCompression()
{
$builder = $this->getSoapBuilder();
$builder->withCompressionGzip();
$this->assertEquals($this->mergeOptions(array('compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP)), $builder->getSoapOptions());
$builder->withCompressionDeflate();
$this->assertEquals($this->mergeOptions(array('compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_DEFLATE)), $builder->getSoapOptions());
}
public function testWithAuthentication()
{
$builder = $this->getSoapBuilder();
$builder->withDigestAuthentication(__DIR__.'/Fixtures/cert.pem', 'foobar');
$this->assertEquals($this->mergeOptions(array('authentication' => SOAP_AUTHENTICATION_DIGEST, 'local_cert' => __DIR__.'/Fixtures/cert.pem', 'passphrase' => 'foobar')), $builder->getSoapOptions());
$builder->withDigestAuthentication(__DIR__.'/Fixtures/cert.pem');
$this->assertEquals($this->mergeOptions(array('authentication' => SOAP_AUTHENTICATION_DIGEST, 'local_cert' => __DIR__.'/Fixtures/cert.pem')), $builder->getSoapOptions());
$builder->withBasicAuthentication('foo', 'bar');
$this->assertEquals($this->mergeOptions(array('authentication' => SOAP_AUTHENTICATION_BASIC, 'login' => 'foo', 'password' => 'bar')), $builder->getSoapOptions());
}
public function testWithProxy()
{
$builder = $this->getSoapBuilder();
$builder->withProxy('localhost', 8080);
$this->assertEquals($this->mergeOptions(array('proxy_host' => 'localhost', 'proxy_port' => 8080)), $builder->getSoapOptions());
$builder->withProxy('127.0.0.1', 8585, 'foo', 'bar');
$this->assertEquals($this->mergeOptions(array('proxy_host' => '127.0.0.1', 'proxy_port' => 8585, 'proxy_login' => 'foo', 'proxy_password' => 'bar')), $builder->getSoapOptions());
}
public function testCreateWithDefaults()
{
$builder = SoapClientBuilder::createWithDefaults();
$this->assertInstanceOf('BeSimple\SoapClient\SoapClientBuilder', $builder);
$this->assertEquals($this->mergeOptions(array('soap_version' => SOAP_1_2, 'encoding' => 'UTF-8', 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, 'user_agent' => 'BeSimpleSoap')), $builder->getSoapOptions());
}
private function getSoapBuilder()
{
return new SoapClientBuilder();
}
private function mergeOptions(array $options)
{
return array_merge($this->defaultOptions, $options);
}
}