1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* For the full copyright and license information, please view the LICENSE file |
5
|
|
|
* that was distributed with this source code. |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
declare (strict_types = 1); |
9
|
|
|
|
10
|
|
|
namespace Component\Remote\BurzeDzisNet; |
11
|
|
|
|
12
|
|
|
use PHPUnit_Framework_TestCase; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* {@see Endpoint} test. |
16
|
|
|
* |
17
|
|
|
* @author Krzysztof Piasecki <[email protected]> |
18
|
|
|
*/ |
19
|
|
|
class EndpointTest extends PHPUnit_Framework_TestCase |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @covers Component\Remote\BurzeDzisNet\apiKey::apikey |
23
|
|
|
*/ |
24
|
|
|
public function testapiKey() |
25
|
|
|
{ |
26
|
|
|
$endpoint = new Endpoint('MyApiKey'); |
27
|
|
|
$this->assertSame('MyApiKey', $endpoint->apiKey()); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @covers Component\Remote\BurzeDzisNet\Endpoint::wsdl |
32
|
|
|
*/ |
33
|
|
|
public function testWsdl() |
34
|
|
|
{ |
35
|
|
|
$endpoint = new Endpoint('MyApiKey'); |
36
|
|
|
$this->assertSame('https://burze.dzis.net/soap.php?WSDL', $endpoint->wsdl()); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @covers Component\Remote\BurzeDzisNet\Endpoint::options |
41
|
|
|
*/ |
42
|
|
|
public function testOptions() |
43
|
|
|
{ |
44
|
|
|
$endpoint = new Endpoint('MyApiKey'); |
45
|
|
|
$this->assertEquals([], $endpoint->options()); |
46
|
|
|
$endpoint2 = new Endpoint('MyApiKey', ['option' => true]); |
47
|
|
|
$this->assertEquals(['option' => true], $endpoint2->options()); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @covers Component\Remote\BurzeDzisNet\Endpoint::client |
52
|
|
|
*/ |
53
|
|
|
public function testClient() |
54
|
|
|
{ |
55
|
|
|
$endpoint = new Endpoint('MyApiKey'); |
56
|
|
|
$client = $endpoint->client(); |
57
|
|
|
$client2 = $endpoint->client(); |
58
|
|
|
$this->assertInstanceOf('SoapClient', $client); |
59
|
|
|
$this->assertNotSame($client, $client2); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @covers Component\Remote\BurzeDzisNet\Endpoint::client |
64
|
|
|
* |
65
|
|
|
* @expectedException \SoapFault |
66
|
|
|
*/ |
67
|
|
View Code Duplication |
public function testClientInvalidWSDL() |
|
|
|
|
68
|
|
|
{ |
69
|
|
|
$endpoint = $this->getMockBuilder("Component\Remote\BurzeDzisNet\Endpoint") |
70
|
|
|
->disableOriginalConstructor() |
71
|
|
|
->setMethods(['wsdl', 'options']) |
72
|
|
|
->getMock(); |
73
|
|
|
$endpoint->method('wsdl')->willReturn(\sprintf('%s%sInvalidExampleWSDL.xml', __DIR__, \DIRECTORY_SEPARATOR)); |
74
|
|
|
$endpoint->method('options')->willReturn([]); |
75
|
|
|
$endpoint->client(); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @covers Component\Remote\BurzeDzisNet\Endpoint::__construct |
80
|
|
|
*/ |
81
|
|
|
public function test__construct() |
82
|
|
|
{ |
83
|
|
|
$endpoint = new Endpoint('MyApiKey'); |
84
|
|
|
$this->assertSame('https://burze.dzis.net/soap.php?WSDL', $endpoint->wsdl()); |
85
|
|
|
$this->assertSame('MyApiKey', $endpoint->apiKey()); |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.