1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* InterKassa driver for the Omnipay PHP payment processing library |
5
|
|
|
* |
6
|
|
|
* @link https://github.com/hiqdev/omnipay-interkassa |
7
|
|
|
* @package omnipay-interkassa |
8
|
|
|
* @license MIT |
9
|
|
|
* @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/) |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Omnipay\InterKassa\Tests\Message; |
13
|
|
|
|
14
|
|
|
use Omnipay\InterKassa\Message\PurchaseRequest; |
15
|
|
|
use Omnipay\InterKassa\Stubs\PurchaseRequestStub; |
16
|
|
|
use Omnipay\Tests\TestCase; |
17
|
|
|
|
18
|
|
|
class PurchaseRequestTest extends TestCase |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* @var |
22
|
|
|
*/ |
23
|
|
|
private $stub; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var PurchaseRequest |
27
|
|
|
*/ |
28
|
|
|
protected $request; |
29
|
|
|
|
30
|
|
|
|
31
|
|
View Code Duplication |
public function setUp() |
|
|
|
|
32
|
|
|
{ |
33
|
|
|
parent::setUp(); |
34
|
|
|
|
35
|
|
|
$this->stub = new PurchaseRequestStub(); |
36
|
|
|
$stub = $this->stub; |
37
|
|
|
|
38
|
|
|
$this->request = new PurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); |
39
|
|
|
$this->request->initialize([ |
40
|
|
|
'purse' => $stub->purse, |
41
|
|
|
'signAlgorithm' => $stub->signAlgorithm, |
42
|
|
|
'signKey' => $stub->signKey, |
43
|
|
|
'testKey' => $stub->testKey, |
44
|
|
|
'returnUrl' => $stub->returnUrl, |
45
|
|
|
'returnMethod' => $stub->returnMethod, |
46
|
|
|
'cancelUrl' => $stub->cancelUrl, |
47
|
|
|
'cancelMethod' => $stub->cancelMethod, |
48
|
|
|
'notifyUrl' => $stub->notifyUrl, |
49
|
|
|
'notifyMethod' => $stub->notifyMethod, |
50
|
|
|
'description' => $stub->description, |
51
|
|
|
'transactionId' => $stub->transactionId, |
52
|
|
|
'amount' => $stub->amount, |
53
|
|
|
'currency' => $stub->currency, |
54
|
|
|
]); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function testGetData() |
58
|
|
|
{ |
59
|
|
|
$data = $this->request->getData(); |
60
|
|
|
|
61
|
|
|
$this->assertSame($this->stub->purse, $data['ik_co_id']); |
62
|
|
|
$this->assertSame($this->stub->returnUrl, $data['ik_suc_u']); |
63
|
|
|
$this->assertSame($this->stub->cancelUrl, $data['ik_fal_u']); |
64
|
|
|
$this->assertSame($this->stub->notifyUrl, $data['ik_ia_u']); |
65
|
|
|
$this->assertSame($this->stub->description, $data['ik_desc']); |
66
|
|
|
$this->assertSame($this->stub->transactionId, $data['ik_pm_no']); |
67
|
|
|
$this->assertSame($this->stub->amount, $data['ik_am']); |
68
|
|
|
$this->assertSame($this->stub->currency, $data['ik_cur']); |
69
|
|
|
$this->assertSame($this->stub->returnMethod, $data['ik_suc_m']); |
70
|
|
|
$this->assertSame($this->stub->returnMethod, $data['ik_pnd_m']); |
71
|
|
|
$this->assertSame($this->stub->cancelMethod, $data['ik_fal_m']); |
72
|
|
|
$this->assertSame($this->stub->notifyMethod, $data['ik_ia_m']); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function testSendData() |
76
|
|
|
{ |
77
|
|
|
$data = $this->request->getData(); |
78
|
|
|
$response = $this->request->sendData($data); |
79
|
|
|
$this->assertSame('Omnipay\InterKassa\Message\PurchaseResponse', get_class($response)); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
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.