-
Notifications
You must be signed in to change notification settings - Fork 3
/
MethodsRequestTest.php
86 lines (71 loc) · 2.99 KB
/
MethodsRequestTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
declare(strict_types=1);
namespace Message;
use Omnipay\Przelewy24\Message\MethodsRequest;
use Omnipay\Przelewy24\Message\MethodsResponse;
use Omnipay\Tests\TestCase;
use Symfony\Component\HttpFoundation\Response;
class MethodsRequestTest extends TestCase
{
/**
* @var MethodsRequest
*/
private $request;
public function setUp(): void
{
$this->request = new MethodsRequest($this->getHttpClient(), $this->getHttpRequest());
$this->request->initialize([
'lang' => 'en',
]);
}
public function testGetData(): void
{
$data = $this->request->getData();
$this->assertSame('en', $data['lang']);
}
public function testSendSuccess(): void
{
$this->setMockHttpResponse('MethodsSuccess.txt');
/** @var MethodsResponse $response */
$response = $this->request->send();
$this->assertInstanceOf(MethodsResponse::class, $response);
$this->assertTrue($response->isSuccessful());
$this->assertSame(Response::HTTP_OK, $response->getCode());
$this->assertSame('', $response->getMessage());
$this->assertCount(43, $response->getMethods());
$method = $response->getMethods()[0];
$this->assertSame('Przelew z BPH', $method['name']);
$this->assertSame(35, $method['id']);
$this->assertSame('FastTransfers', $method['group']);
$this->assertSame('FastTransfers', $method['subgroup']);
$this->assertSame(true, $method['status']);
$this->assertSame('https://static.przelewy24.pl/payment-form-logo/svg/35', $method['imgUrl']);
$this->assertSame(
'https://static.przelewy24.pl/payment-form-logo/svg/mobile/35',
$method['mobileImgUrl']
);
$this->assertSame(true, $method['mobile']);
$this->assertCount(3, $method['availabilityHours']);
$this->assertSame('08-20', $method['availabilityHours']['mondayToFriday']);
$this->assertSame('unavailable', $method['availabilityHours']['saturday']);
$this->assertSame('unavailable', $method['availabilityHours']['sunday']);
}
public function testSendAuthFailure(): void
{
$this->setMockHttpResponse('MethodsAuthFailure.txt');
$response = $this->request->send();
$this->assertInstanceOf(MethodsResponse::class, $response);
$this->assertFalse($response->isSuccessful());
$this->assertSame(Response::HTTP_UNAUTHORIZED, $response->getCode());
$this->assertSame('Incorrect authentication', $response->getMessage());
}
public function testSendNotFoundFailure(): void
{
$this->setMockHttpResponse('MethodsNotFoundFailure.txt');
$response = $this->request->send();
$this->assertInstanceOf(MethodsResponse::class, $response);
$this->assertFalse($response->isSuccessful());
$this->assertSame(Response::HTTP_NOT_FOUND, $response->getCode());
$this->assertSame('Payment methods not found', $response->getMessage());
}
}