Completed
Push — master ( 1b7afa...9fbca5 )
by Dmitry
03:33
created

CompletePurchaseRequestTest::setUp()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 18

Duplication

Lines 25
Ratio 100 %

Importance

Changes 4
Bugs 0 Features 3
Metric Value
c 4
b 0
f 3
dl 25
loc 25
rs 8.8571
cc 1
eloc 18
nc 1
nop 0
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\CompletePurchaseRequest;
15
use Omnipay\InterKassa\Stubs\CompletePurchaseRequestStub;
16
use Omnipay\Tests\TestCase;
17
use Symfony\Component\HttpFoundation\Request as HttpRequest;
18
19
class CompletePurchaseRequestTest extends TestCase
20
{
21
    /**
22
     * @var CompletePurchaseRequest
23
     */
24
    protected $request;
25
26
    /**
27
     * @var CompletePurchaseRequestStub
28
     */
29
    protected $stub;
30
31 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...
32
    {
33
        parent::setUp();
34
35
        $this->stub = new CompletePurchaseRequestStub();
36
        $stub = $this->stub;
37
38
        $httpRequest = new HttpRequest([], [
39
            'ik_co_id' => $stub->purse,
40
            'ik_trn_id' => $stub->transactionId,
41
            'ik_desc' => $stub->description,
42
            'ik_am' => $stub->amount,
43
            'ik_cur' => $stub->currency,
44
            'ik_inv_prc' => $stub->time,
45
            'ik_sign' => $stub->sign,
46
            'ik_inv_st' => $stub->state,
47
        ]);
48
49
        $this->request = new CompletePurchaseRequest($this->getHttpClient(), $httpRequest);
50
        $this->request->initialize([
51
            'purse' => $stub->purse,
52
            'signAlgorithm' => $stub->signAlgorithm,
53
            'signKey' => $stub->signKey,
54
        ]);
55
    }
56
57 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...
58
    {
59
        $data = $this->request->getData();
60
        $stub = $this->stub;
61
62
        $this->assertSame($stub->purse, $data['ik_co_id']);
63
        $this->assertSame($stub->transactionId, $data['ik_trn_id']);
64
        $this->assertSame($stub->description, $data['ik_desc']);
65
        $this->assertSame($stub->amount, $data['ik_am']);
66
        $this->assertSame($stub->currency, $data['ik_cur']);
67
        $this->assertSame($stub->time, $data['ik_inv_prc']);
68
    }
69
70
    public function testSendData()
71
    {
72
        $data = $this->request->getData();
73
        $response = $this->request->sendData($data);
74
        $this->assertSame('Omnipay\InterKassa\Message\CompletePurchaseResponse', get_class($response));
75
    }
76
77
    public function testTestMode()
78
    {
79
        $stub = $this->stub;
80
81
        $httpRequest = new HttpRequest([], [
82
            'ik_co_id' => $stub->purse,
83
            'ik_trn_id' => $stub->transactionId,
84
            'ik_desc' => $stub->description,
85
            'ik_am' => $stub->amount,
86
            'ik_cur' => $stub->currency,
87
            'ik_inv_prc' => $stub->time,
88
            'ik_sign' => $stub->sign,
89
            'ik_inv_st' => $stub->state,
90
        ]);
91
92
        $request = new CompletePurchaseRequest($this->getHttpClient(), $httpRequest);
93
        $request->initialize([
94
            'testMode' => true,
95
            'purse' => $stub->purse,
96
            'signAlgorithm' => $stub->signAlgorithm,
97
            'testKey' => $stub->testKey,
98
        ]);
99
100
        $data = $request->getData();
101
102
        $this->assertSame($stub->purse, $data['ik_co_id']);
103
        $this->assertSame($stub->transactionId, $data['ik_trn_id']);
104
        $this->assertSame($stub->description, $data['ik_desc']);
105
        $this->assertSame($stub->amount, $data['ik_am']);
106
        $this->assertSame($stub->currency, $data['ik_cur']);
107
        $this->assertSame($stub->time, $data['ik_inv_prc']);
108
    }
109
}
110