-
Notifications
You must be signed in to change notification settings - Fork 3
/
BlikAliasesByEmailRequestTest.php
77 lines (62 loc) · 2.52 KB
/
BlikAliasesByEmailRequestTest.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
<?php
declare(strict_types=1);
namespace Message;
use Omnipay\Przelewy24\Message\BlikAliasesByEmailRequest;
use Omnipay\Przelewy24\Message\BlikAliasesByEmailResponse;
use Omnipay\Tests\TestCase;
use Symfony\Component\HttpFoundation\Response;
class BlikAliasesByEmailRequestTest extends TestCase
{
/**
* @var BlikAliasesByEmailRequest
*/
private $request;
public function setUp(): void
{
$this->request = new BlikAliasesByEmailRequest($this->getHttpClient(), $this->getHttpRequest());
$this->request->initialize([
"email" => "[email protected]",
]);
}
public function testGetData(): void
{
$data = $this->request->getData();
$this->assertSame('[email protected]', $data['email']);
}
public function testSendSuccess(): void
{
$this->setMockHttpResponse('BlikAliasesByEmailSuccess.txt');
/** @var BlikAliasesByEmailResponse $response */
$response = $this->request->send();
$this->assertInstanceOf(BlikAliasesByEmailResponse::class, $response);
$this->assertTrue($response->isSuccessful());
$this->assertCount(2, $response->getAliases());
}
public function testSendFailure(): void
{
$this->setMockHttpResponse('BlikAliasesByEmailFailure.txt');
$response = $this->request->send();
$this->assertInstanceOf(BlikAliasesByEmailResponse::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('BlikAliasesByEmailAuthFailure.txt');
$response = $this->request->send();
$this->assertInstanceOf(BlikAliasesByEmailResponse::class, $response);
$this->assertFalse($response->isSuccessful());
$this->assertSame(Response::HTTP_UNAUTHORIZED, $response->getCode());
$this->assertSame('Incorrect authentication', $response->getMessage());
}
public function testSendNotFound(): void
{
$this->setMockHttpResponse('BlikAliasesByEmailNotFound.txt');
$response = $this->request->send();
$this->assertInstanceOf(BlikAliasesByEmailResponse::class, $response);
$this->assertFalse($response->isSuccessful());
$this->assertSame(Response::HTTP_NOT_FOUND, $response->getCode());
$this->assertSame("Transaction not found", $response->getMessage());
}
}