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

OldPurchaseRequestTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 62
Duplicated Lines 40.32 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
B setUp() 25 25 1
A testGetData() 0 15 1
A testSendData() 0 6 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\Stubs\OldPurchaseRequestStub;
16
use Omnipay\Tests\TestCase;
17
18
class OldPurchaseRequestTest extends TestCase
19
{
20
    /**
21
     * @var OldPurchaseRequestStub
22
     */
23
    private $stub;
24
25
    /**
26
     * @var OldPurchaseRequest
27
     */
28
    protected $request;
29
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 OldPurchaseRequestStub();
36
        $stub = $this->stub;
37
38
        $this->request = new OldPurchaseRequest($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
            'returnMethod' => $stub->returnMethod,
46
            'cancelUrl' => $stub->cancelUrl,
47
            'cancelMethod' => $stub->cancelMethod,
48
            'notifyUrl' => $stub->notifyUrl,
49
            'notifyMethod' => $stub->notifyMethod,
50
            'description' => $stub->description,
51
            'transactionId' => $stub->transactionId,
52
            'amount' => $stub->amount,
53
            'currency' => $stub->currency,
54
        ]);
55
    }
56
57
    public function testGetData()
58
    {
59
        $data = $this->request->getData();
60
61
        $this->assertSame($this->stub->purse, $data['ik_shop_id']);
62
        $this->assertSame($this->stub->returnUrl, $data['ik_success_url']);
63
        $this->assertSame($this->stub->cancelUrl, $data['ik_fail_url']);
64
        $this->assertSame($this->stub->notifyUrl, $data['ik_status_url']);
65
        $this->assertSame($this->stub->description, $data['ik_payment_desc']);
66
        $this->assertSame($this->stub->transactionId, $data['ik_payment_id']);
67
        $this->assertSame($this->stub->amount, $data['ik_payment_amount']);
68
        $this->assertSame($this->stub->returnMethod, $data['ik_success_method']);
69
        $this->assertSame($this->stub->cancelMethod, $data['ik_fail_method']);
70
        $this->assertSame($this->stub->notifyMethod, $data['ik_status_method']);
71
    }
72
73
    public function testSendData()
74
    {
75
        $data = $this->request->getData();
76
        $response = $this->request->sendData($data);
77
        $this->assertSame('Omnipay\InterKassa\Message\PurchaseResponse', get_class($response));
78
    }
79
}
80