Completed
Push — master ( 8fe2d8...225854 )
by Andrii
20:54 queued 20:54
created

OldCompletePurchaseResponseTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 3
dl 0
loc 50
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A createRequest() 0 22 1
A testSignException() 0 5 1
A testStateException() 0 5 1
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\OldCompletePurchaseRequest;
15
use Omnipay\InterKassa\Message\OldCompletePurchaseResponse;
16
use Symfony\Component\HttpFoundation\Request as HttpRequest;
17
18
class OldCompletePurchaseResponseTest extends CompletePurchaseResponseTest
19
{
20
    /**
21
     * @var OldCompletePurchaseResponse
22
     */
23
    protected $request;
24
25
    protected $purse = '62B97027-5260-1442-CF1A-7BDC16454400';
26
    protected $sign = 'RtCUy16yl+8c3YidodCa7GC5j0BlI9Y0N5N6oUMLriI=';
27
    protected $currency = null;
28
29
    /**
30
     * @param array $options
31
     * @return OldCompletePurchaseRequest
32
     */
33
    public function createRequest($options = [])
34
    {
35
        $httpRequest = new HttpRequest([], array_merge([
36
            'ik_shop_id' => $this->purse,
37
            'ik_payment_id' => $this->transactionId,
38
            'ik_payment_desc' => $this->description,
39
            'ik_payment_amount' => $this->amount,
40
            'ik_payment_timestamp' => $this->time,
41
            'ik_sign_hash' => $this->sign,
42
            'ik_payment_state' => $this->state,
43
            'ik_trans_id' => $this->invoiceId,
44
            'ik_paysystem_alias' => $this->payway,
45
46
        ], $options));
47
48
        $request = new OldCompletePurchaseRequest($this->getHttpClient(), $httpRequest);
49
        $request->initialize([
50
            'secret' => $this->secret,
51
        ]);
52
53
        return $request;
54
    }
55
56
    public function testSignException()
57
    {
58
        $this->setExpectedException('Omnipay\Common\Exception\InvalidResponseException', 'Failed to validate signature');
59
        $this->createRequest(['ik_wtf' => ':)'])->send();
60
    }
61
62
    public function testStateException()
63
    {
64
        $this->setExpectedException('Omnipay\Common\Exception\InvalidResponseException', 'The payment was not success');
65
        $this->createRequest(['ik_payment_state' => 'fail', 'ik_sign_hash' => '2+Wv5Qna6e+BIhRrykWZ46RJ5sVeEnMdVfPUMxa8tVc='])->send();
66
    }
67
}
68