EchoRequestTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 18
c 1
b 0
f 0
dl 0
loc 31
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testSend() 0 28 1
1
<?php declare(strict_types = 1);
2
3
namespace SlevomatCsobGateway\Call;
4
5
use DateTimeImmutable;
6
use PHPUnit\Framework\MockObject\MockObject;
7
use PHPUnit\Framework\TestCase;
8
use SlevomatCsobGateway\Api\ApiClient;
9
use SlevomatCsobGateway\Api\Response;
10
use SlevomatCsobGateway\Api\ResponseCode;
11
12
class EchoRequestTest extends TestCase
13
{
14
15
	public function testSend(): void
16
	{
17
		/** @var ApiClient|MockObject $apiClient */
18
		$apiClient = $this->getMockBuilder(ApiClient::class)
19
			->disableOriginalConstructor()
20
			->getMock();
21
22
		$apiClient->expects(self::once())->method('get')
23
			->with('echo/{merchantId}/{dttm}/{signature}', [
24
				'merchantId' => '012345',
25
			])
26
			->willReturn(
27
				new Response(ResponseCode::get(ResponseCode::S200_OK), [
28
					'dttm' => '20140425131559',
29
					'resultCode' => 0,
30
					'resultMessage' => 'OK',
31
				])
32
			);
33
34
		$echoRequest = new EchoRequest(
35
			'012345'
36
		);
37
38
		$echoResponse = $echoRequest->send($apiClient);
39
40
		self::assertEquals(DateTimeImmutable::createFromFormat('YmdHis', '20140425131559'), $echoResponse->getResponseDateTime());
41
		self::assertEquals(ResultCode::get(ResultCode::C0_OK), $echoResponse->getResultCode());
42
		self::assertSame('OK', $echoResponse->getResultMessage());
43
	}
44
45
}
46