Completed
Push — master ( dc93ce...91f911 )
by Dmitry
02:08
created

NoVerificationCompletePurchaseRequest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 7
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A getData() 0 4 1
1
<?php
2
/**
3
 * OKPAY driver for Omnipay PHP payment library.
4
 *
5
 * @link      https://github.com/hiqdev/omnipay-okpay
6
 * @package   omnipay-okpay
7
 * @license   MIT
8
 * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace Omnipay\OKPAY\Message;
12
13
use Omnipay\Tests\TestCase;
14
use Symfony\Component\HttpFoundation\Request as HttpRequest;
15
16
class CompletePurchaseRequestTest extends TestCase
17
{
18
    private $request;
19
20
    private $purse                  = 'OK426375940';
21
    private $description            = 'evo.ru-tld.ru: deposit valenp';
22
    private $transactionId          = 2705801;
23
    private $amount                 = 68.71;
24
    private $currency               = 'USD';
0 ignored issues
show
Unused Code introduced by
The property $currency is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
25
    private $timestamp              = '2014-03-22 19:54:58';
26
    private $testMode               = true;
27
28
    private $data = [
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
29
        'ok_charset' => 'utf-8',
30
        'ok_receiver' => 'OK426375940',
31
        'ok_receiver_id' => '532844008',
32
        'ok_receiver_wallet' => 'OK426375940',
33
        'ok_receiver_email' => '[email protected]',
34
        'ok_txn_id' => 2705801,
35
        'ok_txn_kind' => 'payment_link',
36
        'ok_txn_payment_type' => 'instant',
37
        'ok_txn_payment_method' => 'OKB',
38
        'ok_txn_gross' => '68.71',
39
        'ok_txn_net' => '68.71',
40
        'ok_txn_fee' => '0.00',
41
        'ok_txn_currency' => 'USD',
42
        'ok_txn_datetime' => '2014-03-22 19:54:58',
43
        'ok_txn_status' => 'completed',
44
        'ok_invoice' => '',
45
        'ok_payer_status' => 'verified',
46
        'ok_payer_id' => '914126735',
47
        'ok_payer_reputation' => '0',
48
        'ok_payer_first_name' => 'Valentin',
49
        'ok_payer_last_name' => 'Perevalov',
50
        'ok_payer_email' => '[email protected]',
51
        'ok_payer_phone' => '7-9080858303',
52
        'ok_payer_country' => 'Russia',
53
        'ok_payer_city' => 'Chelyabinsk',
54
        'ok_payer_country_code' => 'RU',
55
        'ok_payer_state' => 'Chelyabinskaya obl.',
56
        'ok_payer_address_status' => 'confirmed',
57
        'ok_payer_street' => 'Truda 24-136',
58
        'ok_payer_zip' => '454006',
59
        'ok_payer_address_name' => 'Postal',
60
        'ok_items_count' => '1',
61
        'ok_item_1_name' => 'evo.ru-tld.ru: deposit valenp',
62
        'ok_item_1_type' => 'digital',
63
        'ok_item_1_quantity' => '1',
64
        'ok_item_1_gross' => '68.71',
65
        'ok_item_1_price' => '68.71',
66
        'ok_ipn_id' => '2011795',
67
    ];
68
69
    public function setUp()
70
    {
71
        parent::setUp();
72
73
        $httpRequest = new HttpRequest([], $this->data);
74
75
        $this->request = new NoVerificationCompletePurchaseRequest($this->getHttpClient(), $httpRequest);
76
        $this->request->initialize([
77
            'purse'     => $this->purse,
78
            'secret'    => $this->secret,
0 ignored issues
show
Bug introduced by
The property secret does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
79
            'testMode'  => $this->testMode,
80
        ]);
81
    }
82
83 View Code Duplication
    public function testGetData()
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...
84
    {
85
        $data = $this->request->getData();
86
87
        $this->assertSame($this->description,   $data['ok_item_1_name']);
88
        $this->assertSame($this->transactionId, $data['ok_txn_id']);
89
        $this->assertEquals($this->amount,      $data['ok_txn_gross']);
90
        $this->assertSame($this->timestamp,     $data['ok_txn_datetime']);
91
        $this->assertSame($this->purse,         $data['ok_receiver']);
92
    }
93
94
    public function testSendData()
95
    {
96
        //        $data = $this->request->getData();
0 ignored issues
show
Unused Code Comprehensibility introduced by
54% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
97
        $response = $this->request->sendData($this->data);
98
        $this->assertInstanceOf('Omnipay\OKPAY\Message\CompletePurchaseResponse', $response);
99
    }
100
}
101
102
class NoVerificationCompletePurchaseRequest extends CompletePurchaseRequest
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
103
{
104
    public function getData()
105
    {
106
        return $this->httpRequest->request->all();
107
    }
108
}
109