1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* InterKassa driver for the Omnipay PHP payment processing library |
4
|
|
|
* |
5
|
|
|
* @link https://github.com/hiqdev/omnipay-interkassa |
6
|
|
|
* @package omnipay-interkassa |
7
|
|
|
* @license MIT |
8
|
|
|
* @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/) |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Omnipay\InterKassa\Tests\Message; |
12
|
|
|
|
13
|
|
|
use Omnipay\InterKassa\Message\OldPurchaseRequest; |
14
|
|
|
use Omnipay\InterKassa\Stubs\OldPurchaseRequestStub; |
15
|
|
|
use Omnipay\Tests\TestCase; |
16
|
|
|
|
17
|
|
|
class OldPurchaseRequestTest extends TestCase |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @var OldPurchaseRequestStub |
21
|
|
|
*/ |
22
|
|
|
private $stub; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var OldPurchaseRequest |
26
|
|
|
*/ |
27
|
|
|
protected $request; |
28
|
|
|
|
29
|
|
View Code Duplication |
public function setUp() |
|
|
|
|
30
|
|
|
{ |
31
|
|
|
parent::setUp(); |
32
|
|
|
|
33
|
|
|
$this->stub = new OldPurchaseRequestStub(); |
34
|
|
|
$stub = $this->stub; |
35
|
|
|
|
36
|
|
|
$this->request = new OldPurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); |
37
|
|
|
$this->request->initialize([ |
38
|
|
|
'purse' => $stub->purse, |
39
|
|
|
'signAlgorithm' => $stub->signAlgorithm, |
40
|
|
|
'signKey' => $stub->signKey, |
41
|
|
|
'testKey' => $stub->testKey, |
42
|
|
|
'returnUrl' => $stub->returnUrl, |
43
|
|
|
'returnMethod' => $stub->returnMethod, |
44
|
|
|
'cancelUrl' => $stub->cancelUrl, |
45
|
|
|
'cancelMethod' => $stub->cancelMethod, |
46
|
|
|
'notifyUrl' => $stub->notifyUrl, |
47
|
|
|
'notifyMethod' => $stub->notifyMethod, |
48
|
|
|
'description' => $stub->description, |
49
|
|
|
'transactionId' => $stub->transactionId, |
50
|
|
|
'amount' => $stub->amount, |
51
|
|
|
'currency' => $stub->currency, |
52
|
|
|
]); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function testGetData() |
56
|
|
|
{ |
57
|
|
|
$data = $this->request->getData(); |
58
|
|
|
|
59
|
|
|
$this->assertSame($this->stub->purse, $data['ik_shop_id']); |
60
|
|
|
$this->assertSame($this->stub->returnUrl, $data['ik_success_url']); |
61
|
|
|
$this->assertSame($this->stub->cancelUrl, $data['ik_fail_url']); |
62
|
|
|
$this->assertSame($this->stub->notifyUrl, $data['ik_status_url']); |
63
|
|
|
$this->assertSame($this->stub->description, $data['ik_payment_desc']); |
64
|
|
|
$this->assertSame($this->stub->transactionId, $data['ik_payment_id']); |
65
|
|
|
$this->assertSame($this->stub->amount, $data['ik_payment_amount']); |
66
|
|
|
$this->assertSame($this->stub->returnMethod, $data['ik_success_method']); |
67
|
|
|
$this->assertSame($this->stub->cancelMethod, $data['ik_fail_method']); |
68
|
|
|
$this->assertSame($this->stub->notifyMethod, $data['ik_status_method']); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function testSendData() |
72
|
|
|
{ |
73
|
|
|
$data = $this->request->getData(); |
74
|
|
|
$response = $this->request->sendData($data); |
75
|
|
|
$this->assertSame('Omnipay\InterKassa\Message\PurchaseResponse', get_class($response)); |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.