-
Notifications
You must be signed in to change notification settings - Fork 3
/
CompletePurchaseRequestTest.php
67 lines (56 loc) · 2.19 KB
/
CompletePurchaseRequestTest.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
<?php
declare(strict_types=1);
namespace Message;
use Omnipay\Przelewy24\Message\CompletePurchaseRequest;
use Omnipay\Przelewy24\Message\CompletePurchaseResponse;
use Omnipay\Tests\TestCase;
use Symfony\Component\HttpFoundation\Response;
class CompletePurchaseRequestTest extends TestCase
{
/**
* @var CompletePurchaseRequest
*/
private $request;
public function setUp(): void
{
$this->request = new CompletePurchaseRequest($this->getHttpClient(), $this->getHttpRequest());
$this->request->initialize([
'merchantId' => '144354',
'posId' => '144354',
'crc' => '1287875353948',
'sessionId' => '42',
'amount' => '12.00',
'currency' => 'PLN',
'transaction_id' => '10273987',
]);
}
public function testGetData(): void
{
$data = $this->request->getData();
$this->assertSame('42', $data['sessionId']);
$this->assertSame(1200, $data['amount']);
$this->assertSame('PLN', $data['currency']);
$this->assertSame('10273987', $data['orderId']);
$this->assertSame('9990dc235a73939da03d7033f302dc4f6d621d662f03f5eb8db827f95d2a048c48f5fe28b5b4a9be13a1fc4a58058055', $data['sign']);
$this->assertCount(7, $data);
}
public function testSendSuccess(): void
{
$this->setMockHttpResponse('CompletePurchaseSuccess.txt');
$response = $this->request->send();
$this->assertInstanceOf(CompletePurchaseResponse::class, $response);
$this->assertTrue($response->isSuccessful());
$this->assertFalse($response->isRedirect());
$this->assertSame('', $response->getMessage());
$this->assertSame(Response::HTTP_OK, $response->getCode());
}
public function testSendFailure(): void
{
$this->setMockHttpResponse('CompletePurchaseFailure.txt');
$response = $this->request->send();
$this->assertInstanceOf(CompletePurchaseResponse::class, $response);
$this->assertFalse($response->isSuccessful());
$this->assertSame(Response::HTTP_BAD_REQUEST, $response->getCode());
$this->assertSame('Incorrect CRC value', $response->getMessage());
}
}