-
Notifications
You must be signed in to change notification settings - Fork 3
/
BlikChargeByCodeRequestTest.php
84 lines (69 loc) · 2.84 KB
/
BlikChargeByCodeRequestTest.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
<?php
declare(strict_types=1);
namespace Message;
use Omnipay\Przelewy24\Message\BlikChargeByCodeRequest;
use Omnipay\Przelewy24\Message\BlikChargeByCodeResponse;
use Omnipay\Tests\TestCase;
use Symfony\Component\HttpFoundation\Response;
class BlikChargeByCodeRequestTest extends TestCase
{
/**
* @var BlikChargeByCodeRequest
*/
private $request;
public function setUp(): void
{
$this->request = new BlikChargeByCodeRequest($this->getHttpClient(), $this->getHttpRequest());
$this->request->initialize([
"token" => "test1",
"blikCode" => "test2",
"aliasValue" => "test3",
"aliasLabel" => "test4",
]);
}
public function testGetData(): void
{
$data = $this->request->getData();
$this->assertSame('test1', $data['token']);
$this->assertSame('test2', $data['blikCode']);
$this->assertSame('test3', $data['aliasValue']);
$this->assertSame('test4', $data['aliasLabel']);
}
public function testSendSuccess(): void
{
$this->setMockHttpResponse('BlikChargeByCodeSuccess.txt');
/** @var BlikChargeByCodeResponse $response */
$response = $this->request->send();
$this->assertInstanceOf(BlikChargeByCodeResponse::class, $response);
$this->assertTrue($response->isSuccessful());
$this->assertSame("test123", $response->getOrderId());
$this->assertSame("success", $response->getChargeMessage());
}
public function testSendFailure(): void
{
$this->setMockHttpResponse('BlikChargeByCodeFailure.txt');
$response = $this->request->send();
$this->assertInstanceOf(BlikChargeByCodeResponse::class, $response);
$this->assertFalse($response->isSuccessful());
$this->assertSame(Response::HTTP_BAD_REQUEST, $response->getCode());
$this->assertSame('Invalid input data', $response->getMessage());
}
public function testSendAuthFailure(): void
{
$this->setMockHttpResponse('BlikChargeByCodeAuthFailure.txt');
$response = $this->request->send();
$this->assertInstanceOf(BlikChargeByCodeResponse::class, $response);
$this->assertFalse($response->isSuccessful());
$this->assertSame(Response::HTTP_UNAUTHORIZED, $response->getCode());
$this->assertSame('Incorrect authentication', $response->getMessage());
}
public function testUndefinedError(): void
{
$this->setMockHttpResponse('BlikChargeByCodeUndefinedError.txt');
$response = $this->request->send();
$this->assertInstanceOf(BlikChargeByCodeResponse::class, $response);
$this->assertFalse($response->isSuccessful());
$this->assertSame(Response::HTTP_INTERNAL_SERVER_ERROR, $response->getCode());
$this->assertSame("Undefined error", $response->getMessage());
}
}