|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace ByTIC\Payments\Tests\Gateways\Providers\PlatiOnline\Message; |
|
4
|
|
|
|
|
5
|
|
|
use ByTIC\Payments\Gateways\Providers\PlatiOnline\Message\ServerCompletePurchaseRequest; |
|
6
|
|
|
use ByTIC\Payments\Gateways\Providers\PlatiOnline\Message\ServerCompletePurchaseResponse; |
|
7
|
|
|
use ByTIC\Payments\Tests\AbstractTest; |
|
8
|
|
|
use ByTIC\Payments\Tests\Fixtures\Records\Purchases\PurchasableRecord; |
|
9
|
|
|
use ByTIC\Payments\Tests\Fixtures\Records\Purchases\PurchasableRecordManager; |
|
10
|
|
|
use ByTIC\Payments\Tests\Gateways\Providers\AbstractGateway\Message\ServerCompletePurchaseResponseTrait; |
|
11
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Class ServerCompletePurchaseResponseTest |
|
15
|
|
|
* @package ByTIC\Payments\Tests\Gateways\Providers\PlatiOnline\Message |
|
16
|
|
|
*/ |
|
17
|
|
|
class ServerCompletePurchaseResponseTest extends AbstractTest |
|
18
|
|
|
{ |
|
19
|
|
|
use ServerCompletePurchaseResponseTrait; |
|
20
|
|
|
|
|
21
|
|
|
public function testResponseForValidTransaction() |
|
22
|
|
|
{ |
|
23
|
|
|
$httpRequest = $this->generateRequestFromFixtures( |
|
24
|
|
|
TEST_FIXTURE_PATH . '/requests/platiOnline/serverCompletePurchase/basicParams.php' |
|
25
|
|
|
); |
|
26
|
|
|
|
|
27
|
|
|
$model = \Mockery::mock(PurchasableRecord::class)->makePartial(); |
|
28
|
|
|
$model->shouldReceive('getPaymentGateway')->andReturn(null); |
|
29
|
|
|
|
|
30
|
|
|
$modelManager = \Mockery::mock(PurchasableRecordManager::class)->makePartial(); |
|
31
|
|
|
$modelManager->shouldReceive('findOne')->andReturn($model); |
|
32
|
|
|
|
|
33
|
|
|
$request = new ServerCompletePurchaseRequest($this->client, $httpRequest); |
|
34
|
|
|
$request->initialize($this->gatewayParams()); |
|
35
|
|
|
$request->setModelManager($modelManager); |
|
36
|
|
|
|
|
37
|
|
|
$response = $request->send(); |
|
38
|
|
|
self::assertInstanceOf(ServerCompletePurchaseResponse::class, $response); |
|
39
|
|
|
self::assertInstanceOf(PurchasableRecord::class, $response->getModel()); |
|
|
|
|
|
|
40
|
|
|
self::assertSame(false, $response->isCancelled()); |
|
41
|
|
|
self::assertSame(false, $response->isPending()); |
|
42
|
|
|
self::assertSame('active', $response->getModelResponseStatus()); |
|
|
|
|
|
|
43
|
|
|
|
|
44
|
|
|
$sessionDebug = $response->getSessionDebug(); |
|
|
|
|
|
|
45
|
|
|
self::assertArrayHasKey('order', $sessionDebug); |
|
46
|
|
|
self::assertArrayHasKey('transaction', $sessionDebug); |
|
47
|
|
|
|
|
48
|
|
|
$content = $response->getContent(); |
|
49
|
|
|
self::assertSame('<?xml version="1.0" encoding="UTF-8" ?><itsn><x_trans_id>6917422</x_trans_id><merchServerStamp>' . date("Y-m-d H:m:s") . '</merchServerStamp><f_response_code>1</f_response_code></itsn>', $content); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @return ServerCompletePurchaseResponse |
|
54
|
|
|
*/ |
|
55
|
|
|
protected function getNewResponse() |
|
56
|
|
|
{ |
|
57
|
|
|
$request = new ServerCompletePurchaseRequest($this->client, new Request()); |
|
58
|
|
|
|
|
59
|
|
|
return new ServerCompletePurchaseResponse($request, []); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
protected function gatewayParams() |
|
63
|
|
|
{ |
|
64
|
|
|
return [ |
|
65
|
|
|
'loginId' => getenv('PLATIONLINE_LOGIN_ID'), |
|
66
|
|
|
'publicKey' => getenv('PLATIONLINE_PUBLIC_KEY'), |
|
67
|
|
|
'privateKey' => getenv('PLATIONLINE_PRIVATE_KEY'), |
|
68
|
|
|
'website' => getenv('PLATIONLINE_WEBSITE'), |
|
69
|
|
|
'initialVector' => getenv('PLATIONLINE_INITIAL_VECTOR'), |
|
70
|
|
|
'initialVectorItsn' => getenv('PLATIONLINE_INITIAL_VECTOR_ITSN'), |
|
71
|
|
|
'testMode' => true |
|
72
|
|
|
]; |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.