EchoRequestTest::testSend()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 28
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

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