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

OldPurchaseResponseTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 61
Duplicated Lines 27.87 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 17 17 1
B testSuccess() 0 24 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\OldPurchaseRequest;
15
use Omnipay\InterKassa\Message\PurchaseRequest;
16
17
class OldPurchaseResponseTest extends PurchaseResponseTest
18
{
19
    /**
20
     * @var OldPurchaseRequest
21
     */
22
    protected $request;
23
24
    protected $purse = '887ac1234c1eeee1488b156b';
25
    protected $secret = 'Zp2zfdSJzbS61L32';
26
    protected $returnUrl = 'https://www.example.com/success';
27
    protected $cancelUrl = 'https://www.example.com/failure';
28
    protected $notifyUrl = 'https://www.example.com/notify';
29
    protected $description = 'Test Transaction long description';
30
    protected $transactionId = 'ID_123456';
31
    protected $amount = '14.65';
32
    protected $currency = 'USD';
33
    protected $sign = 'C5sYWKMUZF1SDPTAGosZntOLC8Q2WWNvxx4bwy/gIwc=';
34
35 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...
36
    {
37
        parent::setUp();
38
39
        $this->request = new PurchaseRequest($this->getHttpClient(), $this->getHttpRequest());
0 ignored issues
show
Documentation Bug introduced by
It seems like new \Omnipay\InterKassa\...this->getHttpRequest()) of type object<Omnipay\InterKass...essage\PurchaseRequest> is incompatible with the declared type object<Omnipay\InterKass...age\OldPurchaseRequest> of property $request.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
40
        $this->request->initialize([
41
            'purse' => $this->purse,
42
            'secret' => $this->secret,
43
            'returnUrl' => $this->returnUrl,
44
            'cancelUrl' => $this->cancelUrl,
45
            'notifyUrl' => $this->notifyUrl,
46
            'description' => $this->description,
47
            'transactionId' => $this->transactionId,
48
            'amount' => $this->amount,
49
            'currency' => $this->currency,
50
        ]);
51
    }
52
53
    public function testSuccess()
54
    {
55
        /** @var PurchaseResponse $response */
56
        $response = $this->request->send();
57
58
        $this->assertFalse($response->isSuccessful());
59
        $this->assertTrue($response->isRedirect());
60
        $this->assertNull($response->getCode());
61
        $this->assertNull($response->getMessage());
62
63
        $this->assertSame('POST', $response->getRedirectMethod());
64
        $this->assertSame([
65
            'ik_co_id' => $this->purse,
66
            'ik_am' => $this->amount,
67
            'ik_pm_no' => $this->transactionId,
68
            'ik_desc' => $this->description,
69
            'ik_cur' => $this->currency,
70
            'ik_pnd_u' => $this->returnUrl,
71
            'ik_suc_u' => $this->returnUrl,
72
            'ik_fal_u' => $this->cancelUrl,
73
            'ik_ia_u' => $this->notifyUrl,
74
            'ik_sign' => $this->sign,
75
        ], $response->getRedirectData());
76
    }
77
}
78