CompletePurchaseRequestTest::testGetData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
dl 12
loc 12
rs 9.8666
c 0
b 0
f 0
cc 1
nc 1
nop 0
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\CompletePurchaseRequest;
14
use Omnipay\InterKassa\Stubs\CompletePurchaseRequestStub;
15
use Omnipay\Tests\TestCase;
16
use Symfony\Component\HttpFoundation\Request as HttpRequest;
17
18
class CompletePurchaseRequestTest extends TestCase
19
{
20
    /**
21
     * @var CompletePurchaseRequest
22
     */
23
    protected $request;
24
25
    /**
26
     * @var CompletePurchaseRequestStub
27
     */
28
    protected $stub;
29
30 View Code Duplication
    public function setUp()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
31
    {
32
        parent::setUp();
33
34
        $this->stub = new CompletePurchaseRequestStub();
35
        $stub = $this->stub;
36
37
        $httpRequest = new HttpRequest([], [
38
            'ik_co_id' => $stub->purse,
39
            'ik_trn_id' => $stub->transactionId,
40
            'ik_desc' => $stub->description,
41
            'ik_am' => $stub->amount,
42
            'ik_cur' => $stub->currency,
43
            'ik_inv_prc' => $stub->time,
44
            'ik_sign' => $stub->sign,
45
            'ik_inv_st' => $stub->state,
46
        ]);
47
48
        $this->request = new CompletePurchaseRequest($this->getHttpClient(), $httpRequest);
49
        $this->request->initialize([
50
            'purse' => $stub->purse,
51
            'signAlgorithm' => $stub->signAlgorithm,
52
            'signKey' => $stub->signKey,
53
        ]);
54
    }
55
56 View Code Duplication
    public function testGetData()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
57
    {
58
        $data = $this->request->getData();
59
        $stub = $this->stub;
60
61
        $this->assertSame($stub->purse, $data['ik_co_id']);
62
        $this->assertSame($stub->transactionId, $data['ik_trn_id']);
63
        $this->assertSame($stub->description, $data['ik_desc']);
64
        $this->assertSame($stub->amount, $data['ik_am']);
65
        $this->assertSame($stub->currency, $data['ik_cur']);
66
        $this->assertSame($stub->time, $data['ik_inv_prc']);
67
    }
68
69
    public function testSendData()
70
    {
71
        $data = $this->request->getData();
72
        $response = $this->request->sendData($data);
73
        $this->assertSame('Omnipay\InterKassa\Message\CompletePurchaseResponse', get_class($response));
74
    }
75
76
    public function testTestMode()
77
    {
78
        $stub = $this->stub;
79
80
        $httpRequest = new HttpRequest([], [
81
            'ik_co_id' => $stub->purse,
82
            'ik_trn_id' => $stub->transactionId,
83
            'ik_desc' => $stub->description,
84
            'ik_am' => $stub->amount,
85
            'ik_cur' => $stub->currency,
86
            'ik_inv_prc' => $stub->time,
87
            'ik_sign' => $stub->sign,
88
            'ik_inv_st' => $stub->state,
89
        ]);
90
91
        $request = new CompletePurchaseRequest($this->getHttpClient(), $httpRequest);
92
        $request->initialize([
93
            'testMode' => true,
94
            'purse' => $stub->purse,
95
            'signAlgorithm' => $stub->signAlgorithm,
96
            'testKey' => $stub->testKey,
97
        ]);
98
99
        $data = $request->getData();
100
101
        $this->assertSame($stub->purse, $data['ik_co_id']);
102
        $this->assertSame($stub->transactionId, $data['ik_trn_id']);
103
        $this->assertSame($stub->description, $data['ik_desc']);
104
        $this->assertSame($stub->amount, $data['ik_am']);
105
        $this->assertSame($stub->currency, $data['ik_cur']);
106
        $this->assertSame($stub->time, $data['ik_inv_prc']);
107
    }
108
}
109