Completed
Push — master ( 170fde...562033 )
by Jan
03:08
created

CustomerInfoRequestTest::testSend()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 34
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 34
rs 8.8571
cc 1
eloc 23
nc 1
nop 0
1
<?php
2
3
namespace SlevomatCsobGateway\Call;
4
5
use DateTimeImmutable;
6
use SlevomatCsobGateway\Api\ApiClient;
7
use SlevomatCsobGateway\Api\Response;
8
use SlevomatCsobGateway\Api\ResponseCode;
9
10
class CustomerInfoRequestTest extends \PHPUnit_Framework_TestCase
11
{
12
13
	public function testSend()
14
	{
15
		$apiClient = $this->getMockBuilder(ApiClient::class)
16
			->disableOriginalConstructor()
17
			->getMock();
18
19
		$apiClient->expects(self::once())->method('get')
20
			->with('customer/info/{merchantId}/{customerId}/{dttm}/{signature}', [
21
				'merchantId' => '012345',
22
				'customerId' => '[email protected]',
23
			])
24
			->willReturn(
25
				new Response(new ResponseCode(ResponseCode::S200_OK), [
26
					'customerId' => '[email protected]',
27
					'dttm' => '20140425131559',
28
					'resultCode' => 0,
29
					'resultMessage' => 'OK',
30
				])
31
			);
32
33
		/** @var ApiClient $apiClient */
34
		$customerInfoRequest = new CustomerInfoRequest(
35
			'012345',
36
			'[email protected]'
37
		);
38
39
		$customerInfoResponse = $customerInfoRequest->send($apiClient);
40
41
		$this->assertInstanceOf(CustomerInfoResponse::class, $customerInfoResponse);
42
		$this->assertSame('[email protected]', $customerInfoResponse->getCustomerId());
43
		$this->assertEquals(DateTimeImmutable::createFromFormat('YmdHis', '20140425131559'), $customerInfoResponse->getResponseDateTime());
44
		$this->assertEquals(new ResultCode(ResultCode::C0_OK), $customerInfoResponse->getResultCode());
45
		$this->assertSame('OK', $customerInfoResponse->getResultMessage());
46
	}
47
48
}
49