1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ByTIC\Payments\Tests\Gateways\Providers\Librapay; |
4
|
|
|
|
5
|
|
|
use ByTIC\Omnipay\Librapay\Message\ServerCompletePurchaseResponse; |
6
|
|
|
use ByTIC\Payments\Gateways\Providers\Librapay\Gateway; |
7
|
|
|
use ByTIC\Payments\Tests\Fixtures\Records\Gateways\Providers\Librapay\LibrapayData; |
8
|
|
|
use ByTIC\Payments\Tests\Fixtures\Records\PaymentMethods\PaymentMethod; |
9
|
|
|
use ByTIC\Payments\Tests\Gateways\Providers\AbstractGateway\GatewayTest as AbstractGatewayTest; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Class GatewayTest |
13
|
|
|
* @package ByTIC\Payments\Tests\Gateways\Providers\Librapay |
14
|
|
|
*/ |
15
|
|
|
class GatewayTest extends AbstractGatewayTest |
16
|
|
|
{ |
17
|
|
|
public function testIsActive() |
18
|
|
|
{ |
19
|
|
|
$gateway = new Gateway(); |
20
|
|
|
self::assertFalse($gateway->isActive()); |
21
|
|
|
|
22
|
|
|
$gateway->setMerchant('999999'); |
23
|
|
|
$gateway->setTerminal('999999'); |
24
|
|
|
$gateway->setKey('999999'); |
25
|
|
|
$gateway->setMerchantName('999999'); |
26
|
|
|
$gateway->setMerchantEmail('999999'); |
27
|
|
|
|
28
|
|
|
self::assertFalse($gateway->isActive()); |
29
|
|
|
|
30
|
|
|
$gateway->setMerchantUrl('9'); |
31
|
|
|
|
32
|
|
|
self::assertFalse($gateway->isActive()); |
33
|
|
|
|
34
|
|
|
$gateway->setMerchantUrl('999999'); |
35
|
|
|
|
36
|
|
|
self::assertTrue($gateway->isActive()); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function testServerCompletePurchaseConfirmedResponse() |
40
|
|
|
{ |
41
|
|
|
$httpRequest = LibrapayData::getServerCompletePurchaseRequest(); |
42
|
|
|
$response = $this->createServerCompletePurchaseResponse($httpRequest); |
43
|
|
|
|
44
|
|
|
self::assertTrue($response->isSuccessful()); |
45
|
|
|
|
46
|
|
|
$content = $response->getContent(); |
47
|
|
|
self::assertSame('1', $content); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @param $request |
52
|
|
|
* @return ServerCompletePurchaseResponse |
53
|
|
|
*/ |
54
|
|
|
protected function createServerCompletePurchaseResponse($request) |
55
|
|
|
{ |
56
|
|
|
/** @var ServerCompletePurchaseResponse $response */ |
57
|
|
|
$response = $this->gatewayManager->detectItemFromHttpRequest( |
58
|
|
|
$this->purchaseManager, |
59
|
|
|
'serverCompletePurchase', |
60
|
|
|
$request |
61
|
|
|
); |
62
|
|
|
|
63
|
|
|
self::assertInstanceOf(ServerCompletePurchaseResponse::class, $response); |
64
|
|
|
|
65
|
|
|
return $response; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
protected function setUp(): void |
69
|
|
|
{ |
70
|
|
|
parent::setUp(); |
71
|
|
|
|
72
|
|
|
/** @var PaymentMethod $paymentMethod */ |
73
|
|
|
$paymentMethod = $this->purchase->getPaymentMethod(); |
|
|
|
|
74
|
|
|
$paymentMethod->options = trim(LibrapayData::getMethodOptions()); |
75
|
|
|
|
76
|
|
|
$this->purchase->created = date('Y-m-d H:i:s'); |
77
|
|
|
|
78
|
|
|
$this->gateway = $paymentMethod->getType()->getGateway(); |
|
|
|
|
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.