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

GuzzleSoapClientDriverTest::testSend()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 40
Code Lines 28

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 40
rs 8.8571
c 1
b 0
f 0
cc 1
eloc 28
nc 1
nop 0
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