Completed
Push — master ( 136808...1b7afa )
by Dmitry
9s
created

CompletePurchaseRequestTest::testTestMode()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 30
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 2
Metric Value
c 2
b 0
f 2
dl 0
loc 30
rs 8.8571
cc 1
eloc 23
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\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
    protected $purse = '887ac1234c1eeee1488b156b';
26
    protected $signAlgorithm = 'sha256';
27
    protected $signKey = 'Zp2zfdSJzbS61L32';
28
    protected $testKey = 'W0b98idvHeKY2h3w';
29
    protected $description = 'Test Transaction long description';
30
    protected $transactionId = 'ID_123456';
31
    protected $amount = '1465.01';
32
    protected $currency = 'USD';
33
    protected $state = 'success';
34
    protected $time = '2015-12-22 11:07:12';
35
    protected $sign = 'ACm/nwG2yH1y3EVWIriFz4xP3icbqihbAr+06nAsgcU=';
36
37 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...
38
    {
39
        parent::setUp();
40
41
        $httpRequest = new HttpRequest([], [
42
            'ik_co_id' => $this->purse,
43
            'ik_trn_id' => $this->transactionId,
44
            'ik_desc' => $this->description,
45
            'ik_am' => $this->amount,
46
            'ik_cur' => $this->currency,
47
            'ik_inv_prc' => $this->time,
48
            'ik_sign' => $this->sign,
49
            'ik_inv_st' => $this->state,
50
        ]);
51
52
        $this->request = new CompletePurchaseRequest($this->getHttpClient(), $httpRequest);
53
        $this->request->initialize([
54
            'purse' => $this->purse,
55
            'signAlgorithm' => $this->signAlgorithm,
56
            'signKey' => $this->signKey,
57
        ]);
58
    }
59
60
    public function testGetData()
61
    {
62
        $data = $this->request->getData();
63
64
        $this->assertSame($this->purse, $data['ik_co_id']);
65
        $this->assertSame($this->transactionId, $data['ik_trn_id']);
66
        $this->assertSame($this->description, $data['ik_desc']);
67
        $this->assertSame($this->amount, $data['ik_am']);
68
        $this->assertSame($this->currency, $data['ik_cur']);
69
        $this->assertSame($this->time, $data['ik_inv_prc']);
70
    }
71
72
    public function testSendData()
73
    {
74
        $data = $this->request->getData();
75
        $response = $this->request->sendData($data);
76
        $this->assertSame('Omnipay\InterKassa\Message\CompletePurchaseResponse', get_class($response));
77
    }
78
79
    public function testTestMode()
80
    {
81
        $httpRequest = new HttpRequest([], [
82
            'ik_co_id' => $this->purse,
83
            'ik_trn_id' => $this->transactionId,
84
            'ik_desc' => $this->description,
85
            'ik_am' => $this->amount,
86
            'ik_cur' => $this->currency,
87
            'ik_inv_prc' => $this->time,
88
            'ik_sign' => $this->sign,
89
            'ik_inv_st' => $this->state,
90
        ]);
91
92
        $request = new CompletePurchaseRequest($this->getHttpClient(), $httpRequest);
93
        $request->initialize([
94
            'testMode' => true,
95
            'purse' => $this->purse,
96
            'signAlgorithm' => $this->signAlgorithm,
97
            'testKey' => $this->testKey,
98
        ]);
99
100
        $data = $request->getData();
101
102
        $this->assertSame($this->purse, $data['ik_co_id']);
103
        $this->assertSame($this->transactionId, $data['ik_trn_id']);
104
        $this->assertSame($this->description, $data['ik_desc']);
105
        $this->assertSame($this->amount, $data['ik_am']);
106
        $this->assertSame($this->currency, $data['ik_cur']);
107
        $this->assertSame($this->time, $data['ik_inv_prc']);
108
    }
109
}
110