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

CustomerInfoRequestTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B testSend() 0 34 1
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