Completed
Pull Request — master (#8)
by Josef
08:42
created

GuzzleSoapClientDriverTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
lcom 1
cbo 6
dl 0
loc 45
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B testSend() 0 40 1
1
<?php declare(strict_types = 1);
2
3
namespace SlevomatEET\Driver;
4
5
class GuzzleSoapClientDriverTest extends \PHPUnit\Framework\TestCase
6
{
7
8
	public function testSend()
9
	{
10
		$requestData = 'fooData';
11
		$responseData = 'responseData';
12
		$location = 'https://pg.eet.cz';
13
		$soapAction = 'fooAction';
14
15
		$guzzleHttpClient = $this->createMock(\GuzzleHttp\Client::class);
16
		$guzzleHttpClient
17
			->expects(self::once())
18
			->method('send')
19
			->with(self::callback(function (\GuzzleHttp\Psr7\Request $request) use ($requestData, $location, $soapAction) {
20
				$this->assertEquals([
21
					'Host' => [
22
						'pg.eet.cz',
23
					],
24
					'User-Agent' => [
25
						GuzzleSoapClientDriver::HEADER_USER_AGENT,
26
					],
27
					'Content-Type' => [
28
						'text/xml; charset=utf-8',
29
					],
30
					'SOAPAction' => [
31
						$soapAction,
32
					],
33
					'Content-Length' => [
34
						strlen($requestData),
35
					],
36
				], $request->getHeaders());
37
				$this->assertEquals($location, (string) $request->getUri());
38
39
				return true;
40
			}))
41
			->willReturn(new \GuzzleHttp\Psr7\Response(200, [], $responseData));
42
43
		$guzzleSoapClientDriver = new GuzzleSoapClientDriver($guzzleHttpClient);
44
		$response = $guzzleSoapClientDriver->send($requestData, $location, $soapAction, SOAP_1_1);
45
46
		$this->assertSame($responseData, $response);
47
	}
48
49
}
50