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 CustomerInfoRequestTest 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('customer/echo/{merchantId}/{customerId}/{dttm}/{signature}', [ |
24
|
|
|
'merchantId' => '012345', |
25
|
|
|
'customerId' => '[email protected]', |
26
|
|
|
]) |
27
|
|
|
->willReturn( |
28
|
|
|
new Response(ResponseCode::get(ResponseCode::S200_OK), [ |
29
|
|
|
'customerId' => '[email protected]', |
30
|
|
|
'dttm' => '20140425131559', |
31
|
|
|
'resultCode' => 0, |
32
|
|
|
'resultMessage' => 'OK', |
33
|
|
|
]) |
34
|
|
|
); |
35
|
|
|
|
36
|
|
|
$customerInfoRequest = new CustomerInfoRequest( |
37
|
|
|
'012345', |
38
|
|
|
'[email protected]' |
39
|
|
|
); |
40
|
|
|
|
41
|
|
|
$customerInfoResponse = $customerInfoRequest->send($apiClient); |
42
|
|
|
|
43
|
|
|
self::assertSame('[email protected]', $customerInfoResponse->getCustomerId()); |
44
|
|
|
self::assertEquals(DateTimeImmutable::createFromFormat('YmdHis', '20140425131559'), $customerInfoResponse->getResponseDateTime()); |
45
|
|
|
self::assertEquals(ResultCode::get(ResultCode::C0_OK), $customerInfoResponse->getResultCode()); |
46
|
|
|
self::assertSame('OK', $customerInfoResponse->getResultMessage()); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
} |
50
|
|
|
|