Completed
Push — master ( fde375...74d6aa )
by Vuong
02:28 queued 35s
created

VerifyFilterTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 71
Duplicated Lines 39.44 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 28
loc 71
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A gatewayId() 0 4 1
A testMissingCommand() 0 6 1
A testMissingGateway() 0 6 1
A testInvalid() 13 13 1
A test() 15 15 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
 * @link https://github.com/yiiviet/yii2-payment
4
 * @copyright Copyright (c) 2017 Yii Viet
5
 * @license [New BSD License](http://www.opensource.org/licenses/bsd-license.php)
6
 */
7
8
9
namespace yiiviet\tests\unit\payment;
10
11
use yiiviet\payment\VerifyFilter;
12
13
/**
14
 * Lớp VerifyFilterTest
15
 *
16
 * @author Vuong Minh <[email protected]>
17
 * @since 1.0.2
18
 */
19
class VerifyFilterTest extends TestCase
20
{
21
22
    public static function gatewayId(): string
23
    {
24
        return 'VTC';
25
    }
26
27
    /**
28
     * @expectedException \yii\base\InvalidConfigException
29
     * @expectedExceptionMessage `command` property must be set!
30
     */
31
    public function testMissingCommand()
32
    {
33
        return new VerifyFilter([
34
            'gateway' => $this->gateway
35
        ]);
36
    }
37
38
    /**
39
     * @expectedException \yii\base\InvalidConfigException
40
     * @expectedExceptionMessage `gateway` property must be set!
41
     */
42
    public function testMissingGateway()
43
    {
44
        return new VerifyFilter([
45
            'command' => 'IPN'
46
        ]);
47
    }
48
49
    /**
50
     * @expectedException  \yii\web\ForbiddenHttpException
51
     */
52 View Code Duplication
    public function testInvalid()
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...
53
    {
54
        $_POST = [
55
            '_method' => 'POST',
56
            'data' => '100000|VND|0963465816|1|74132',
57
            'signature' => '1d31c0779f47e2bc3bfe40becf1fda0d7e881aeb90d8efb0341e258692cf896aa'
58
        ];
59
60
        return (new VerifyFilter([
61
            'gateway' => $this->gateway,
62
            'command' => 'IPN'
63
        ]))->beforeAction(null);
64
    }
65
66
    /**
67
     * @depends testMissingCommand
68
     * @depends testMissingGateway
69
     * @depends testInvalid
70
     */
71 View Code Duplication
    public function test()
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...
72
    {
73
        $_POST = [
74
            '_method' => 'POST',
75
            'data' => '100000|VND|0963465816|1|74132',
76
            'signature' => '1d31c0779f47e2bc3bfe40becf1fda0d7e881aeb90d8efb0341e258692cf896a'
77
        ];
78
79
        $result = (new VerifyFilter([
80
            'gateway' => $this->gateway,
81
            'command' => 'IPN'
82
        ]))->beforeAction(null);
83
84
        $this->assertTrue($result);
85
    }
86
87
88
89
}
90