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

PurchaseResponseTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 70
Duplicated Lines 37.14 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 4
Bugs 0 Features 3
Metric Value
wmc 2
c 4
b 0
f 3
lcom 1
cbo 4
dl 26
loc 70
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B setUp() 26 26 1
B testSuccess() 0 30 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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\Message\PurchaseResponse;
16
use Omnipay\InterKassa\Stubs\PurchaseResponseStub;
17
use Omnipay\Tests\TestCase;
18
19
class PurchaseResponseTest extends TestCase
20
{
21
    /**
22
     * @var PurchaseRequest
23
     */
24
    protected $request;
25
26
    /**
27
     * @var PurchaseResponseStub
28
     */
29
    private $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 PurchaseResponseStub();
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
            'cancelUrl' => $stub->cancelUrl,
46
            'notifyUrl' => $stub->notifyUrl,
47
            'description' => $stub->description,
48
            'transactionId' => $stub->transactionId,
49
            'amount' => $stub->amount,
50
            'currency' => $stub->currency,
51
            'returnMethod' => $stub->returnMethod,
52
            'successMethod' => $stub->successMethod,
53
            'cancelMethod' => $stub->cancelMethod,
54
            'notifyMethod' => $stub->notifyMethod,
55
        ]);
56
    }
57
58
    public function testSuccess()
59
    {
60
        /** @var PurchaseResponse $response */
61
        $response = $this->request->send();
62
        $stub = $this->stub;
63
64
        $this->assertFalse($response->isSuccessful());
65
        $this->assertTrue($response->isRedirect());
66
        $this->assertNull($response->getCode());
67
        $this->assertNull($response->getMessage());
68
        $this->assertSame($stub->sci, $response->getRedirectUrl());
69
70
        $this->assertSame('POST', $response->getRedirectMethod());
71
        $this->assertSame([
72
            'ik_co_id' => $stub->purse,
73
            'ik_am' => $stub->amount,
74
            'ik_pm_no' => $stub->transactionId,
75
            'ik_desc' => $stub->description,
76
            'ik_cur' => $stub->currency,
77
            'ik_pnd_u' => $stub->returnUrl,
78
            'ik_pnd_m' => $stub->returnMethod,
79
            'ik_suc_u' => $stub->returnUrl,
80
            'ik_suc_m' => $stub->successMethod,
81
            'ik_fal_u' => $stub->cancelUrl,
82
            'ik_fal_m' => $stub->cancelMethod,
83
            'ik_ia_u' => $stub->notifyUrl,
84
            'ik_ia_m' => $stub->notifyMethod,
85
            'ik_sign' => $stub->sign,
86
        ], $response->getRedirectData());
87
    }
88
}
89